Class NodeDocumentCodec

  • All Implemented Interfaces:
    org.bson.codecs.Codec<NodeDocument>, org.bson.codecs.Decoder<NodeDocument>, org.bson.codecs.Encoder<NodeDocument>

    public class NodeDocumentCodec
    extends Object
    implements org.bson.codecs.Codec<NodeDocument>
    Custom codec for MongoDB to transform a stream of BSON tokens into a NodeDocument. This custom codec provides two benefits compared to using a standard Mongo codec.
    • The standard codecs produce objects from the Mongo client API (BasicDBObject or BsonDocument or Document) which have then to be converted into NodeDocuments (OAK API). This custom codec creates directly a NodeDocument, thereby skipping the intermediate object. This should be more efficient and reduce the pressure on the GC.
    • Allows estimating the size of the document while reading it, which will have a negligible overhead (as compared with doing an additional traverse of the object structure to compute the size).

    This class must be thread-safe, Mongo uses a single coded implementation across multiple threads.

    • Field Detail

      • OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_FILTERED_PATH

        public static final String OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_FILTERED_PATH
        See Also:
        Constant Field Values
      • OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_SUFFIXES_TO_SKIP

        public static final String OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_SUFFIXES_TO_SKIP
        See Also:
        Constant Field Values
    • Method Detail

      • decode

        public NodeDocument decode​(org.bson.BsonReader reader,
                                   org.bson.codecs.DecoderContext decoderContext)
        Specified by:
        decode in interface org.bson.codecs.Decoder<NodeDocument>
      • encode

        public void encode​(org.bson.BsonWriter writer,
                           NodeDocument value,
                           org.bson.codecs.EncoderContext encoderContext)
        Specified by:
        encode in interface org.bson.codecs.Encoder<NodeDocument>
      • getEncoderClass

        public Class<NodeDocument> getEncoderClass()
        Specified by:
        getEncoderClass in interface org.bson.codecs.Encoder<NodeDocument>