@Test public void containsPastFF2() { assertThrows(IllegalArgumentException.class, () -> rs.contains(db, new byte[]{(byte)0xff,(byte)0x00}).join()); }
@Nonnull public CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key) { checkKey(key); return tc.runAsync(tr -> { byte[] frobnicated = subspace.pack(key); tr.addReadConflictKey(frobnicated); AsyncIterator<KeyValue> iterator = tr.snapshot().getRange(subspace.range().begin, keyAfter(frobnicated), 1, true).iterator(); return iterator.onHasNext().thenApply(hasNext -> { if (!hasNext) { return false; } else { byte[] endRange = iterator.next().getValue(); return ByteArrayUtil.compareUnsigned(key, endRange) < 0; } }); }); }
RangeSet { @Nonnull public CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key) { checkKey(key); return tc.runAsync(tr -> { byte[] frobnicated = subspace.pack(key); tr.addReadConflictKey(frobnicated); AsyncIterator<KeyValue> iterator = tr.snapshot().getRange(subspace.range().begin, keyAfter(frobnicated), 1, true).iterator(); return iterator.onHasNext().thenApply(hasNext -> { if (!hasNext) { return false; } else { byte[] endRange = iterator.next().getValue(); return ByteArrayUtil.compareUnsigned(key, endRange) < 0; } }); }); } }
RangeSet { @Nonnull public CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key) { checkKey(key); return tc.runAsync(tr -> { byte[] frobnicated = subspace.pack(key); tr.addReadConflictKey(frobnicated); AsyncIterator<KeyValue> iterator = tr.snapshot().getRange(subspace.range().begin, keyAfter(frobnicated), 1, true).iterator(); return iterator.onHasNext().thenApply(hasNext -> { if (!hasNext) { return false; } else { byte[] endRange = iterator.next().getValue(); return ByteArrayUtil.compareUnsigned(key, endRange) < 0; } }); }); } RangeSet(@Nonnull Subspace subspace); }
RangeSet { @Nonnull public CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key) { checkKey(key); return tc.runAsync(tr -> { byte[] frobnicated = subspace.pack(key); tr.addReadConflictKey(frobnicated); AsyncIterator<KeyValue> iterator = tr.snapshot().getRange(subspace.range().begin, keyAfter(frobnicated), 1, true).iterator(); return iterator.onHasNext().thenApply(hasNext -> { if (!hasNext) { return false; } else { byte[] endRange = iterator.next().getValue(); return ByteArrayUtil.compareUnsigned(key, endRange) < 0; } }); }); } RangeSet(@Nonnull Subspace subspace); @Nonnull CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nonnull Range r); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nonnull Range r, boolean requireEmpty); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end, boolean requireEmpty); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nonnull Range superRange); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nonnull Range superRange); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end, int limit); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nullable byte[] begin, @Nullable byte[] end, int limit); @Nonnull CompletableFuture<Void> clear(@Nonnull TransactionContext tc); @Nonnull CompletableFuture<String> rep(@Nonnull ReadTransactionContext tc); }
RangeSet { @Nonnull public CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key) { checkKey(key); return tc.runAsync(tr -> { byte[] frobnicated = subspace.pack(key); tr.addReadConflictKey(frobnicated); AsyncIterator<KeyValue> iterator = tr.snapshot().getRange(subspace.range().begin, keyAfter(frobnicated), 1, true).iterator(); return iterator.onHasNext().thenApply(hasNext -> { if (!hasNext) { return false; } else { byte[] endRange = iterator.next().getValue(); return ByteArrayUtil.compareUnsigned(key, endRange) < 0; } }); }); } RangeSet(@Nonnull Subspace subspace); @Nonnull CompletableFuture<Boolean> contains(@Nonnull TransactionContext tc, @Nonnull byte[] key); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nonnull Range r); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nonnull Range r, boolean requireEmpty); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull CompletableFuture<Boolean> insertRange(@Nonnull TransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end, boolean requireEmpty); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nonnull Range superRange); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nonnull Range superRange); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nullable byte[] begin, @Nullable byte[] end); @Nonnull CompletableFuture<List<Range>> missingRanges(@Nonnull ReadTransactionContext tc, @Nullable byte[] begin, @Nullable byte[] end, int limit); @Nonnull AsyncIterable<Range> missingRanges(@Nonnull ReadTransaction tr, @Nullable byte[] begin, @Nullable byte[] end, int limit); @Nonnull CompletableFuture<Void> clear(@Nonnull TransactionContext tc); @Nonnull CompletableFuture<String> rep(@Nonnull ReadTransactionContext tc); static final int UNLIMITED; }