@Test public void serializeKey() { List<Tuple> sortedTuples = TEST_TUPLES.stream().sorted().collect(Collectors.toList()); List<Tuple> sortedKeys = TEST_TUPLES.stream() .map(serializer::serializeKey) .sorted(ByteArrayUtil::compareUnsigned) .map(serializer::deserializeKey) .collect(Collectors.toList()); assertEquals(sortedTuples, sortedKeys); Subspace subspace = new Subspace(Tuple.from("fake", "subspace")); List<Tuple> prefixedTuples = TEST_TUPLES.stream() .map(serializer::serializeKey) .map(b -> ByteArrayUtil.join(subspace.getKey(), b)) .map(data -> serializer.deserializeKey(data, subspace.getKey().length)) .collect(Collectors.toList()); assertEquals(TEST_TUPLES, prefixedTuples); }
@Nonnull @Override public byte[] serializeKey(@Nonnull Tuple key) { try { return key.pack(); } catch (IllegalArgumentException e) { throw new BunchedSerializationException("unable so serialize key", e) .setValue(key); } }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeKey(@Nonnull Tuple key) { try { return key.pack(); } catch (IllegalArgumentException e) { throw new BunchedSerializationException("unable so serialize key", e) .setValue(key); } } }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeKey(@Nonnull Tuple key) { try { return key.pack(); } catch (IllegalArgumentException e) { throw new BunchedSerializationException("unable so serialize key", e) .setValue(key); } } private  BunchedTupleSerializer(); }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeKey(@Nonnull Tuple key) { try { return key.pack(); } catch (IllegalArgumentException e) { throw new BunchedSerializationException("unable so serialize key", e) .setValue(key); } } private  BunchedTupleSerializer(); static BunchedTupleSerializer instance(); @Nonnull @Override byte[] serializeKey(@Nonnull Tuple key); @Nonnull @Override byte[] serializeEntry(@Nonnull Tuple key, @Nonnull Tuple value); @Nonnull @Override byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries); @Nonnull @Override Tuple deserializeKey(@Nonnull byte[] data, int offset, int length); @Nonnull @Override List<Map.Entry<Tuple, Tuple>> deserializeEntries(@Nonnull Tuple key, @Nonnull byte[] data); @Override boolean canAppend(); }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeKey(@Nonnull Tuple key) { try { return key.pack(); } catch (IllegalArgumentException e) { throw new BunchedSerializationException("unable so serialize key", e) .setValue(key); } } private  BunchedTupleSerializer(); static BunchedTupleSerializer instance(); @Nonnull @Override byte[] serializeKey(@Nonnull Tuple key); @Nonnull @Override byte[] serializeEntry(@Nonnull Tuple key, @Nonnull Tuple value); @Nonnull @Override byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries); @Nonnull @Override Tuple deserializeKey(@Nonnull byte[] data, int offset, int length); @Nonnull @Override List<Map.Entry<Tuple, Tuple>> deserializeEntries(@Nonnull Tuple key, @Nonnull byte[] data); @Override boolean canAppend();  }