@Test public void testGetSliceWithCollision() throws Exception { Keyspace keyspace = Keyspace.open(KEYSPACE); ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF); cfs.clearUnsafe(); insert("k1", "k2", "k3"); // token = 2 insert("key1", "key2", "key3"); // token = 4 insert("longKey1", "longKey2"); // token = 8 List<Row> rows = cfs.getRangeSlice( new Bounds<RowPosition>(dk("k2"), dk("key2")), null, new IdentityQueryFilter(), 10000); assert rows.size() == 4 : "Expecting 4 keys, got " + rows.size(); assert rows.get(0).key.key.equals(ByteBufferUtil.bytes("k2")); assert rows.get(1).key.key.equals(ByteBufferUtil.bytes("k3")); assert rows.get(2).key.key.equals(ByteBufferUtil.bytes("key1")); assert rows.get(3).key.key.equals(ByteBufferUtil.bytes("key2")); }
private void insert(String key) { Mutation rm; rm = new Mutation(KEYSPACE, ByteBufferUtil.bytes(key)); rm.add(CF, Util.cellname("column"), ByteBufferUtil.bytes("asdf"), 0); rm.apply(); }
public Token<BigInteger> fromByteArray(ByteBuffer bytes) { return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes))); }