T
- the operations result type.public class MapReduceWithInlineResultsOperation<T> extends java.lang.Object implements AsyncReadOperation<MapReduceAsyncBatchCursor<T>>, ReadOperation<MapReduceBatchCursor<T>>
Operation that runs a Map Reduce against a MongoDB instance. This operation only supports "inline" results, i.e. the results will be returned as a result of running this operation.
To run a map reduce operation into a given collection, use MapReduceToCollectionOperation
.
Constructor and Description |
---|
MapReduceWithInlineResultsOperation(MongoNamespace namespace,
BsonJavaScript mapFunction,
BsonJavaScript reduceFunction,
Decoder<T> decoder)
Construct a MapReduceOperation with all the criteria it needs to execute.
|
Modifier and Type | Method and Description |
---|---|
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.
|
MapReduceWithInlineResultsOperation<T> |
collation(Collation collation)
Sets the collation options
|
MapReduceBatchCursor<T> |
execute(ReadBinding binding)
Executing this will return a cursor with your results and the statistics in.
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<MapReduceAsyncBatchCursor<T>> callback)
General execute which can return anything of type T
|
MapReduceWithInlineResultsOperation<T> |
filter(BsonDocument filter)
Sets the filter to apply to the query.
|
MapReduceWithInlineResultsOperation<T> |
finalizeFunction(BsonJavaScript finalizeFunction)
Sets the JavaScript function that follows the reduce method and modifies the output.
|
Collation |
getCollation()
Returns the collation options
|
Decoder<T> |
getDecoder()
Gets the decoder used to decode the result documents.
|
BsonDocument |
getFilter()
Gets the query filter.
|
BsonJavaScript |
getFinalizeFunction()
Gets the JavaScript function that follows the reduce method and modifies the output.
|
int |
getLimit()
Gets the limit to apply.
|
BsonJavaScript |
getMapFunction()
Gets the JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
|
long |
getMaxTime(java.util.concurrent.TimeUnit timeUnit)
Gets the maximum execution time on the server for this operation.
|
MongoNamespace |
getNamespace()
Gets the namespace.
|
ReadConcern |
getReadConcern()
Gets the read concern
|
BsonJavaScript |
getReduceFunction()
Gets the JavaScript function that "reduces" to a single object all the values associated with a particular key.
|
BsonDocument |
getScope()
Gets the global variables that are accessible in the map, reduce and finalize functions.
|
BsonDocument |
getSort()
Gets the sort criteria to apply to the query.
|
boolean |
isJsMode()
Gets the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce
functions.
|
boolean |
isVerbose()
Gets whether to include the timing information in the result information.
|
MapReduceWithInlineResultsOperation<T> |
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.
|
MapReduceWithInlineResultsOperation<T> |
limit(int limit)
Sets the limit to apply.
|
MapReduceWithInlineResultsOperation<T> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
MapReduceWithInlineResultsOperation<T> |
readConcern(ReadConcern readConcern)
Sets the read concern
|
MapReduceWithInlineResultsOperation<T> |
scope(BsonDocument scope)
Sets the global variables that are accessible in the map, reduce and finalize functions.
|
MapReduceWithInlineResultsOperation<T> |
sort(BsonDocument sort)
Sets the sort criteria to apply to the query.
|
MapReduceWithInlineResultsOperation<T> |
verbose(boolean verbose)
Sets whether to include the timing information in the result information.
|
public MapReduceWithInlineResultsOperation(MongoNamespace namespace, BsonJavaScript mapFunction, BsonJavaScript reduceFunction, Decoder<T> decoder)
namespace
- the database and collection namespace for the operation.mapFunction
- a JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- a JavaScript function that "reduces" to a single object all the values associated with a particular key.decoder
- the decoder for the result documents.public MongoNamespace getNamespace()
public Decoder<T> getDecoder()
public BsonJavaScript getMapFunction()
public BsonJavaScript getReduceFunction()
public BsonJavaScript getFinalizeFunction()
public MapReduceWithInlineResultsOperation<T> finalizeFunction(BsonJavaScript finalizeFunction)
finalizeFunction
- the JavaScript function that follows the reduce method and modifies the output.public BsonDocument getScope()
public MapReduceWithInlineResultsOperation<T> scope(BsonDocument scope)
scope
- the global variables that are accessible in the map, reduce and finalize functions.public BsonDocument getFilter()
public MapReduceWithInlineResultsOperation<T> filter(BsonDocument filter)
filter
- the filter to apply to the query.public BsonDocument getSort()
public MapReduceWithInlineResultsOperation<T> sort(BsonDocument sort)
sort
- the sort criteria, which may be null.public int getLimit()
public MapReduceWithInlineResultsOperation<T> limit(int limit)
limit
- the limit, which may be nullpublic boolean isJsMode()
public MapReduceWithInlineResultsOperation<T> jsMode(boolean jsMode)
jsMode
- the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and
reduce functionspublic boolean isVerbose()
public MapReduceWithInlineResultsOperation<T> verbose(boolean verbose)
verbose
- whether to include the timing information in the result information.public Collation getCollation()
public MapReduceWithInlineResultsOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic long getMaxTime(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic MapReduceWithInlineResultsOperation<T> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic ReadConcern getReadConcern()
public MapReduceWithInlineResultsOperation<T> readConcern(ReadConcern readConcern)
readConcern
- the read concernpublic MapReduceBatchCursor<T> execute(ReadBinding binding)
execute
in interface ReadOperation<MapReduceBatchCursor<T>>
binding
- the bindingpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<MapReduceAsyncBatchCursor<T>> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<MapReduceAsyncBatchCursor<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