Class NodeDocumentCodec
- java.lang.Object
-
- org.apache.jackrabbit.oak.index.indexer.document.flatfile.pipelined.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 Summary
Fields Modifier and Type Field Description static String
OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_FILTERED_PATH
static String
OAK_INDEXER_PIPELINED_NODE_DOCUMENT_FILTER_SUFFIXES_TO_SKIP
static String
SIZE_FIELD
-
Constructor Summary
Constructors Constructor Description NodeDocumentCodec(MongoDocumentStore store, Collection<NodeDocument> collection, org.bson.codecs.configuration.CodecRegistry defaultRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeDocument
decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
void
encode(org.bson.BsonWriter writer, NodeDocument value, org.bson.codecs.EncoderContext encoderContext)
Class<NodeDocument>
getEncoderClass()
-
-
-
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
-
SIZE_FIELD
public static final String SIZE_FIELD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NodeDocumentCodec
public NodeDocumentCodec(MongoDocumentStore store, Collection<NodeDocument> collection, org.bson.codecs.configuration.CodecRegistry defaultRegistry)
-
-
Method Detail
-
decode
public NodeDocument decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
- Specified by:
decode
in interfaceorg.bson.codecs.Decoder<NodeDocument>
-
encode
public void encode(org.bson.BsonWriter writer, NodeDocument value, org.bson.codecs.EncoderContext encoderContext)
- Specified by:
encode
in interfaceorg.bson.codecs.Encoder<NodeDocument>
-
getEncoderClass
public Class<NodeDocument> getEncoderClass()
- Specified by:
getEncoderClass
in interfaceorg.bson.codecs.Encoder<NodeDocument>
-
-