T
- the operations result type.AsyncReadOperation<AsyncBatchCursor<T>>
, ReadOperation<BatchCursor<T>>
public class AggregateOperation<T> extends Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Constructor | Description |
---|---|
AggregateOperation(MongoNamespace namespace,
List<BsonDocument> pipeline,
Decoder<T> decoder) |
Construct a new instance.
|
Modifier and Type | Method | Description |
---|---|---|
AggregateOperation<T> |
allowDiskUse(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.
|
AggregateOperation<T> |
batchSize(Integer batchSize) |
Sets the number of documents to return per batch.
|
AggregateOperation<T> |
collation(Collation collation) |
Sets the collation options
|
AggregateOperation<T> |
comment(String comment) |
Sets the comment to the aggregation.
|
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
|
Boolean |
getAllowDiskUse() |
Whether writing to temporary files is enabled.
|
Integer |
getBatchSize() |
Gets the number of documents to return per batch.
|
Collation |
getCollation() |
Returns the collation options
|
String |
getComment() |
Returns the comment to send with the aggregate.
|
BsonDocument |
getHint() |
Returns the hint for which index to use.
|
BsonValue |
getHintBsonValue() |
Returns the hint BsonValue for which index to use.
|
long |
getMaxAwaitTime(TimeUnit timeUnit) |
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor
query.
|
long |
getMaxTime(TimeUnit timeUnit) |
Gets the maximum execution time on the server for this operation.
|
List<BsonDocument> |
getPipeline() |
Gets the aggregation pipeline.
|
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.
|
AggregateOperation<T> |
hint(BsonValue hint) |
Sets the hint for which index to use.
|
AggregateOperation<T> |
maxAwaitTime(long maxAwaitTime,
TimeUnit timeUnit) |
Sets the maximum await execution time on the server for this operation.
|
AggregateOperation<T> |
maxTime(long maxTime,
TimeUnit timeUnit) |
Sets the maximum execution time on the server for this operation.
|
String |
toString() |
|
AggregateOperation<T> |
useCursor(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.
|
public AggregateOperation(MongoNamespace namespace, 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 List<BsonDocument> getPipeline()
public Boolean getAllowDiskUse()
public AggregateOperation<T> allowDiskUse(Boolean allowDiskUse)
allowDiskUse
- true if writing to temporary files is enabledpublic Integer getBatchSize()
public AggregateOperation<T> batchSize(Integer batchSize)
batchSize
- the batch sizepublic long getMaxAwaitTime(TimeUnit timeUnit)
public AggregateOperation<T> maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
maxAwaitTime
- the max await time. A value less than one will be ignored, and indicates that the driver should respect the
server's default valuetimeUnit
- the time unit, which may not be nullpublic long getMaxTime(TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic AggregateOperation<T> maxTime(long maxTime, TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be null@Deprecated public Boolean getUseCursor()
@Deprecated public AggregateOperation<T> useCursor(Boolean useCursor)
useCursor
- whether the server should use a cursor to return resultspublic Collation getCollation()
public AggregateOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic String getComment()
public AggregateOperation<T> comment(String comment)
comment
- the commentpublic BsonDocument getHint()
public BsonValue getHintBsonValue()
Hints can either be a BsonString or a BsonDocument.
public AggregateOperation<T> hint(BsonValue hint)
hint
- the hintpublic BatchCursor<T> execute(ReadBinding binding)
ReadOperation
execute
in interface ReadOperation<T>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<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 verbosity