Spring Data MongoDB

org.springframework.data.mongodb.core.mapreduce
Class MapReduceOptions

java.lang.Object
  extended by org.springframework.data.mongodb.core.mapreduce.MapReduceOptions

public class MapReduceOptions
extends Object


Constructor Summary
MapReduceOptions()
           
 
Method Summary
protected  com.mongodb.BasicDBObject createOutObject()
           
 MapReduceOptions extraOption(String key, Object value)
          Add additional extra options that may not have a method on this class.
 MapReduceOptions finalizeFunction(String finalizeFunction)
          Sets the finalize function
 Map<String,Object> getExtraOptions()
           
 String getFinalizeFunction()
           
 Boolean getJavaScriptMode()
           
 com.mongodb.DBObject getOptionsObject()
           
 String getOutputCollection()
           
 String getOutputDatabase()
           
 Boolean getOutputSharded()
           
 com.mongodb.MapReduceCommand.OutputType getOutputType()
           
 Map<String,Object> getScopeVariables()
           
 MapReduceOptions javaScriptMode(boolean javaScriptMode)
          Flag that toggles behavior in the map-reduce operation so as to avoid intermediate conversion to BSON between the map and reduce steps.
 MapReduceOptions limit(int limit)
          Limit the number of objects to return from the collection that is fed into the map reduce operation Often used in conjunction with a query and sort option so as to reduce the portion of the data that will be processed.
static MapReduceOptions options()
          Static factory method to create a MapReduceOptions instance
 MapReduceOptions outputCollection(String collectionName)
          The collection where the results from the map-reduce operation will be stored.
 MapReduceOptions outputDatabase(String outputDatabase)
          The database where the results from the map-reduce operation will be stored.
 MapReduceOptions outputSharded(boolean outputShared)
          If true and combined with an output mode that writes to a collection, the output collection will be sharded using the _id field.
 MapReduceOptions outputTypeInline()
          With this option, no collection will be created, and the whole map-reduce operation will happen in RAM.
 MapReduceOptions outputTypeMerge()
          This option will merge new data into the old output collection.
 MapReduceOptions outputTypeReduce()
          If documents exists for a given key in the result set and in the old collection, then a reduce operation (using the specified reduce function) will be performed on the two values and the result will be written to the output collection.
 MapReduceOptions outputTypeReplace()
          The output will be inserted into a collection which will atomically replace any existing collection with the same name.
 MapReduceOptions scopeVariables(Map<String,Object> scopeVariables)
          Key-value pairs that are placed into JavaScript global scope and can be accessed from map, reduce, and finalize scripts.
 MapReduceOptions verbose(boolean verbose)
          Flag to set that will provide statistics on job execution time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapReduceOptions

public MapReduceOptions()
Method Detail

options

public static MapReduceOptions options()
Static factory method to create a MapReduceOptions instance

Returns:
a new instance

limit

public MapReduceOptions limit(int limit)
Limit the number of objects to return from the collection that is fed into the map reduce operation Often used in conjunction with a query and sort option so as to reduce the portion of the data that will be processed.

Parameters:
limit - Limit the number of objects to process
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputCollection

public MapReduceOptions outputCollection(String collectionName)
The collection where the results from the map-reduce operation will be stored. Note, you can set the database name as well with the outputDatabase option.

Parameters:
collectionName - The name of the collection where the results of the map-reduce operation will be stored.
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputDatabase

public MapReduceOptions outputDatabase(String outputDatabase)
The database where the results from the map-reduce operation will be stored. Note, you ca set the collection name as well with the outputCollection option.

Parameters:
outputDatabase - The name of the database where the results of the map-reduce operation will be stored.
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputTypeInline

public MapReduceOptions outputTypeInline()
With this option, no collection will be created, and the whole map-reduce operation will happen in RAM. Also, the results of the map-reduce will be returned within the result object. Note that this option is possible only when the result set fits within the 16MB limit of a single document.

Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputTypeMerge

public MapReduceOptions outputTypeMerge()
This option will merge new data into the old output collection. In other words, if the same key exists in both the result set and the old collection, the new key will overwrite the old one.

Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputTypeReduce

public MapReduceOptions outputTypeReduce()
If documents exists for a given key in the result set and in the old collection, then a reduce operation (using the specified reduce function) will be performed on the two values and the result will be written to the output collection. If a finalize function was provided, this will be run after the reduce as well.

Returns:

outputTypeReplace

public MapReduceOptions outputTypeReplace()
The output will be inserted into a collection which will atomically replace any existing collection with the same name. Note, the default is MapReduceCommand.OutputType.REPLACE

Returns:
MapReduceOptions so that methods can be chained in a fluent API style

outputSharded

public MapReduceOptions outputSharded(boolean outputShared)
If true and combined with an output mode that writes to a collection, the output collection will be sharded using the _id field. For MongoDB 1.9+

Parameters:
outputShared - if true, output will be sharded based on _id key.
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

finalizeFunction

public MapReduceOptions finalizeFunction(String finalizeFunction)
Sets the finalize function

Parameters:
finalizeFunction - The finalize function. Can be a JSON string or a Spring Resource URL
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

scopeVariables

public MapReduceOptions scopeVariables(Map<String,Object> scopeVariables)
Key-value pairs that are placed into JavaScript global scope and can be accessed from map, reduce, and finalize scripts.

Parameters:
scopeVariables - variables that can be accessed from map, reduce, and finalize scripts
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

javaScriptMode

public MapReduceOptions javaScriptMode(boolean javaScriptMode)
Flag that toggles behavior in the map-reduce operation so as to avoid intermediate conversion to BSON between the map and reduce steps. For MongoDB 1.9+

Parameters:
javaScriptMode - if true, have the execution of map-reduce stay in JavaScript
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

verbose

public MapReduceOptions verbose(boolean verbose)
Flag to set that will provide statistics on job execution time.

Returns:
MapReduceOptions so that methods can be chained in a fluent API style

extraOption

public MapReduceOptions extraOption(String key,
                                    Object value)
Add additional extra options that may not have a method on this class. This method will help if you use a version of this client library with a server version that has added additional map-reduce options that do not yet have an method for use in setting them. options

Parameters:
key - The key option
value - The value of the option
Returns:
MapReduceOptions so that methods can be chained in a fluent API style

getExtraOptions

public Map<String,Object> getExtraOptions()

getFinalizeFunction

public String getFinalizeFunction()

getJavaScriptMode

public Boolean getJavaScriptMode()

getOutputCollection

public String getOutputCollection()

getOutputDatabase

public String getOutputDatabase()

getOutputSharded

public Boolean getOutputSharded()

getOutputType

public com.mongodb.MapReduceCommand.OutputType getOutputType()

getScopeVariables

public Map<String,Object> getScopeVariables()

getOptionsObject

public com.mongodb.DBObject getOptionsObject()

createOutObject

protected com.mongodb.BasicDBObject createOutObject()

Spring Data MongoDB

Copyright © 2011-2013-2013 SpringSource. All Rights Reserved.