@Test public void testKeyValueRangesMany3() { putDirect("row1", "col1", "", 0); putDirect("row2", "col1", "", 0); putDirect("row2", "col2", "", 0); RangeRequest allRange = RangeRequest.builder().prefixRange("row1".getBytes()).batchHint(3).build(); for (int i = 0 ; i < 1000 ; i++) { ClosableIterator<RowResult<Value>> range = keyValueService.getRange(TEST_TABLE, allRange, 1); ImmutableList<RowResult<Value>> list = ImmutableList.copyOf(range); assertEquals(1, list.size()); } }
@Test public void testGetRangesPaging() { Transaction t = startTransaction(); byte[] row0Bytes = PtBytes.toBytes("row0"); byte[] row00Bytes = PtBytes.toBytes("row00"); byte[] colBytes = PtBytes.toBytes("col"); Cell k1 = Cell.create(row00Bytes, colBytes); byte[] row1Bytes = PtBytes.toBytes("row1"); Cell k2 = Cell.create(row1Bytes, colBytes); byte[] v = PtBytes.toBytes("v"); t.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0Bytes, colBytes), v)); t.put(TEST_TABLE, ImmutableMap.of(k1, v)); t.put(TEST_TABLE, ImmutableMap.of(k2, v)); t.commit(); t = startTransaction(); t.delete(TEST_TABLE, ImmutableSet.of(k1)); t.commit(); t = startTransaction(); byte[] rangeEnd = RangeRequests.nextLexicographicName(row00Bytes); List<RangeRequest> ranges = ImmutableList.of(RangeRequest.builder().prefixRange(row0Bytes).endRowExclusive(rangeEnd).batchHint(1).build()); verifyAllGetRangesImplsNumRanges(t, ranges, ImmutableList.of("v")); }
@Test public void testGetRanges() { Transaction t = startTransaction(); byte[] row1Bytes = PtBytes.toBytes("row1"); Cell row1Key = Cell.create(row1Bytes, PtBytes.toBytes("col")); byte[] row1Value = PtBytes.toBytes("value1"); byte[] row2Bytes = PtBytes.toBytes("row2"); Cell row2Key = Cell.create(row2Bytes, PtBytes.toBytes("col")); byte[] row2Value = PtBytes.toBytes("value2"); t.put(TEST_TABLE, ImmutableMap.of(row1Key, row1Value, row2Key, row2Value)); t.commit(); t = startTransaction(); List<RangeRequest> ranges = ImmutableList.of( RangeRequest.builder().prefixRange(row1Bytes).build(), RangeRequest.builder().prefixRange(row2Bytes).build()); verifyAllGetRangesImplsNumRanges(t, ranges, ImmutableList.of("value1", "value2")); }
@Test public void testGetRangesPaging() { Transaction t = startTransaction(); byte[] row0Bytes = PtBytes.toBytes("row0"); byte[] row00Bytes = PtBytes.toBytes("row00"); byte[] colBytes = PtBytes.toBytes("col"); Cell k1 = Cell.create(row00Bytes, colBytes); byte[] row1Bytes = PtBytes.toBytes("row1"); Cell k2 = Cell.create(row1Bytes, colBytes); byte[] v = PtBytes.toBytes("v"); t.put(TEST_TABLE, ImmutableMap.of(Cell.create(row0Bytes, colBytes), v)); t.put(TEST_TABLE, ImmutableMap.of(k1, v)); t.put(TEST_TABLE, ImmutableMap.of(k2, v)); t.commit(); t = startTransaction(); t.delete(TEST_TABLE, ImmutableSet.of(k1)); t.commit(); t = startTransaction(); byte[] rangeEnd = RangeRequests.nextLexicographicName(row00Bytes); List<RangeRequest> ranges = ImmutableList.of(RangeRequest.builder().prefixRange(row0Bytes).endRowExclusive(rangeEnd).batchHint(1).build()); verifyAllGetRangesImplsNumRanges(t, ranges, ImmutableList.of("v")); }
@Test public void testGetRanges() { Transaction t = startTransaction(); byte[] row1Bytes = PtBytes.toBytes("row1"); Cell row1Key = Cell.create(row1Bytes, PtBytes.toBytes("col")); byte[] row1Value = PtBytes.toBytes("value1"); byte[] row2Bytes = PtBytes.toBytes("row2"); Cell row2Key = Cell.create(row2Bytes, PtBytes.toBytes("col")); byte[] row2Value = PtBytes.toBytes("value2"); t.put(TEST_TABLE, ImmutableMap.of(row1Key, row1Value, row2Key, row2Value)); t.commit(); t = startTransaction(); List<RangeRequest> ranges = ImmutableList.of( RangeRequest.builder().prefixRange(row1Bytes).build(), RangeRequest.builder().prefixRange(row2Bytes).build()); verifyAllGetRangesImplsNumRanges(t, ranges, ImmutableList.of("value1", "value2")); }
@Test public void testKeyValueRangesMany3() { putDirect("row1", "col1", "", 0); putDirect("row2", "col1", "", 0); putDirect("row2", "col2", "", 0); RangeRequest allRange = RangeRequest.builder().prefixRange("row1".getBytes()).batchHint(3).build(); for (int i = 0 ; i < 1000 ; i++) { ClosableIterator<RowResult<Value>> range = keyValueService.getRange(TEST_TABLE, allRange, 1); ImmutableList<RowResult<Value>> list = ImmutableList.copyOf(range); assertEquals(1, list.size()); } }
@Test public void testPrefix() { byte[] end = RangeRequest.builder().prefixRange(new byte[] {-1}).build().getEndExclusive(); assertEquals(0, end.length); end = RangeRequest.builder().prefixRange(new byte[] {-2}).build().getEndExclusive(); assertEquals(1, end.length); assertEquals(-1, end[0]); end = RangeRequest.builder().prefixRange(new byte[] {0, -1}).build().getEndExclusive(); assertEquals(1, end.length); assertEquals(1, end[0]); end = RangeRequest.builder().prefixRange(new byte[] {0, -1, 0}).build().getEndExclusive(); assertEquals(3, end.length); assertEquals(1, end[2]); }
public static RangeRequest.Builder createPrefixRange(long value1) { byte[] value1Bytes = PtBytes.toBytes(Long.MIN_VALUE ^ value1); return RangeRequest.builder().prefixRange(EncodingUtils.add(value1Bytes)); }
public static RangeRequest.Builder createPrefixRange(long value) { byte[] valueBytes = PtBytes.toBytes(Long.MIN_VALUE ^ value); return RangeRequest.builder().prefixRange(EncodingUtils.add(valueBytes)); }
public static RangeRequest.Builder createPrefixRangeUnsorted(String bucket) { long hashOfRowComponents = computeHashFirstComponents(bucket); byte[] hashOfRowComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfRowComponents); byte[] bucketBytes = EncodingUtils.encodeVarString(bucket); return RangeRequest.builder().prefixRange(EncodingUtils.add(hashOfRowComponentsBytes, bucketBytes)); }
public static RangeRequest.Builder createPrefixRangeUnsorted(String key) { long hashOfRowComponents = computeHashFirstComponents(key); byte[] hashOfRowComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfRowComponents); byte[] keyBytes = EncodingUtils.encodeVarString(key); return RangeRequest.builder().prefixRange(EncodingUtils.add(hashOfRowComponentsBytes, keyBytes)); }
public static RangeRequest.Builder createPrefixRangeUnsorted(String bucket) { long hashOfRowComponents = computeHashFirstComponents(bucket); byte[] hashOfRowComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfRowComponents); byte[] bucketBytes = EncodingUtils.encodeVarString(bucket); return RangeRequest.builder().prefixRange(EncodingUtils.add(hashOfRowComponentsBytes, bucketBytes)); }
public static RangeRequest.Builder createPrefixRange(String bucket, long key) { long hashOfRowComponents = computeHashFirstComponents(bucket); byte[] hashOfRowComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfRowComponents); byte[] bucketBytes = EncodingUtils.encodeVarString(bucket); byte[] keyBytes = PtBytes.toBytes(Long.MIN_VALUE ^ key); return RangeRequest.builder().prefixRange(EncodingUtils.add(hashOfRowComponentsBytes, bucketBytes, keyBytes)); }