一种解决方案:
桌子
CREATE TABLE image_by_size
(
rowkey text, // arbitrary text, it can be 'IMAGE_BY_SIZE' for example
size int,
id_image text,
PRIMARY KEY (rowkey,size,id_image)
);
按大小列出图像:
SELECT id_image FROM image_by_size WHERE rowkey='IMAGE_BY_SIZE' ORDER BY size DESC;
桌子
CREATE TABLE image_by_view
(
rowkey text, // arbitrary text, it can be 'IMAGE_BY_VIEW' for example
view int,
id_image text,
PRIMARY KEY (rowkey,view,id_image)
);
按视图列出图像:
SELECT id_image FROM image_by_view WHERE rowkey='IMAGE_BY_VIEW' ORDER BY size DESC;
桌子
CREATE TABLE image_by_create
(
rowkey text, // arbitrary text, it can be 'IMAGE_BY_CREATE_DATE' for example
create_date timestamp,
id_image text,
PRIMARY KEY (rowkey,create_date,id_image)
);
按创建日期列出图像:
SELECT id_image FROM image_by_create WHERE rowkey='IMAGE_BY_CREATE_DATE' ORDER BY create_date DESC;
一桌解决方案
由于大小、视图和时间戳都是数字,因此可以只使用一张表来索引所有这些
CREATE TABLE image_index
(
index_type text, // 'IMAGE_BY_SIZE', 'IMAGE_BY_VIEW' or 'IMAGE_BY_CREATE_DATE'
value bigint,
id_image text,
PRIMARY KEY (index_type,value,id_image)
);
按大小索引图像
INSERT INTO image_index(index_type,value,id_image) VALUES('IMAGE_BY_SIZE',size_as_long,id_image);
按视图索引图像
INSERT INTO image_index(index_type,value,id_image) VALUES('IMAGE_BY_VIEW',view_as_long,id_image);
按创建日期索引图像
INSERT INTO image_index(index_type,value,id_image) VALUES('IMAGE_BY_CREATE_DATE',create_timestamp_as_long,id_image);