private List<KeySlice> getKeySlice(ByteBuffer startKey, ByteBuffer endKey, SliceQuery columnSlice, int count) throws BackendException { return getRangeSlices(new org.apache.cassandra.thrift.KeyRange().setStart_key(startKey).setEnd_key(endKey).setCount(count), columnSlice); }
private List<byte[]> getRows(byte[] rangeStart) { KeyRange keyRange = new KeyRange().setStart_key(rangeStart).setEnd_key(new byte[0]).setCount(batchHint); SlicePredicate slicePredicate = SlicePredicates.create(SlicePredicates.Range.ALL, SlicePredicates.Limit.ZERO); List<KeySlice> rows = rowGetter.getRows("getCandidateCellsForSweeping", keyRange, slicePredicate); return rows.stream().map(KeySlice::getKey).collect(Collectors.toList()); }
private KeyRange getKeyRange(byte[] startKey, byte[] endExclusive) { KeyRange keyRange = new KeyRange(batchHint); keyRange.setStart_key(startKey); if (endExclusive.length == 0) { keyRange.setEnd_key(endExclusive); } else { // We need the previous name because this is inclusive, not exclusive keyRange.setEnd_key(RangeRequests.previousLexicographicName(endExclusive)); } return keyRange; } }
/** * * @return The thrift representation of this object */ public KeyRange toThrift() { KeyRange keyRange = new KeyRange(rowCount); if(startToken != null) keyRange.setStart_token(startToken); else keyRange.setStart_key(startKey == null ? ByteBuffer.wrap(new byte[0]) : keySerializer.toByteBuffer(startKey)); if(endToken != null) keyRange.setEnd_token(endToken); else keyRange.setEnd_key(endKey == null ? ByteBuffer.wrap(new byte[0]) : keySerializer.toByteBuffer(endKey)); if (rowFilters != null) for (IndexExpression filter : rowFilters) { keyRange.addToRow_filter(filter); } return keyRange; }
keyRange.setStart_key(minVal == null ? "".getBytes() : minVal); keyRange.setEnd_key(maxVal == null ? "".getBytes() : maxVal); ColumnParent cp = new ColumnParent(m.getTableName());
keyRange.setStart_key(ByteBufferUtil.EMPTY_BYTE_BUFFER); keyRange.setEnd_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);
public KeyRange setStart_key(byte[] start_key) { setStart_key(start_key == null ? (ByteBuffer)null : ByteBuffer.wrap(start_key)); return this; }
public KeyRange setStart_key(byte[] start_key) { setStart_key(start_key == null ? (ByteBuffer)null : ByteBuffer.wrap(start_key)); return this; }
public KeyRange setStart_key(byte[] start_key) { setStart_key(start_key == null ? (ByteBuffer)null : ByteBuffer.wrap(start_key)); return this; }
@Test public void testGetSuperRangeSlices() throws HectorException { for (int i = 0; i < 10; i++) { ColumnPath cp = new ColumnPath("Super1"); cp.setSuper_column(bytes("SuperColumn_1")); cp.setColumn(bytes("testGetSuperRangeSlices_" + i)); keyspace.insert("testGetSuperRangeSlices0", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlices_Value_" + i)); keyspace.insert("testGetSuperRangeSlices1", cp, StringSerializer.get().toByteBuffer("testGetSuperRangeSlices_Value_" + i)); } // get value ColumnParent clp = new ColumnParent("Super1"); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); KeyRange range = new KeyRange(); range.setStart_key( "".getBytes()); range.setEnd_key( "".getBytes()); Map<String, List<SuperColumn>> keySlices = se.fromBytesMap(keyspace.getSuperRangeSlices(clp, sp, range)); assertNotNull(keySlices); assertNotNull("testGetSuperRangSlices0 is null", keySlices.get("testGetSuperRangeSlices0")); assertEquals("testGetSuperRangeSlices_Value_0", string(keySlices.get("testGetSuperRangeSlices0").get(0).getColumns().get(0).getValue())); assertEquals(1, keySlices.get("testGetSuperRangeSlices1").size()); assertEquals(10, keySlices.get("testGetSuperRangeSlices1").get(0).getColumns().size()); ColumnPath cp = new ColumnPath("Super1"); keyspace.remove("testGetSuperRangeSlices0", cp); keyspace.remove("testGetSuperRangeSlices1", cp); }
@Test public void testGetRangeSlices() throws HectorException { for (int i = 0; i < 10; i++) { ColumnPath cp = new ColumnPath("Standard1"); cp.setColumn(bytes("testGetRangeSlices_" + i)); keyspace.insert("testGetRangeSlices0", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i)); keyspace.insert("testGetRangeSlices1", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i)); keyspace.insert("testGetRangeSlices2", cp, StringSerializer.get().toByteBuffer("testGetRangeSlices_Value_" + i)); } // get value ColumnParent clp = new ColumnParent("Standard1"); SliceRange sr = new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false, 150); SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(sr); KeyRange range = new KeyRange(); range.setStart_key( "".getBytes()); range.setEnd_key( "".getBytes()); Map<String, List<Column>> keySlices = se.fromBytesMap(keyspace.getRangeSlices(clp, sp, range)); assertNotNull(keySlices); assertNotNull("testGetRangeSlices1 is null", keySlices.get("testGetRangeSlices1")); assertEquals("testGetRangeSlices_Value_0", string(keySlices.get("testGetRangeSlices1").get(0).getValue())); assertEquals(10, keySlices.get("testGetRangeSlices1").size()); ColumnPath cp = new ColumnPath("Standard1"); keyspace.remove("testGetRanageSlices0", cp); keyspace.remove("testGetRanageSlices1", cp); keyspace.remove("testGetRanageSlices2", cp); }
public byte[] getStart_key() { setStart_key(org.apache.thrift.TBaseHelper.rightSize(start_key)); return start_key == null ? null : start_key.array(); }
private List<byte[]> getRows(byte[] rangeStart) { KeyRange keyRange = new KeyRange().setStart_key(rangeStart).setEnd_key(new byte[0]).setCount(batchHint); SlicePredicate slicePredicate = SlicePredicates.create(SlicePredicates.Range.ALL, SlicePredicates.Limit.ZERO); List<KeySlice> rows = rowGetter.getRows("getCandidateCellsForSweeping", keyRange, slicePredicate); return rows.stream().map(KeySlice::getKey).collect(Collectors.toList()); }
/** * * @return The thrift representation of this object */ public KeyRange toThrift() { KeyRange keyRange = new KeyRange(rowCount); keyRange.setStart_key(startKey == null ? ByteBuffer.wrap(new byte[0]) : keySerializer.toByteBuffer(startKey)); keyRange.setEnd_key(endKey == null ? ByteBuffer.wrap(new byte[0]) : keySerializer.toByteBuffer(endKey)); return keyRange; }
static KeyRange keyRangeStartRow(byte[] startRowKey, int count) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(startRowKey == null ? EMPTY_BYTES : startRowKey); keyRange.setEnd_key(EMPTY_BYTES); keyRange.setCount(count); return keyRange; }
/** * Create a KeyRange that begins at the given row key. * * @param startRowKey Starting row key as a byte[]. * @return KeyRange that starts at the given row, open-ended. */ static KeyRange keyRangeStartRow(byte[] startRowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(startRowKey); keyRange.setEnd_key(EMPTY_BYTE_BUFFER); keyRange.setCount(MAX_ROWS_BATCH_SIZE); return keyRange; } // keyRangeStartRow
/** * Create a KeyRange that begins at the given row key. * * @param startRowKey Starting row key as a byte[]. * @return KeyRange that starts at the given row, open-ended. */ static KeyRange keyRangeStartRow(byte[] startRowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(startRowKey); keyRange.setEnd_key(EMPTY_BYTE_BUFFER); keyRange.setCount(MAX_ROWS_BATCH_SIZE); return keyRange; } // keyRangeStartRow
/** * Create a KeyRange that selects a single row with the given key. * * @param rowKey Row key as a byte[]. * @return KeyRange that starts and ends with the given key. */ static KeyRange keyRangeSingleRow(byte[] rowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(rowKey); keyRange.setEnd_key(rowKey); keyRange.setCount(1); return keyRange; } // keyRangeSingleRow
private List<KeySlice> getKeySlice(ByteBuffer startKey, ByteBuffer endKey, SliceQuery columnSlice, int count) throws BackendException { return getRangeSlices(new org.apache.cassandra.thrift.KeyRange().setStart_key(startKey).setEnd_key(endKey).setCount(count), columnSlice); }
public List<KeySlice> getRangeSlice(ByteBuffer start, ByteBuffer end, int limit) throws Exception { SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, limit)); ColumnParent parent = new ColumnParent(cfName); KeyRange range = new KeyRange(limit).setStart_key(start).setEnd_key(end); return client.get_range_slices(parent, predicate, range, cl); }