Search in sources :

Example 1 with MapReduceBatchCursor

use of com.mongodb.internal.operation.MapReduceBatchCursor in project mongo-java-driver by mongodb.

the class MapReduceIterableImpl method asReadOperation.

@Override
public ReadOperation<BatchCursor<TResult>> asReadOperation() {
    if (inline) {
        ReadOperation<MapReduceBatchCursor<TResult>> operation = operations.mapReduce(mapFunction, reduceFunction, finalizeFunction, resultClass, filter, limit, maxTimeMS, jsMode, scope, sort, verbose, collation);
        return new WrappedMapReduceReadOperation<TResult>(operation);
    } else {
        getExecutor().execute(createMapReduceToCollectionOperation(), getReadConcern(), getClientSession());
        String dbName = databaseName != null ? databaseName : namespace.getDatabaseName();
        FindOptions findOptions = new FindOptions().collation(collation);
        Integer batchSize = getBatchSize();
        if (batchSize != null) {
            findOptions.batchSize(batchSize);
        }
        return operations.find(new MongoNamespace(dbName, collectionName), new BsonDocument(), resultClass, findOptions);
    }
}
Also used : FindOptions(com.mongodb.internal.client.model.FindOptions) MapReduceBatchCursor(com.mongodb.internal.operation.MapReduceBatchCursor) BsonDocument(org.bson.BsonDocument) MongoNamespace(com.mongodb.MongoNamespace)

Aggregations

MongoNamespace (com.mongodb.MongoNamespace)1 FindOptions (com.mongodb.internal.client.model.FindOptions)1 MapReduceBatchCursor (com.mongodb.internal.operation.MapReduceBatchCursor)1 BsonDocument (org.bson.BsonDocument)1