【发布时间】:2015-07-26 23:17:22
【问题描述】:
我有下表:
CREATE TABLE prosfiles (
name_file text,
beginpros timestamp,
humandate timestamp,
lastpros timestamp,
originalname text,
pros int,
uploaded int,
uploader text,
PRIMARY KEY (name_file)
)
CREATE INDEX prosfiles_pros_idx ON prosfiles (pros);
在这个表中,我保留了几个由 python 脚本处理的 csv 文件的位置,因为我有几个脚本同时运行处理这些文件,我使用这个表来保持控制并避免两个脚本开始处理同一个文件('pros' 列中的 0 表示文件尚未处理,1 表示已处理的文件,1010 表示当前正在由另一个脚本处理的文件)
每个文件都运行以下查询来选择要处理的文件:
"select name_file from prosfiles where pros = 0 limit 1"
但这总是返回具有该条件的文件的第一行
我想运行一个查询,从所有 pros = 0 的行中返回一个随机行。
在 mysql 中我使用了“order by rand()”,但在 cassandra 中我不知道如何对结果进行随机排序。
【问题讨论】:
标签: python cassandra cassandra-2.0