@Test public void serializeEmptyList() { assertThrows(BunchedSerializationException.class, () -> serializer.serializeEntries(Collections.emptyList())); }
@Nonnull @Override public byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries) { if (entries.isEmpty()) { throw new BunchedSerializationException("cannot serialize empty entry list"); } List<byte[]> serializedEntries = new ArrayList<>(1 + entries.size()); serializedEntries.add(PREFIX); if (!entries.isEmpty()) { Iterator<Map.Entry<Tuple, Tuple>> iterator = entries.iterator(); Map.Entry<Tuple, Tuple> firstEntry = iterator.next(); serializedEntries.add(Tuple.from(firstEntry.getValue()).pack()); while (iterator.hasNext()) { Map.Entry<Tuple, Tuple> entry = iterator.next(); serializedEntries.add(serializeEntry(entry)); } } return ByteArrayUtil.join(null, serializedEntries); }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries) { if (entries.isEmpty()) { throw new BunchedSerializationException("cannot serialize empty entry list"); } List<byte[]> serializedEntries = new ArrayList<>(1 + entries.size()); serializedEntries.add(PREFIX); if (!entries.isEmpty()) { Iterator<Map.Entry<Tuple, Tuple>> iterator = entries.iterator(); Map.Entry<Tuple, Tuple> firstEntry = iterator.next(); serializedEntries.add(Tuple.from(firstEntry.getValue()).pack()); while (iterator.hasNext()) { Map.Entry<Tuple, Tuple> entry = iterator.next(); serializedEntries.add(serializeEntry(entry)); } } return ByteArrayUtil.join(null, serializedEntries); } }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries) { if (entries.isEmpty()) { throw new BunchedSerializationException("cannot serialize empty entry list"); } List<byte[]> serializedEntries = new ArrayList<>(1 + entries.size()); serializedEntries.add(PREFIX); if (!entries.isEmpty()) { Iterator<Map.Entry<Tuple, Tuple>> iterator = entries.iterator(); Map.Entry<Tuple, Tuple> firstEntry = iterator.next(); serializedEntries.add(Tuple.from(firstEntry.getValue()).pack()); while (iterator.hasNext()) { Map.Entry<Tuple, Tuple> entry = iterator.next(); serializedEntries.add(serializeEntry(entry)); } } return ByteArrayUtil.join(null, serializedEntries); } private  BunchedTupleSerializer(); }
BunchedTupleSerializer implements BunchedSerializer<Tuple, Tuple> { @Nonnull @Override public byte[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries) { if (entries.isEmpty()) { throw new BunchedSerializationException("cannot serialize empty entry list"); } List<byte[]> serializedEntries = new ArrayList<>(1 + entries.size()); serializedEntries.add(PREFIX); if (!entries.isEmpty()) { Iterator<Map.Entry<Tuple, Tuple>> iterator = entries.iterator(); Map.Entry<Tuple, Tuple> firstEntry = iterator.next(); serializedEntries.add(Tuple.from(firstEntry.getValue()).pack()); while (iterator.hasNext()) { Map.Entry<Tuple, Tuple> entry = iterator.next(); serializedEntries.add(serializeEntry(entry)); } } return ByteArrayUtil.join(null, serializedEntries); } 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[] serializeEntries(@Nonnull List<Map.Entry<Tuple, Tuple>> entries) { if (entries.isEmpty()) { throw new BunchedSerializationException("cannot serialize empty entry list"); } List<byte[]> serializedEntries = new ArrayList<>(1 + entries.size()); serializedEntries.add(PREFIX); if (!entries.isEmpty()) { Iterator<Map.Entry<Tuple, Tuple>> iterator = entries.iterator(); Map.Entry<Tuple, Tuple> firstEntry = iterator.next(); serializedEntries.add(Tuple.from(firstEntry.getValue()).pack()); while (iterator.hasNext()) { Map.Entry<Tuple, Tuple> entry = iterator.next(); serializedEntries.add(serializeEntry(entry)); } } return ByteArrayUtil.join(null, serializedEntries); } 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();  }