private static void writeValue(VespaDocumentSerializer6 serializer, DataType dataType, Object value) {
        FieldValue fieldValue;
        if (value instanceof FieldValue) {
            fieldValue = (FieldValue)value;
        } else {
            fieldValue = dataType.createFieldValue(value);
        }
        fieldValue.serialize(serializer);
    }
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