public static @Nullable <Data> ByteArraySequence serializeToByteSeq(Data data,
                                                                      @NotNull DataExternalizer<Data> externalizer,
                                                                      int bufferInitialSize,
                                                                      @NotNull ThreadLocalCachedByteArray cachedBufferToUse)
    throws IOException {
    BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(s -> {
      return cachedBufferToUse.getBuffer(s);
    }, bufferInitialSize);
    DataOutputStream stream = new DataOutputStream(out);
    externalizer.save(stream, data);
    return out.size() == 0 ? null : out.toByteArraySequence();
  }
public static @Nullable <Data> ByteArraySequence serializeToByteSeq(Data data,
                                                                      @NotNull DataExternalizer<Data> externalizer,
                                                                      int bufferInitialSize,
                                                                      @NotNull ThreadLocalCachedByteArray cachedBufferToUse)