BLink implements AutoCloseable, Page.Owner { public V delete(K v) { Node<K, V> n; Deque<ResultCouple<K, V>> descent = new LinkedList<>(); Queue<CriticJob> maintenance = new LinkedList<>(); try { n = locate_leaf(v, WRITE_LOCK, descent); } catch (IOException ex) { throw new UncheckedIOException("failed to delete " + v, ex); } V delete; try { delete = n.remove_key(v); normalize(n, descent, 1, maintenance); } catch (IOException ex) { throw new UncheckedIOException("failed to delete " + v, ex); } finally { unlock(n, WRITE_LOCK); } if (delete != null) { size.decrement(); } handleMainenance(maintenance); return delete; } BLink(
            long maxSize, SizeEvaluator<K, V> evaluator,
            PageReplacementPolicy policy, BLinkIndexDataStorage<K, V> storage
    );  BLink(
            long maxSize, SizeEvaluator<K, V> evaluator,
            PageReplacementPolicy policy, BLinkIndexDataStorage<K, V> storage,
            BLinkMetadata<K> metadata
    ); @Override void close(); void truncate(); long size(); long getUsedMemory(); int nodes(); @Override void unload(long pageId); BLinkMetadata<K> checkpoint(); V search(K v); Stream<Entry<K, V>> scan(K from, K to); Stream<Entry<K, V>> scan(K from, K to, boolean toInclusive); boolean insert(K v, V e, V expected); V insert(K v, V e); V delete(K v); @Override String toString(); @SuppressWarnings("unchecked") String toStringFull();  }
@Test public void testDelete() throws Exception { final long inserts = 100000; BLinkIndexDataStorage<Sized<Long>, Long> storage = new DummyBLinkIndexDataStorage<>(); try (BLink<Sized<Long>, Long> blink = new BLink<>(2048L, new LongSizeEvaluator(), new RandomPageReplacementPolicy(10), storage)) { for (long l = 0; l < inserts; l++) { blink.insert(Sized.valueOf(l), l); } BLinkMetadata<Sized<Long>> metadata = blink.checkpoint(); assertNotEquals(1, metadata.nodes.size()); for (long l = 0; l < inserts; l++) { assertEquals(l, (long) blink.delete(Sized.valueOf(l))); } for (long l = 0; l < inserts; l++) { assertEquals(null, blink.search(Sized.valueOf(l))); } } }