MapDefinitionUIDStore { void deletePair(final Txn<ByteBuffer> writeTxn, final UID mapUid) { LOGGER.trace("deletePair({})", mapUid); final ByteBuffer mapDefinitionBuffer = mapUidReverseDb.getAsBytes( writeTxn, mapUid.getBackingBuffer()) .orElseThrow(() -> new RuntimeException(LogUtil.message( "No entry exists for mapUid {}", ByteBufferUtils.byteBufferInfo(mapUid.getBackingBuffer())))); mapUidForwardDb.delete(writeTxn, mapDefinitionBuffer); mapUidReverseDb.delete(writeTxn, mapUid.getBackingBuffer()); } MapDefinitionUIDStore(final Env<ByteBuffer> lmdbEnv,
                          final MapUidForwardDb mapUidForwardDb,
                          final MapUidReverseDb mapUidReverseDb); long getEntryCount(); PooledByteBuffer getUidPooledByteBuffer(); PooledByteBuffer getMapDefinitionPooledByteBuffer();  }
@Test void testDeletePair() { String pipelineUuid = UUID.randomUUID().toString(); String pipelineVersion = UUID.randomUUID().toString(); RefStreamDefinition refStreamDefinition = new RefStreamDefinition(pipelineUuid, pipelineVersion, 1); MapDefinition mapDefinition1 = new MapDefinition(refStreamDefinition, "map1"); MapDefinition mapDefinition2 = new MapDefinition(refStreamDefinition, "map2"); MapDefinition mapDefinition3 = new MapDefinition(refStreamDefinition, "map3"); final Map<UID, MapDefinition> loadedEntries = loadEntries(mapDefinition1, mapDefinition2, mapDefinition3); assertThat(mapUidForwardDb.getEntryCount()).isEqualTo(3); assertThat(mapUidReverseDb.getEntryCount()).isEqualTo(3); LmdbUtils.doWithWriteTxn(lmdbEnv, writeTxn -> { mapDefinitionUIDStore.deletePair(writeTxn, loadedEntries.entrySet().iterator().next().getKey()); }); assertThat(mapUidForwardDb.getEntryCount()).isEqualTo(2); assertThat(mapUidReverseDb.getEntryCount()).isEqualTo(2); }