一種解決方案:
表
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);
你救我的一天。 –
Stackoverflow旨在保存我們的日子:D。它也多次拯救了我的一天 – doanduyhai