ValueStoreDb extends AbstractLmdbDb<ValueStoreKey, RefDataValue> { public boolean areValuesEqual(final Txn<ByteBuffer> txn, final ByteBuffer valueStoreKeyBuffer, final RefDataValue newRefDataValue) { long currentValueHashCode = keySerde.extractValueHashCode(valueStoreKeyBuffer); long newValueHashCode = newRefDataValue.getValueHashCode(valueStoreHashAlgorithm); boolean areValuesEqual; if (currentValueHashCode != newValueHashCode) { areValuesEqual = false; } else { try (final PooledByteBuffer newRefDataValuePooledBuf = getPooledValueBuffer()) { Optional<ByteBuffer> optCurrentValueBuf = getAsBytes(txn, valueStoreKeyBuffer); if (optCurrentValueBuf.isPresent()) { ByteBuffer newValueBuffer = valueSerde.serialize(newRefDataValuePooledBuf::getByteBuffer, newRefDataValue); areValuesEqual = optCurrentValueBuf.get().equals(newValueBuffer); } else { areValuesEqual = false; } } } return areValuesEqual; } @Inject  ValueStoreDb(@Assisted final Env<ByteBuffer> lmdbEnvironment,
                        final ByteBufferPool byteBufferPool,
                        final ValueStoreKeySerde keySerde,
                        final GenericRefDataValueSerde valueSerde,
                        final ValueStoreHashAlgorithm valueStoreHashAlgorithm); ValueStoreHashAlgorithm getValueStoreHashAlgorithm(); boolean areValuesEqual(final Txn<ByteBuffer> txn,
                                  final ByteBuffer valueStoreKeyBuffer,
                                  final RefDataValue newRefDataValue); ByteBuffer getOrCreateKey(final Txn<ByteBuffer> writeTxn,
                                     final RefDataValue refDataValue,
                                     final PooledByteBuffer valueStoreKeyPooledBuffer,
                                     final boolean isOverwrite,
                                     final EntryConsumer onExistingEntryAction,
                                     final EntryConsumer onNewEntryAction); Optional<RefDataValue> get(final Txn<ByteBuffer> txn,
                                      final ByteBuffer keyBuffer,
                                      final int typeId); static final String DB_NAME; }
@Test void testAreValueEqual_notFound() { StringValue value2 = StringValue.of("value2"); ValueStoreKey unknownValueStoreKey = new ValueStoreKey(123, (short) 0); ByteBuffer unknownValueStoreKeyBuffer = valueStoreDb.getPooledKeyBuffer().getByteBuffer(); valueStoreDb.serializeKey(unknownValueStoreKeyBuffer, unknownValueStoreKey); LmdbUtils.doWithWriteTxn(lmdbEnv, writeTxn -> { boolean areValuesEqual = valueStoreDb.areValuesEqual(writeTxn, unknownValueStoreKeyBuffer, value2); assertThat(areValuesEqual).isFalse(); }); }