MapDefinitionUIDStore { Optional<UID> getNextMapDefinition(final Txn<ByteBuffer> writeTxn, final RefStreamDefinition refStreamDefinition, final Supplier<ByteBuffer> uidBufferSupplier) { return mapUidForwardDb.getNextMapDefinition(writeTxn, refStreamDefinition, uidBufferSupplier); } MapDefinitionUIDStore(final Env<ByteBuffer> lmdbEnv,
                          final MapUidForwardDb mapUidForwardDb,
                          final MapUidReverseDb mapUidReverseDb); long getEntryCount(); PooledByteBuffer getUidPooledByteBuffer(); PooledByteBuffer getMapDefinitionPooledByteBuffer();  }
@Test void testGetNextMapDefinition() { String pipelineUuid = UUID.randomUUID().toString(); String pipelineVersion = UUID.randomUUID().toString(); RefStreamDefinition refStreamDefinition1 = new RefStreamDefinition(pipelineUuid, pipelineVersion, 1); RefStreamDefinition refStreamDefinition2 = new RefStreamDefinition(pipelineUuid, pipelineVersion, 2); RefStreamDefinition refStreamDefinition3 = new RefStreamDefinition(pipelineUuid, pipelineVersion, 3); MapDefinition mapDefinition11 = new MapDefinition(refStreamDefinition1, "map1"); MapDefinition mapDefinition21 = new MapDefinition(refStreamDefinition2, "map1"); MapDefinition mapDefinition22 = new MapDefinition(refStreamDefinition2, "map2"); MapDefinition mapDefinition31 = new MapDefinition(refStreamDefinition3, "map1"); loadEntries(Arrays.asList( mapDefinition11, mapDefinition21, mapDefinition22, mapDefinition31)); assertThat(mapUidReverseDb.getEntryCount()).isEqualTo(4); assertThat(mapUidForwardDb.getEntryCount()).isEqualTo(4); LOGGER.info("--------------------------------------------------------------------------------"); LmdbUtils.doWithWriteTxn(lmdbEnv, writeTxn -> { doGetNextMapDefinitionTest( writeTxn, refStreamDefinition1, Optional.of(mapDefinition11), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition1, Optional.of(mapDefinition11), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition2, Optional.of(mapDefinition21), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition2, Optional.of(mapDefinition21), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition3, Optional.of(mapDefinition31), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition3, Optional.of(mapDefinition31), false); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition1, Optional.of(mapDefinition11), true); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition1, Optional.empty(), true); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition2, Optional.of(mapDefinition21), true); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition2, Optional.of(mapDefinition22), true); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition3, Optional.of(mapDefinition31), true); doGetNextMapDefinitionTest( writeTxn, refStreamDefinition3, Optional.empty(), true); }); }