public class MapReduceToCollectionOperation extends java.lang.Object implements AsyncWriteOperation<MapReduceStatistics>, WriteOperation<MapReduceStatistics>
To run a map reduce operation and receive the results inline (i.e. as a response to running the command) use MapReduceToCollectionOperation
.
Constructor and Description |
---|
MapReduceToCollectionOperation(MongoNamespace namespace,
BsonJavaScript mapFunction,
BsonJavaScript reduceFunction,
java.lang.String collectionName)
Construct a MapReduceOperation with all the criteria it needs to execute
|
MapReduceToCollectionOperation(MongoNamespace namespace,
BsonJavaScript mapFunction,
BsonJavaScript reduceFunction,
java.lang.String collectionName,
WriteConcern writeConcern)
Construct a MapReduceOperation with all the criteria it needs to execute
|
Modifier and Type | Method and Description |
---|---|
MapReduceToCollectionOperation |
action(java.lang.String action)
Sets the output action one of: "replace", "merge", "reduce"
|
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.
|
MapReduceToCollectionOperation |
bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
Sets the bypass document level validation flag.
|
MapReduceToCollectionOperation |
collation(Collation collation)
Sets the collation options
|
MapReduceToCollectionOperation |
databaseName(java.lang.String databaseName)
Sets the name of the database to output into.
|
MapReduceStatistics |
execute(WriteBinding binding)
Executing this will return a cursor with your results in.
|
void |
executeAsync(AsyncWriteBinding binding,
SingleResultCallback<MapReduceStatistics> callback)
General execute which can return anything of type T
|
MapReduceToCollectionOperation |
filter(BsonDocument filter)
Sets the filter to apply to the query.
|
MapReduceToCollectionOperation |
finalizeFunction(BsonJavaScript finalizeFunction)
Sets the JavaScript function that follows the reduce method and modifies the output.
|
java.lang.String |
getAction()
Gets the output action, one of: "replace", "merge", "reduce".
|
java.lang.Boolean |
getBypassDocumentValidation()
Gets the bypass document level validation flag
|
Collation |
getCollation()
Returns the collation options
|
java.lang.String |
getCollectionName()
Gets the name of the collection to output the results to.
|
java.lang.String |
getDatabaseName()
Gets the name of the database to output into.
|
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.
|
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.
|
WriteConcern |
getWriteConcern()
Gets the write concern.
|
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 |
isNonAtomic()
True if the post-processing step will prevent MongoDB from locking the database.
|
boolean |
isSharded()
True if the output database is sharded
|
boolean |
isVerbose()
Gets whether to include the timing information in the result information.
|
MapReduceToCollectionOperation |
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.
|
MapReduceToCollectionOperation |
limit(int limit)
Sets the limit to apply.
|
MapReduceToCollectionOperation |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
MapReduceToCollectionOperation |
nonAtomic(boolean nonAtomic)
Sets if the post-processing step will prevent MongoDB from locking the database.
|
MapReduceToCollectionOperation |
scope(BsonDocument scope)
Sets the global variables that are accessible in the map, reduce and finalize functions.
|
MapReduceToCollectionOperation |
sharded(boolean sharded)
Sets if the output database is sharded
|
MapReduceToCollectionOperation |
sort(BsonDocument sort)
Sets the sort criteria to apply to the query.
|
MapReduceToCollectionOperation |
verbose(boolean verbose)
Sets whether to include the timing information in the result information.
|
public MapReduceToCollectionOperation(MongoNamespace namespace, BsonJavaScript mapFunction, BsonJavaScript reduceFunction, java.lang.String collectionName)
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.collectionName
- the name of the collection to output the results to.public MapReduceToCollectionOperation(MongoNamespace namespace, BsonJavaScript mapFunction, BsonJavaScript reduceFunction, java.lang.String collectionName, WriteConcern writeConcern)
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.collectionName
- the name of the collection to output the results to.writeConcern
- the write concernpublic MongoNamespace getNamespace()
public BsonJavaScript getMapFunction()
public BsonJavaScript getReduceFunction()
public java.lang.String getCollectionName()
public WriteConcern getWriteConcern()
public BsonJavaScript getFinalizeFunction()
public MapReduceToCollectionOperation finalizeFunction(BsonJavaScript finalizeFunction)
finalizeFunction
- the JavaScript function that follows the reduce method and modifies the output.public BsonDocument getScope()
public MapReduceToCollectionOperation scope(BsonDocument scope)
scope
- the global variables that are accessible in the map, reduce and finalize functions.public BsonDocument getFilter()
public MapReduceToCollectionOperation filter(BsonDocument filter)
filter
- the filter to apply to the query.public BsonDocument getSort()
public MapReduceToCollectionOperation sort(BsonDocument sort)
sort
- the sort criteria, which may be null.public int getLimit()
public MapReduceToCollectionOperation limit(int limit)
limit
- the limit, which may be nullpublic boolean isJsMode()
public MapReduceToCollectionOperation 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 MapReduceToCollectionOperation verbose(boolean verbose)
verbose
- whether to include the timing information in the result information.public long getMaxTime(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic MapReduceToCollectionOperation maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic java.lang.String getAction()
public MapReduceToCollectionOperation action(java.lang.String action)
action
- the output actionpublic java.lang.String getDatabaseName()
public MapReduceToCollectionOperation databaseName(java.lang.String databaseName)
databaseName
- the name of the database to output into.public boolean isSharded()
public MapReduceToCollectionOperation sharded(boolean sharded)
sharded
- if the output database is shardedpublic boolean isNonAtomic()
public MapReduceToCollectionOperation nonAtomic(boolean nonAtomic)
"merge"
or "reduce"
actions.nonAtomic
- if the post-processing step will prevent MongoDB from locking the database.public java.lang.Boolean getBypassDocumentValidation()
public MapReduceToCollectionOperation bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
Note: This only applies when an $out stage is specified
.bypassDocumentValidation
- If true, allows the write to opt-out of document level validation.public Collation getCollation()
public MapReduceToCollectionOperation collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic MapReduceStatistics execute(WriteBinding binding)
execute
in interface WriteOperation<MapReduceStatistics>
binding
- the bindingpublic void executeAsync(AsyncWriteBinding binding, SingleResultCallback<MapReduceStatistics> callback)
AsyncWriteOperation
executeAsync
in interface AsyncWriteOperation<MapReduceStatistics>
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