static long getSerializedSize(Document doc) {
        DocumentSerializer serializer = new VespaDocumentSerializer6(new GrowableByteBuffer(8 * 1024, 2.0f));
        serializer.write(doc);
        return serializer.getBuf().position();
    }
Returns the serialized size of the given {@link Document}. Please note that this method performs actual
serialization of the document, but simply return the size of the final {@link GrowableByteBuffer}. If you need
the buffer itself, do NOT use this method.

@param doc The Document whose size to calculate.
@return The size in bytes.
document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java