use of com.mongodb.client.model.FindOptions in project mongo-java-driver by mongodb.
the class AggregateIterableImpl method execute.
@SuppressWarnings("deprecation")
private MongoIterable<TResult> execute() {
List<BsonDocument> aggregateList = createBsonDocumentList();
BsonValue outCollection = getAggregateOutCollection(aggregateList);
if (outCollection != null) {
AggregateToCollectionOperation operation = new AggregateToCollectionOperation(namespace, aggregateList, writeConcern).maxTime(maxTimeMS, MILLISECONDS).allowDiskUse(allowDiskUse).bypassDocumentValidation(bypassDocumentValidation).collation(collation);
MongoIterable<TResult> delegated = new FindIterableImpl<TDocument, TResult>(new MongoNamespace(namespace.getDatabaseName(), outCollection.asString().getValue()), documentClass, resultClass, codecRegistry, primary(), readConcern, executor, new BsonDocument(), new FindOptions().collation(collation));
if (batchSize != null) {
delegated.batchSize(batchSize);
}
return new AwaitingWriteOperationIterable<TResult, Void>(operation, executor, delegated);
} else {
return new OperationIterable<TResult>(new AggregateOperation<TResult>(namespace, aggregateList, codecRegistry.get(resultClass)).maxTime(maxTimeMS, MILLISECONDS).allowDiskUse(allowDiskUse).batchSize(batchSize).useCursor(useCursor).readConcern(readConcern).collation(collation), readPreference, executor);
}
}
use of com.mongodb.client.model.FindOptions in project mongo-java-driver by mongodb.
the class MapReduceIterableImpl method execute.
MongoIterable<TResult> execute() {
if (inline) {
MapReduceWithInlineResultsOperation<TResult> operation = new MapReduceWithInlineResultsOperation<TResult>(namespace, new BsonJavaScript(mapFunction), new BsonJavaScript(reduceFunction), codecRegistry.get(resultClass)).filter(toBsonDocument(filter)).limit(limit).maxTime(maxTimeMS, MILLISECONDS).jsMode(jsMode).scope(toBsonDocument(scope)).sort(toBsonDocument(sort)).verbose(verbose).readConcern(readConcern).collation(collation);
if (finalizeFunction != null) {
operation.finalizeFunction(new BsonJavaScript(finalizeFunction));
}
return new OperationIterable<TResult>(operation, readPreference, executor);
} else {
MapReduceToCollectionOperation operation = createMapReduceToCollectionOperation();
String dbName = databaseName != null ? databaseName : namespace.getDatabaseName();
MongoIterable<TResult> delegated = new FindIterableImpl<TDocument, TResult>(new MongoNamespace(dbName, collectionName), documentClass, resultClass, codecRegistry, primary(), readConcern, executor, new BsonDocument(), new FindOptions().collation(collation)).batchSize(batchSize);
return new AwaitingWriteOperationIterable<TResult, MapReduceStatistics>(operation, executor, delegated);
}
}
use of com.mongodb.client.model.FindOptions in project mongo-java-driver by mongodb.
the class MapReduceIterableImpl method execute.
MongoIterable<TResult> execute() {
if (inline) {
MapReduceWithInlineResultsOperation<TResult> operation = new MapReduceWithInlineResultsOperation<TResult>(namespace, new BsonJavaScript(mapFunction), new BsonJavaScript(reduceFunction), codecRegistry.get(resultClass)).filter(toBsonDocument(filter)).limit(limit).maxTime(maxTimeMS, MILLISECONDS).jsMode(jsMode).scope(toBsonDocument(scope)).sort(toBsonDocument(sort)).verbose(verbose).readConcern(readConcern).collation(collation);
if (finalizeFunction != null) {
operation.finalizeFunction(new BsonJavaScript(finalizeFunction));
}
return new OperationIterable<TResult>(operation, readPreference, executor);
} else {
executor.execute(createMapReduceToCollectionOperation());
String dbName = databaseName != null ? databaseName : namespace.getDatabaseName();
return new FindIterableImpl<TDocument, TResult>(new MongoNamespace(dbName, collectionName), documentClass, resultClass, codecRegistry, primary(), readConcern, executor, new BsonDocument(), new FindOptions().collation(collation).batchSize(batchSize));
}
}
use of com.mongodb.client.model.FindOptions in project mongo-java-driver by mongodb.
the class AggregateIterableImpl method execute.
@SuppressWarnings("deprecation")
private MongoIterable<TResult> execute() {
List<BsonDocument> aggregateList = createBsonDocumentList(pipeline);
BsonValue outCollection = getOutCollection(aggregateList);
if (outCollection != null) {
executor.execute(createAggregateToCollectionOperation(aggregateList));
FindIterable<TResult> findOperation = new FindIterableImpl<TDocument, TResult>(new MongoNamespace(namespace.getDatabaseName(), outCollection.asString().getValue()), documentClass, resultClass, codecRegistry, readPreference, readConcern, executor, new BsonDocument(), new FindOptions().collation(collation));
if (batchSize != null) {
findOperation.batchSize(batchSize);
}
return findOperation;
} else {
return new OperationIterable<TResult>(new AggregateOperation<TResult>(namespace, aggregateList, codecRegistry.get(resultClass)).maxTime(maxTimeMS, MILLISECONDS).allowDiskUse(allowDiskUse).batchSize(batchSize).useCursor(useCursor).readConcern(readConcern).collation(collation), readPreference, executor);
}
}
Aggregations