@Override
    public void read(FieldBase field, Document doc) {
        // Verify that we have correct version
        version = getShort(null);
        if (version < 8 || version > Document.SERIALIZED_VERSION) {
            throw new DeserializationException("Unknown version " + version + ", expected " +
                                               Document.SERIALIZED_VERSION + ".");
        }

        int dataLength = getInt(null);
        int dataPos = position();

        DocumentId documentId = readDocumentId();
        byte content = getByte(null);
        doc.setDataType(readDocumentType());
        doc.setId(documentId);

        if ((content & 0x2) != 0) {
            readStruct(doc, doc.getDataType().contentStruct());

        }
        if ((content & 0x4) != 0) {
            readStruct(doc, doc.getDataType().contentStruct());
        }

        if (dataLength != (position() - dataPos)) {
            throw new DeserializationException("Length mismatch");
        }
    }
Class used for de-serializing documents on the Vespa 6.x document format.

@author baldersheim
document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java