use of com.mongodb.bulk.InsertRequest in project mongo-java-driver by mongodb.
the class MongoCollectionImpl method insertOne.
@Override
public void insertOne(final TDocument document, final InsertOneOptions options, final SingleResultCallback<Void> callback) {
TDocument insertDocument = document;
if (getCodec() instanceof CollectibleCodec) {
insertDocument = ((CollectibleCodec<TDocument>) getCodec()).generateIdIfAbsentFromDocument(insertDocument);
}
executeSingleWriteRequest(new InsertRequest(documentToBsonDocument(insertDocument)), options.getBypassDocumentValidation(), new SingleResultCallback<BulkWriteResult>() {
@Override
public void onResult(final BulkWriteResult result, final Throwable t) {
callback.onResult(null, t);
}
});
}
use of com.mongodb.bulk.InsertRequest in project mongo-java-driver by mongodb.
the class MongoCollectionImpl method insertOne.
@Override
public void insertOne(final TDocument document, final InsertOneOptions options) {
notNull("document", document);
TDocument insertDocument = document;
if (getCodec() instanceof CollectibleCodec) {
insertDocument = ((CollectibleCodec<TDocument>) getCodec()).generateIdIfAbsentFromDocument(document);
}
executeSingleWriteRequest(new InsertRequest(documentToBsonDocument(insertDocument)), options.getBypassDocumentValidation());
}
use of com.mongodb.bulk.InsertRequest in project mongo-java-driver by mongodb.
the class MaxDocumentSizeTest method setUp.
@Before
public void setUp() {
message = new InsertMessage("test.test", true, ACKNOWLEDGED, asList(new InsertRequest(new BsonDocument("bytes", new BsonBinary(new byte[2048])))), MessageSettings.builder().maxDocumentSize(1024).build());
buffer = new ByteBufferBsonOutput(new SimpleBufferProvider());
}
use of com.mongodb.bulk.InsertRequest in project mongo-java-driver by mongodb.
the class MaxMessageSizeTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() {
BsonBinary binary = new BsonBinary(new byte[2048]);
message = new InsertMessage("test.test", true, ACKNOWLEDGED, Arrays.asList(new InsertRequest(new BsonDocument("bytes", binary)), new InsertRequest(new BsonDocument("bytes", binary)), new InsertRequest(new BsonDocument("bytes", binary))), MessageSettings.builder().maxMessageSize(4500).build());
buffer = new ByteBufferBsonOutput(new SimpleBufferProvider());
}
Aggregations