this.estimatedLength = estimatedLength;
}
@Override
final protected void writeObjectOverride(Object obj) throws IOException {
AccessibleByteArrayOutputStream baos = new AccessibleByteArrayOutputStream(estimatedLength);
CompactObjectOutputStream oout = new CompactObjectOutputStream(baos);
oout.writeObject(obj);
ExternalizeUtil.writeCollection(oout, oout.getReferences());
oout.flush();
oout.close();
out.writeInt(baos.getCount()); //includes the lob references
out.write(baos.getBuffer(), 0, baos.getCount());
byte[] chunk = new byte[(1 << 16) - 1];
for (InputStream is : oout.getStreams()) {
while (true) {
int bytes = is.read(chunk);
out.writeShort(Math.max(0, bytes));