use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class WriteCommandProtocol method sendMessageAsync.
private void sendMessageAsync(final InternalConnection connection, final ByteBufferBsonOutput buffer, final BaseWriteCommandMessage message, final long startTimeNanos, final SingleResultCallback<BulkWriteResult> clientCallback, final SingleResultCallback<BsonDocument> callback) {
SingleResultCallback<ResponseBuffers> receiveCallback = new CommandResultCallback<BsonDocument>(callback, new BsonDocumentCodec(), message.getId(), connection.getDescription().getServerAddress());
connection.sendMessageAsync(buffer.getByteBuffers(), message.getId(), new SendMessageCallback<BulkWriteResult>(connection, buffer, message, message.getCommandName(), startTimeNanos, commandListener, clientCallback, receiveCallback));
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class FindOperation method createExplainableQueryOperation.
private FindOperation<BsonDocument> createExplainableQueryOperation() {
FindOperation<BsonDocument> explainFindOperation = new FindOperation<BsonDocument>(namespace, new BsonDocumentCodec());
BsonDocument explainModifiers = new BsonDocument();
if (modifiers != null) {
explainModifiers.putAll(modifiers);
}
explainModifiers.append("$explain", BsonBoolean.TRUE);
return explainFindOperation.filter(filter).projection(projection).sort(sort).skip(skip).limit(Math.abs(limit) * -1).modifiers(explainModifiers);
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class ByteBufBsonDocument method toBsonDocument.
private BsonDocument toBsonDocument() {
ByteBuf duplicateByteBuf = byteBuf.duplicate();
BsonBinaryReader bsonReader = new BsonBinaryReader(new ByteBufferBsonInput(duplicateByteBuf));
try {
return new BsonDocumentCodec().decode(bsonReader, DecoderContext.builder().build());
} finally {
duplicateByteBuf.release();
bsonReader.close();
}
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class ClientMetadataHelper method clientMetadataDocumentTooLarge.
static boolean clientMetadataDocumentTooLarge(final BsonDocument document) {
BasicOutputBuffer buffer = new BasicOutputBuffer(MAXIMUM_CLIENT_METADATA_ENCODED_SIZE);
new BsonDocumentCodec().encode(new BsonBinaryWriter(buffer), document, EncoderContext.builder().build());
return buffer.getPosition() > MAXIMUM_CLIENT_METADATA_ENCODED_SIZE;
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class CommandMonitoringTest method getWritableCloneOfCommand.
private BsonDocument getWritableCloneOfCommand(final BsonDocument original) {
BsonDocument clone = new BsonDocument();
BsonDocumentWriter writer = new BsonDocumentWriter(clone);
new BsonDocumentCodec(CODEC_REGISTRY_HACK).encode(writer, original, EncoderContext.builder().build());
return clone;
}
Aggregations