我有一個cassandra db和具有TimeUUIDType比較器的列系列。我使用Hector並使用RandomPartitioner具有密鑰空間。TimeUUID列上的切片查詢
我想進行切片查詢以獲得由TimeUUID排序的可分頁結果。
SliceQuery<String, UUID, UserLike> query = HFactory.createSliceQuery(getKeyspace(), StringSerializer.get(), TimeUUIDSerializer.get(), UserLikesSerializer.get());
query = query.setKey(username);
query.setColumnFamily(SOME_CF);
當我配置與此代碼查詢:
query.setRange(new UUID(UUIDGen.createTime(Long.MAX_VALUE),UUIDGen.getClockSeqAndNode()), null, true, maxResults);
我不正確的序列(可能是因爲我使用RandomPartitioner - 正確的嗎?)檢索數據 當我配置與此代碼的查詢:
query.setRange(new UUID(UUIDGen.createTime(Long.MAX_VALUE),UUIDGen.getClockSeqAndNode()), new UUID(UUIDGen.createTime(0),UUIDGen.getClockSeqAndNode()), true, maxResults);
我得到一個錯誤:
InvalidRequestException(why:range finish must come after start in the order of traversal)
at me.prettyprint.hector.api.exceptions.HInvalidRequestException
任何想法?
不完全。是時間跨度問題(我的意思是價值Long.MAX_VALUE)。我用System.currentTimeInMillis()替換它,現在它就像一個魅力 – tomekkup