Search in sources :

Example 1 with FindOptions

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);
    }
}
Also used : AggregateToCollectionOperation(com.mongodb.operation.AggregateToCollectionOperation) FindOptions(com.mongodb.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) MongoNamespace(com.mongodb.MongoNamespace) BsonValue(org.bson.BsonValue)

Example 2 with FindOptions

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);
    }
}
Also used : FindOptions(com.mongodb.client.model.FindOptions) MongoNamespace(com.mongodb.MongoNamespace) BsonJavaScript(org.bson.BsonJavaScript) MapReduceToCollectionOperation(com.mongodb.operation.MapReduceToCollectionOperation) BsonDocument(org.bson.BsonDocument)

Example 3 with FindOptions

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));
    }
}
Also used : FindOptions(com.mongodb.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) BsonJavaScript(org.bson.BsonJavaScript)

Example 4 with FindOptions

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);
    }
}
Also used : FindOptions(com.mongodb.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) BsonValue(org.bson.BsonValue)

Aggregations

FindOptions (com.mongodb.client.model.FindOptions)4 BsonDocument (org.bson.BsonDocument)4 MongoNamespace (com.mongodb.MongoNamespace)2 BsonJavaScript (org.bson.BsonJavaScript)2 BsonValue (org.bson.BsonValue)2 AggregateToCollectionOperation (com.mongodb.operation.AggregateToCollectionOperation)1 MapReduceToCollectionOperation (com.mongodb.operation.MapReduceToCollectionOperation)1