T
- the operations result type.public class GroupOperation<T> extends Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Constructor and Description |
---|
GroupOperation(MongoNamespace namespace,
BsonJavaScript reduceFunction,
BsonDocument initial,
Decoder<T> decoder)
Create an operation that will perform a Group on a given collection.
|
Modifier and Type | Method and Description |
---|---|
GroupOperation<T> |
collation(Collation collation)
Sets the collation options
|
BatchCursor<T> |
execute(ReadBinding binding)
Will return a cursor of Documents containing the results of the group operation.
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<AsyncBatchCursor<T>> callback)
General execute which can return anything of type T
|
GroupOperation<T> |
filter(BsonDocument filter)
Sets the optional query filter to determine which documents in the collection to process.
|
GroupOperation<T> |
finalizeFunction(BsonJavaScript finalizeFunction)
Sets the function that runs each item in the result set before returning the final value.
|
Collation |
getCollation()
Returns the collation options
|
Decoder<T> |
getDecoder()
Gets the decoder used to decode the result documents.
|
BsonDocument |
getFilter()
Gets the query filter to determine which documents in the collection to process.
|
BsonJavaScript |
getFinalizeFunction()
Gets the function that runs each item in the result before returning the final value.
|
BsonDocument |
getInitial()
Gets the initial the aggregation result document.
|
BsonDocument |
getKey()
Gets the document containing the field or fields to group.
|
BsonJavaScript |
getKeyFunction()
Gets the function that creates a "key object" for use as the grouping key.
|
MongoNamespace |
getNamespace()
Gets the namespace.
|
BsonJavaScript |
getReduceFunction()
Gets the aggregation function that operates on the documents during the grouping operation.
|
GroupOperation<T> |
key(BsonDocument key)
Sets the document containing the field or fields to group.
|
GroupOperation<T> |
keyFunction(BsonJavaScript keyFunction)
Sets the function that creates a "key object" for use as the grouping key.
|
public GroupOperation(MongoNamespace namespace, BsonJavaScript reduceFunction, BsonDocument initial, Decoder<T> decoder)
namespace
- the database and collection namespace for the operation.reduceFunction
- The aggregation function that operates on the documents during the grouping operation.initial
- The initial the aggregation result document.decoder
- the decoder for the result documents.public MongoNamespace getNamespace()
public Decoder<T> getDecoder()
public BsonDocument getKey()
public GroupOperation<T> key(BsonDocument key)
key
- the document containing the field or fields to group.public BsonJavaScript getKeyFunction()
public GroupOperation<T> keyFunction(BsonJavaScript keyFunction)
keyFunction
- the function that creates a "key object" for use as the grouping key.public BsonDocument getInitial()
public BsonJavaScript getReduceFunction()
public BsonDocument getFilter()
public GroupOperation<T> filter(BsonDocument filter)
filter
- the query filter to determine which documents in the collection to process.public BsonJavaScript getFinalizeFunction()
public GroupOperation<T> finalizeFunction(BsonJavaScript finalizeFunction)
finalizeFunction
- the function that runs each item in the result set before returning the final value.public Collation getCollation()
public GroupOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic BatchCursor<T> execute(ReadBinding binding)
execute
in interface ReadOperation<BatchCursor<T>>
binding
- the bindingpublic 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 executed