Search in sources :

Example 1 with BsonWriterSettings

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

the class BaseWriteCommandMessage method encodeMessageBodyWithMetadata.

@Override
protected EncodingMetadata encodeMessageBodyWithMetadata(final BsonOutput outputStream, final int messageStartPosition) {
    BaseWriteCommandMessage nextMessage = null;
    writeCommandHeader(outputStream);
    int commandStartPosition = outputStream.getPosition();
    int firstDocumentStartPosition = outputStream.getPosition();
    BsonBinaryWriter writer = new BsonBinaryWriter(new BsonWriterSettings(), new BsonBinaryWriterSettings(getSettings().getMaxDocumentSize() + HEADROOM), outputStream, getFieldNameValidator());
    try {
        writer.writeStartDocument();
        writeCommandPrologue(writer);
        nextMessage = writeTheWrites(outputStream, commandStartPosition, writer);
        writer.writeEndDocument();
    } finally {
        writer.close();
    }
    return new EncodingMetadata(nextMessage, firstDocumentStartPosition);
}
Also used : BsonBinaryWriter(org.bson.BsonBinaryWriter) BsonBinaryWriterSettings(org.bson.BsonBinaryWriterSettings) BsonWriterSettings(org.bson.BsonWriterSettings)

Aggregations

BsonBinaryWriter (org.bson.BsonBinaryWriter)1 BsonBinaryWriterSettings (org.bson.BsonBinaryWriterSettings)1 BsonWriterSettings (org.bson.BsonWriterSettings)1