Interface MapReduceIterable<TResult>

  • Type Parameters:
    TResult - The type of the result.
    All Superinterfaces:
    Iterable<TResult>, MongoIterable<TResult>

    public interface MapReduceIterable<TResult>
    extends MongoIterable<TResult>
    Iterable for map-reduce.

    By default the MapReduceIterable returns the results inline. You can write map-reduce output to a collection by using the collectionName(String) method.

    Since:
    3.0
    • Method Detail

      • toCollection

        void toCollection()
        Aggregates documents to a collection according to the specified map-reduce function with the given options, which must specify a non-inline result.
        Throws:
        IllegalStateException - if a collection name to write the results to has not been specified
        Since:
        3.4
        See Also:
        collectionName(String)
      • collectionName

        MapReduceIterable<TResult> collectionName​(String collectionName)
        Sets the collectionName for the output of the MapReduce

        The default action is replace the collection if it exists, to change this use action(com.mongodb.client.model.MapReduceAction).

        Parameters:
        collectionName - the name of the collection that you want the map-reduce operation to write its output.
        Returns:
        this
      • scope

        MapReduceIterable<TResult> scope​(@Nullable
                                         Bson scope)
        Sets the global variables that are accessible in the map, reduce and finalize functions.
        Parameters:
        scope - the global variables that are accessible in the map, reduce and finalize functions.
        Returns:
        this
        MongoDB documentation
        mapReduce
      • sort

        MapReduceIterable<TResult> sort​(@Nullable
                                        Bson sort)
        Sets the sort criteria to apply to the query.
        Parameters:
        sort - the sort criteria, which may be null.
        Returns:
        this
        MongoDB documentation
        Sort
      • limit

        MapReduceIterable<TResult> limit​(int limit)
        Sets the limit to apply.
        Parameters:
        limit - the limit, which may be null
        Returns:
        this
        MongoDB documentation
        Limit
      • jsMode

        MapReduceIterable<TResult> jsMode​(boolean jsMode)
        Sets the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions. Defaults to false.
        Parameters:
        jsMode - the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions
        Returns:
        jsMode
        MongoDB documentation
        mapReduce
      • verbose

        MapReduceIterable<TResult> verbose​(boolean verbose)
        Sets whether to include the timing information in the result information.
        Parameters:
        verbose - whether to include the timing information in the result information.
        Returns:
        this
      • maxTime

        MapReduceIterable<TResult> maxTime​(long maxTime,
                                           TimeUnit timeUnit)
        Sets the maximum execution time on the server for this operation.
        Parameters:
        maxTime - the max time
        timeUnit - the time unit, which may not be null
        Returns:
        this
        MongoDB documentation
        Max Time
      • sharded

        @Deprecated
        MapReduceIterable<TResult> sharded​(boolean sharded)
        Deprecated.
        this option will no longer be supported in MongoDB 4.4.
        Sets if the output database is sharded
        Parameters:
        sharded - if the output database is sharded
        Returns:
        this
        MongoDB documentation
        output with an action
      • nonAtomic

        @Deprecated
        MapReduceIterable<TResult> nonAtomic​(boolean nonAtomic)
        Deprecated.
        this option will no longer be supported in MongoDB 4.4 as it will no longer hold a global or database level write lock.
        Sets if the post-processing step will prevent MongoDB from locking the database. Valid only with the MapReduceAction.MERGE or MapReduceAction.REDUCE actions.
        Parameters:
        nonAtomic - if the post-processing step will prevent MongoDB from locking the database.
        Returns:
        this
        MongoDB documentation
        output with an action
      • bypassDocumentValidation

        MapReduceIterable<TResult> bypassDocumentValidation​(@Nullable
                                                            Boolean bypassDocumentValidation)
        Sets the bypass document level validation flag.

        Note: This only applies when an $out stage is specified

        .
        Parameters:
        bypassDocumentValidation - If true, allows the write to opt-out of document level validation.
        Returns:
        this
        Since:
        3.2
        MongoDB documentation
        mapReduce
        Since server release
        3.2
      • collation

        MapReduceIterable<TResult> collation​(@Nullable
                                             Collation collation)
        Sets the collation options

        A null value represents the server default.

        Parameters:
        collation - the collation options to use
        Returns:
        this
        Since:
        3.4
        Since server release
        3.4