Search in sources :

Example 1 with RawBsonDocument

use of org.bson.RawBsonDocument in project mongo-java-driver by mongodb.

the class RawBsonDocumentCodec method decode.

@Override
public RawBsonDocument decode(final BsonReader reader, final DecoderContext decoderContext) {
    BasicOutputBuffer buffer = new BasicOutputBuffer(0);
    BsonBinaryWriter writer = new BsonBinaryWriter(buffer);
    try {
        writer.pipe(reader);
        return new RawBsonDocument(buffer.getInternalBuffer(), 0, buffer.getPosition());
    } finally {
        writer.close();
        buffer.close();
    }
}
Also used : RawBsonDocument(org.bson.RawBsonDocument) BsonBinaryWriter(org.bson.BsonBinaryWriter) BasicOutputBuffer(org.bson.io.BasicOutputBuffer)

Aggregations

BsonBinaryWriter (org.bson.BsonBinaryWriter)1 RawBsonDocument (org.bson.RawBsonDocument)1 BasicOutputBuffer (org.bson.io.BasicOutputBuffer)1