ValueStoreKeySerde implements Serde<ValueStoreKey> { public static short extractId(final ByteBuffer byteBuffer) { return byteBuffer.getShort(ID_OFFSET); }  @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 testExtractId() { short id = 123; ValueStoreKey originalValueStoreKey = new ValueStoreKey(1234567L, id); ValueStoreKeySerde serde = new ValueStoreKeySerde(); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(serde.getBufferCapacity()); serde.serialize(byteBuffer, originalValueStoreKey); short extractedId = ValueStoreKeySerde.extractId(byteBuffer); assertThat(extractedId).isEqualTo(id); }