T
- the operations result type.public class AggregateOperation<T> extends java.lang.Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Modifier and Type | Field and Description |
---|---|
private java.lang.Boolean |
allowDiskUse |
private java.lang.Integer |
batchSize |
private Collation |
collation |
private static java.lang.String |
CURSOR |
private Decoder<T> |
decoder |
private static java.util.List<java.lang.String> |
FIELD_NAMES_WITH_RESULT |
private static java.lang.String |
FIRST_BATCH |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
private java.util.List<BsonDocument> |
pipeline |
private ReadConcern |
readConcern |
private static java.lang.String |
RESULT |
private java.lang.Boolean |
useCursor |
Constructor and Description |
---|
AggregateOperation(MongoNamespace namespace,
java.util.List<BsonDocument> pipeline,
Decoder<T> decoder)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
AggregateOperation<T> |
allowDiskUse(java.lang.Boolean allowDiskUse)
Enables writing to temporary files.
|
ReadOperation<BsonDocument> |
asExplainableOperation(ExplainVerbosity explainVerbosity)
Gets an operation whose execution explains this operation.
|
AsyncReadOperation<BsonDocument> |
asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
Gets an operation whose execution explains this operation.
|
private CommandOperationHelper.CommandTransformer<BsonDocument,AsyncBatchCursor<T>> |
asyncTransformer(AsyncConnectionSource source,
AsyncConnection connection) |
AggregateOperation<T> |
batchSize(java.lang.Integer batchSize)
Sets the number of documents to return per batch.
|
AggregateOperation<T> |
collation(Collation collation)
Sets the collation options
|
private QueryResult<T> |
createQueryResult(BsonDocument result,
ConnectionDescription description) |
BatchCursor<T> |
execute(ReadBinding binding)
General execute which can return anything of type T
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<AsyncBatchCursor<T>> callback)
General execute which can return anything of type T
|
java.lang.Boolean |
getAllowDiskUse()
Whether writing to temporary files is enabled.
|
java.lang.Integer |
getBatchSize()
Gets the number of documents to return per batch.
|
Collation |
getCollation()
Returns the collation options
|
private BsonDocument |
getCommand(ConnectionDescription description) |
long |
getMaxTime(java.util.concurrent.TimeUnit timeUnit)
Gets the maximum execution time on the server for this operation.
|
java.util.List<BsonDocument> |
getPipeline()
Gets the aggregation pipeline.
|
ReadConcern |
getReadConcern()
Gets the read concern
|
java.lang.Boolean |
getUseCursor()
Deprecated.
There is no replacement for this. Applications can assume that the driver will use a cursor for server versions
that support it (>= 2.6). The driver will ignore this as of MongoDB 3.6, which does not support inline results for the aggregate
command.
|
private boolean |
isInline(ConnectionDescription description) |
AggregateOperation<T> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
AggregateOperation<T> |
readConcern(ReadConcern readConcern)
Sets the read concern
|
private CommandOperationHelper.CommandTransformer<BsonDocument,BatchCursor<T>> |
transformer(ConnectionSource source,
Connection connection) |
AggregateOperation<T> |
useCursor(java.lang.Boolean useCursor)
Deprecated.
There is no replacement for this. Applications can assume that the driver will use a cursor for server versions
that support it (>= 2.6). The driver will ignore this as of MongoDB 3.6, which does not support inline results for the aggregate
command.
|
private static final java.lang.String RESULT
private static final java.lang.String CURSOR
private static final java.lang.String FIRST_BATCH
private static final java.util.List<java.lang.String> FIELD_NAMES_WITH_RESULT
private final MongoNamespace namespace
private final java.util.List<BsonDocument> pipeline
private java.lang.Boolean allowDiskUse
private java.lang.Integer batchSize
private long maxTimeMS
private java.lang.Boolean useCursor
private ReadConcern readConcern
private Collation collation
public AggregateOperation(MongoNamespace namespace, java.util.List<BsonDocument> pipeline, Decoder<T> decoder)
namespace
- the database and collection namespace for the operation.pipeline
- the aggregation pipeline.decoder
- the decoder for the result documents.public java.util.List<BsonDocument> getPipeline()
public java.lang.Boolean getAllowDiskUse()
public AggregateOperation<T> allowDiskUse(java.lang.Boolean allowDiskUse)
allowDiskUse
- true if writing to temporary files is enabledpublic java.lang.Integer getBatchSize()
public AggregateOperation<T> batchSize(java.lang.Integer batchSize)
batchSize
- the batch sizepublic long getMaxTime(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic AggregateOperation<T> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be null@Deprecated public java.lang.Boolean getUseCursor()
@Deprecated public AggregateOperation<T> useCursor(java.lang.Boolean useCursor)
useCursor
- whether the server should use a cursor to return resultspublic ReadConcern getReadConcern()
public AggregateOperation<T> readConcern(ReadConcern readConcern)
readConcern
- the read concernpublic Collation getCollation()
public AggregateOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic BatchCursor<T> execute(ReadBinding binding)
ReadOperation
execute
in interface ReadOperation<BatchCursor<T>>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<AsyncBatchCursor<T>>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executedpublic ReadOperation<BsonDocument> asExplainableOperation(ExplainVerbosity explainVerbosity)
explainVerbosity
- the explain verbositypublic AsyncReadOperation<BsonDocument> asExplainableOperationAsync(ExplainVerbosity explainVerbosity)
explainVerbosity
- the explain verbosityprivate boolean isInline(ConnectionDescription description)
private BsonDocument getCommand(ConnectionDescription description)
private QueryResult<T> createQueryResult(BsonDocument result, ConnectionDescription description)
private CommandOperationHelper.CommandTransformer<BsonDocument,BatchCursor<T>> transformer(ConnectionSource source, Connection connection)
private CommandOperationHelper.CommandTransformer<BsonDocument,AsyncBatchCursor<T>> asyncTransformer(AsyncConnectionSource source, AsyncConnection connection)