RangeStoreDb extends AbstractLmdbDb<RangeStoreKey, ValueStoreKey> { public boolean containsMapDefinition(final Txn<ByteBuffer> txn, final UID mapDefinitionUid) { LOGGER.trace(() -> "containsMapDefinition called for " + mapDefinitionUid); try (PooledByteBuffer pooledKeyBuffer = getPooledKeyBuffer()) { final Range<Long> startRange = new Range<>(0L, 0L); final RangeStoreKey startRangeStoreKey = new RangeStoreKey(mapDefinitionUid, startRange); final ByteBuffer startKeyBuf = pooledKeyBuffer.getByteBuffer(); keySerde.serialize(startKeyBuf, startRangeStoreKey); final KeyRange<ByteBuffer> keyRange = KeyRange.atLeast(startKeyBuf); try (CursorIterable<ByteBuffer> cursorIterable = getLmdbDbi().iterate(txn, keyRange)) { return cursorIterable.iterator().hasNext(); } } } @Inject  RangeStoreDb(@Assisted final Env<ByteBuffer> lmdbEnvironment,
                        final ByteBufferPool byteBufferPool,
                        final RangeStoreKeySerde keySerde,
                        final ValueStoreKeySerde valueSerde); Optional<ValueStoreKey> get(final Txn<ByteBuffer> txn, final UID mapDefinitionUid, final long key); Optional<ByteBuffer> getAsBytes(final Txn<ByteBuffer> txn, final UID mapDefinitionUid, final long key); boolean containsMapDefinition(final Txn<ByteBuffer> txn, final UID mapDefinitionUid); void deleteMapEntries(final Txn<ByteBuffer> writeTxn,
                                 final UID mapUid,
                                 final EntryConsumer entryConsumer); static final String DB_NAME; }
@Test void testContainsMapDefinition() { final List<UID> uids = Arrays.asList(uid1, uid2, uid3); final UID uid4 = UID.of(ByteBuffer.allocateDirect(UID.UID_ARRAY_LENGTH), 0, 0, 0, 4); for (int i = 0; i < uids.size(); i++) { LOGGER.debug("Iteration {}, loading for UID {}", i, uids.get(i)); rangeStoreDb.put(key(uids.get(i), 1, 11), val((i * 10) + 1), false); rangeStoreDb.put(key(uids.get(i), 11, 13), val((i * 10) + 2), false); rangeStoreDb.put(key(uids.get(i), 13, 21), val((i * 10) + 3), false); rangeStoreDb.put(key(uids.get(i), 101, 201), val((i * 10) + 4), false); rangeStoreDb.put(key(uids.get(i), 201, 301), val((i * 10) + 5), false); } rangeStoreDb.logRawDatabaseContents(); rangeStoreDb.logDatabaseContents(); LmdbUtils.doWithReadTxn(lmdbEnv, txn -> { boolean result; for (int i = 0; i < uids.size(); i++) { result = rangeStoreDb.containsMapDefinition(txn, uids.get(i)); assertThat(result).isTrue(); } result = rangeStoreDb.containsMapDefinition(txn, uid4); assertThat(result).isFalse(); }); }