DataRowKey implements RowKey { @Override public byte[] encode() { if( uuid != null ) { return VarEncoder.appendByteArraysWithPrefix(PREFIX, VarEncoder.encodeULong(tableId), Util.UUIDToBytes(uuid)); } return VarEncoder.appendByteArraysWithPrefix(PREFIX, VarEncoder.encodeULong(tableId)); } DataRowKey(final long tableId);  DataRowKey(final long tableId, final UUID uuid); @Override byte[] encode(); long getTableId(); UUID getUuid(); @Override byte getPrefix(); @Override String toString(); @Override int compareTo(RowKey o);  }
@Test public void testEncodeDataRow() { final UUID rowUUID = UUID.randomUUID(); final DataRowKey row = new DataRowKey(TABLE_ID, rowUUID); final byte[] expectedEncoding = VarEncoder.appendByteArraysWithPrefix(DATA_ROW_PREFIX, VarEncoder.encodeULong(TABLE_ID), Util.UUIDToBytes(rowUUID)); assertArrayEquals(expectedEncoding, row.encode()); }
@Test public void testEncodeDataRowNullUUID() { final DataRowKey row = new DataRowKey(TABLE_ID); final byte[] expectedEncoding = VarEncoder.appendByteArraysWithPrefix(DATA_ROW_PREFIX, VarEncoder.encodeULong(TABLE_ID)); assertArrayEquals(expectedEncoding, row.encode()); }