Search in sources :

Example 1 with FindOptions

use of com.mongodb.internal.client.model.FindOptions in project mongo-java-driver by mongodb.

the class AggregatePublisherImpl method asAsyncReadOperation.

@Override
AsyncReadOperation<AsyncBatchCursor<T>> asAsyncReadOperation(final int initialBatchSize) {
    MongoNamespace outNamespace = getOutNamespace();
    if (outNamespace != null) {
        AsyncReadOperation<Void> aggregateToCollectionOperation = getAggregateToCollectionOperation();
        FindOptions findOptions = new FindOptions().collation(collation).batchSize(initialBatchSize);
        AsyncReadOperation<AsyncBatchCursor<T>> findOperation = getOperations().find(outNamespace, new BsonDocument(), getDocumentClass(), findOptions);
        return new VoidReadOperationThenCursorReadOperation<>(aggregateToCollectionOperation, findOperation);
    } else {
        return asAggregateOperation(initialBatchSize);
    }
}
Also used : FindOptions(com.mongodb.internal.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) AsyncBatchCursor(com.mongodb.internal.async.AsyncBatchCursor) MongoNamespace(com.mongodb.MongoNamespace)

Example 2 with FindOptions

use of com.mongodb.internal.client.model.FindOptions 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)

Example 3 with FindOptions

use of com.mongodb.internal.client.model.FindOptions in project mongo-java-driver by mongodb.

the class AggregateIterableImpl method asReadOperation.

@Override
public ReadOperation<BatchCursor<TResult>> asReadOperation() {
    MongoNamespace outNamespace = getOutNamespace();
    if (outNamespace != null) {
        getExecutor().execute(operations.aggregateToCollection(pipeline, maxTimeMS, allowDiskUse, bypassDocumentValidation, collation, hint, hintString, comment, variables, aggregationLevel), getReadPreference(), getReadConcern(), getClientSession());
        FindOptions findOptions = new FindOptions().collation(collation);
        Integer batchSize = getBatchSize();
        if (batchSize != null) {
            findOptions.batchSize(batchSize);
        }
        return operations.find(outNamespace, new BsonDocument(), resultClass, findOptions);
    } else {
        return asAggregateOperation();
    }
}
Also used : FindOptions(com.mongodb.internal.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) MongoNamespace(com.mongodb.MongoNamespace)

Example 4 with FindOptions

use of com.mongodb.internal.client.model.FindOptions in project mongo-java-driver by mongodb.

the class MapReducePublisherImpl method createFindOperation.

private AsyncReadOperation<AsyncBatchCursor<T>> createFindOperation(final int initialBatchSize) {
    String dbName = databaseName != null ? databaseName : getNamespace().getDatabaseName();
    FindOptions findOptions = new FindOptions().collation(collation).batchSize(initialBatchSize);
    return getOperations().find(new MongoNamespace(dbName, collectionName), new BsonDocument(), getDocumentClass(), findOptions);
}
Also used : FindOptions(com.mongodb.internal.client.model.FindOptions) BsonDocument(org.bson.BsonDocument) MongoNamespace(com.mongodb.MongoNamespace)

Aggregations

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