RangeSet { @Nonnull public CompletableFuture<Void> clear(@Nonnull TransactionContext tc) { return tc.runAsync(tr -> { tr.clear(subspace.range()); return AsyncUtil.DONE; }); } 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; }
@Test public void clear() { db.run(tr -> { tr.set(rsSubspace.pack(new byte[]{(byte)0xde, (byte)0xad}), new byte[]{(byte)0xc0, (byte)0xde}); return null; }); assertTrue(db.readAsync(tr -> tr.getRange(rsSubspace.range()).asList()).join().size() == 1, "Key does not appear to be added"); rs.clear(db).join(); assertTrue(db.readAsync(tr -> tr.getRange(rsSubspace.range()).asList()).join().isEmpty(), "Clear did not remove key"); }