ValueStoreKeySerde implements Serde<ValueStoreKey> { public static void incrementId(final ByteBuffer byteBuffer) { short currId = byteBuffer.getShort(ID_OFFSET); byteBuffer.putShort(ID_OFFSET, (short) (currId + 1)); }  @Override int getBufferCapacity(); @Override ValueStoreKey deserialize(final ByteBuffer byteBuffer); @Override void serialize(final ByteBuffer byteBuffer, final ValueStoreKey valueStoreKey); static void incrementId(final ByteBuffer byteBuffer); static void updateId(final ByteBuffer byteBuffer, final short newId); static long extractValueHashCode(final ByteBuffer byteBuffer); static short extractId(final ByteBuffer byteBuffer); static int compareValueHashCode(final ByteBuffer thisBuffer, final ByteBuffer thatBuffer); static final int VALUE_HASH_CODE_OFFSET; static final int VALUE_HASH_CODE_BYTES; static final int ID_BYTES; static final int ID_OFFSET; }
@Test void testIncrementId() { ValueStoreKey originalValueStoreKey = new ValueStoreKey(1234567L, (short) 123); ByteBuffer byteBuffer = serialize(originalValueStoreKey); ValueStoreKeySerde.incrementId(byteBuffer); ValueStoreKey newValueStoreKey = deserialize(byteBuffer); assertThat(newValueStoreKey.getValueHashCode()).isEqualTo(originalValueStoreKey.getValueHashCode()); assertThat(newValueStoreKey.getUniqueId()).isEqualTo((short) (originalValueStoreKey.getUniqueId() + 1)); }