Class GroupOperation<T>

java.lang.Object
com.mongodb.operation.GroupOperation<T>
Type Parameters:
T - the operations result type.
All Implemented Interfaces:
AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>

@Deprecated public class GroupOperation<T> extends Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
Deprecated.
Groups documents in a collection by the specified key and performs simple aggregation functions, such as computing counts and sums. The command is analogous to a SELECT ... GROUP BY statement in SQL.
Since:
3.0
  • Constructor Details

    • GroupOperation

      public GroupOperation(MongoNamespace namespace, BsonJavaScript reduceFunction, BsonDocument initial, Decoder<T> decoder)
      Deprecated.
      Create an operation that will perform a Group on a given collection.
      Parameters:
      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.
  • Method Details

    • getNamespace

      public MongoNamespace getNamespace()
      Deprecated.
      Gets the namespace.
      Returns:
      the namespace
      Since:
      3.4
    • getDecoder

      public Decoder<T> getDecoder()
      Deprecated.
      Gets the decoder used to decode the result documents.
      Returns:
      the decoder
      Since:
      3.4
    • getKey

      public BsonDocument getKey()
      Deprecated.
      Gets the document containing the field or fields to group.
      Returns:
      the document containing the field or fields to group.
    • key

      public GroupOperation<T> key(BsonDocument key)
      Deprecated.
      Sets the document containing the field or fields to group.
      Parameters:
      key - the document containing the field or fields to group.
      Returns:
      this
    • getKeyFunction

      public BsonJavaScript getKeyFunction()
      Deprecated.
      Gets the function that creates a "key object" for use as the grouping key.
      Returns:
      the function that creates a "key object" for use as the grouping key.
    • keyFunction

      public GroupOperation<T> keyFunction(BsonJavaScript keyFunction)
      Deprecated.
      Sets the function that creates a "key object" for use as the grouping key.
      Parameters:
      keyFunction - the function that creates a "key object" for use as the grouping key.
      Returns:
      this
    • getInitial

      public BsonDocument getInitial()
      Deprecated.
      Gets the initial the aggregation result document.
      Returns:
      the initial the aggregation result document.
    • getReduceFunction

      public BsonJavaScript getReduceFunction()
      Deprecated.
      Gets the aggregation function that operates on the documents during the grouping operation.
      Returns:
      the aggregation function that operates on the documents during the grouping operation.
    • getFilter

      public BsonDocument getFilter()
      Deprecated.
      Gets the query filter to determine which documents in the collection to process.
      Returns:
      the query filter to determine which documents in the collection to process.
    • filter

      public GroupOperation<T> filter(BsonDocument filter)
      Deprecated.
      Sets the optional query filter to determine which documents in the collection to process.
      Parameters:
      filter - the query filter to determine which documents in the collection to process.
      Returns:
      this
    • getFinalizeFunction

      public BsonJavaScript getFinalizeFunction()
      Deprecated.
      Gets the function that runs each item in the result before returning the final value.
      Returns:
      the function that runs each item in the result set before returning the final value.
    • finalizeFunction

      public GroupOperation<T> finalizeFunction(BsonJavaScript finalizeFunction)
      Deprecated.
      Sets the function that runs each item in the result set before returning the final value.
      Parameters:
      finalizeFunction - the function that runs each item in the result set before returning the final value.
      Returns:
      this
    • getCollation

      public Collation getCollation()
      Deprecated.
      Returns the collation options
      Returns:
      the collation options
      Since:
      3.4
    • collation

      public GroupOperation<T> collation(Collation collation)
      Deprecated.
      Sets the collation options

      A null value represents the server default.

      Parameters:
      collation - the collation options to use
      Returns:
      this
      Since:
      3.4
    • retryReads

      public GroupOperation<T> retryReads(boolean retryReads)
      Deprecated.
      Enables retryable reads if a read fails due to a network error.
      Parameters:
      retryReads - true if reads should be retried
      Returns:
      this
      Since:
      3.11
    • getRetryReads

      public boolean getRetryReads()
      Deprecated.
      Gets the value for retryable reads. The default is true.
      Returns:
      the retryable reads value
      Since:
      3.11
    • execute

      public BatchCursor<T> execute(ReadBinding binding)
      Deprecated.
      Will return a cursor of Documents containing the results of the group operation.
      Specified by:
      execute in interface ReadOperation<T>
      Parameters:
      binding - the binding
      Returns:
      a MongoCursor of T, the results of the group operation in a form to be iterated over.
    • executeAsync

      public void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
      Deprecated.
      Description copied from interface: AsyncReadOperation
      General execute which can return anything of type T
      Specified by:
      executeAsync in interface AsyncReadOperation<T>
      Parameters:
      binding - the binding to execute in the context of
      callback - the callback to be called when the operation has been executed