public static class MapReduce.Builder extends Object
MapReduce
commands.Modifier and Type | Field and Description |
---|---|
protected String |
myFinalizeFunction
The finalize function to apply to the final results of the reduce
function.
|
protected boolean |
myJsMode
If true limits the translation of the documents to an from
BSON/JavaScript.
|
protected boolean |
myKeepTemp
If true then the temporary collections created during the map/reduce
should not be dropped.
|
protected int |
myLimit
Limits the number of objects to be used as input to the map/reduce.
|
protected String |
myMapFunction
The map functions to apply to each selected document.
|
protected String |
myOutputDatabase
The name of the output database if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
protected String |
myOutputName
The name of the output collection if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
protected MapReduce.OutputType |
myOutputType
The handling for the output of the map/reduce.
|
protected Document |
myQuery
The query to select the document to run the map/reduce against.
|
protected ReadPreference |
myReadPreference
The read preference to use.
|
protected String |
myReduceFunction
The reduce function to apply to the emitted output of the map
function.
|
protected Document |
myScope
The scoped values to expose to the map/reduce/finalize functions.
|
protected Document |
mySort
The sort to apply to the input objects.
|
protected boolean |
myVerbose
If true emits progress messages in the server logs.
|
Constructor and Description |
---|
MapReduce.Builder()
Creates a new Builder.
|
Modifier and Type | Method and Description |
---|---|
MapReduce |
build()
Constructs a new
FindAndModify object from the state of the
builder. |
MapReduce.Builder |
finalize(String finalize)
Sets the finalize function to apply to the final results of the
reduce function.
|
MapReduce.Builder |
jsMode()
Sets to true to limit the translation of the documents to an from
BSON/JavaScript.
|
MapReduce.Builder |
jsMode(boolean jsMode)
Sets to true to limit the translation of the documents to an from
BSON/JavaScript.
|
MapReduce.Builder |
keepTemp()
Sets to true to drop the temporary collections created during the
map/reduce.
|
MapReduce.Builder |
keepTemp(boolean keepTemp)
Sets to true to drop the temporary collections created during the
map/reduce.
|
MapReduce.Builder |
limit(int limit)
Sets the limit for the number of objects to be used as input to the
map/reduce.
|
MapReduce.Builder |
map(String map)
Sets the map functions to apply to each selected document.
|
MapReduce.Builder |
outputDatabase(String outputDatabase)
Sets the name of the output database if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
MapReduce.Builder |
outputName(String outputName)
Sets the name of the output collection if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
MapReduce.Builder |
outputType(MapReduce.OutputType outputType)
Sets the handling for the output of the map/reduce.
|
MapReduce.Builder |
query(DocumentAssignable query)
Sets the query to select the documents to run the map/reduce against.
|
MapReduce.Builder |
readPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the MapReduce command. |
MapReduce.Builder |
reduce(String reduce)
Sets the reduce function to apply to the emitted output of the map
function.
|
MapReduce.Builder |
reset()
Resets the builder back to its initial state.
|
MapReduce.Builder |
scope(DocumentAssignable scope)
Sets the scoped values to expose to the map/reduce/finalize
functions.
|
MapReduce.Builder |
setFinalizeFunction(String finalize)
Sets the finalize function to apply to the final results of the
reduce function.
|
MapReduce.Builder |
setJsMode(boolean jsMode)
Sets to true to limit the translation of the documents to an from
BSON/JavaScript.
|
MapReduce.Builder |
setKeepTemp(boolean keepTemp)
Sets to true to drop the temporary collections created during the
map/reduce.
|
MapReduce.Builder |
setLimit(int limit)
Sets the limit for the number of objects to be used as input to the
map/reduce.
|
MapReduce.Builder |
setMapFunction(String map)
Sets the map functions to apply to each selected document.
|
MapReduce.Builder |
setOutputDatabase(String outputDatabase)
Sets the name of the output database if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
MapReduce.Builder |
setOutputName(String outputName)
Sets the name of the output collection if the output type is One of
MapReduce.OutputType.REPLACE , MapReduce.OutputType.MERGE , or
MapReduce.OutputType.REDUCE . |
MapReduce.Builder |
setOutputType(MapReduce.OutputType outputType)
Sets the handling for the output of the map/reduce.
|
MapReduce.Builder |
setQuery(DocumentAssignable query)
Sets the query to select the documents to run the map/reduce against.
|
MapReduce.Builder |
setReadPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the MapReduce command. |
MapReduce.Builder |
setReduceFunction(String reduce)
Sets the reduce function to apply to the emitted output of the map
function.
|
MapReduce.Builder |
setScope(DocumentAssignable scope)
Sets the scoped values to expose to the map/reduce/finalize
functions.
|
MapReduce.Builder |
setSort(DocumentAssignable sort)
Sets the sort to apply to the input objects.
|
MapReduce.Builder |
setSort(IntegerElement... sortFields)
Sets the sort to apply to the input objects.
|
MapReduce.Builder |
setVerbose(boolean verbose)
Sets to true to emit progress messages in the server logs.
|
MapReduce.Builder |
sort(DocumentAssignable sort)
Sets the sort to apply to the input objects.
|
MapReduce.Builder |
sort(IntegerElement... sortFields)
Sets the sort to apply to the input objects.
|
MapReduce.Builder |
verbose()
Sets to true to emit progress messages in the server logs.
|
MapReduce.Builder |
verbose(boolean verbose)
Sets to true to emit progress messages in the server logs.
|
protected String myFinalizeFunction
protected boolean myJsMode
protected boolean myKeepTemp
protected int myLimit
protected String myMapFunction
protected String myOutputDatabase
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.protected String myOutputName
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.protected MapReduce.OutputType myOutputType
protected Document myQuery
protected ReadPreference myReadPreference
protected String myReduceFunction
protected Document myScope
protected Document mySort
protected boolean myVerbose
public MapReduce build()
FindAndModify
object from the state of the
builder.FindAndModify
object.public MapReduce.Builder finalize(String finalize)
This method delegates to setFinalizeFunction(String)
.
finalize
- The finalize function to apply to the final results of the
reduce function.public MapReduce.Builder jsMode()
This method delegates to setJsMode(true)
.
public MapReduce.Builder jsMode(boolean jsMode)
This method delegates to setJsMode(boolean)
.
jsMode
- True to limit the translation of the documents to an from
BSON/JavaScript.public MapReduce.Builder keepTemp()
This method delegates to setKeepTemp(true)
.
public MapReduce.Builder keepTemp(boolean keepTemp)
This method delegates to keepTemp(boolean)
.
keepTemp
- True to drop the temporary collections created during the
map/reduce.public MapReduce.Builder limit(int limit)
This method delegates to setLimit(int)
.
limit
- The limit for the number of objects to be used as input to
the map/reduce.public MapReduce.Builder map(String map)
This method delegates to setMapFunction(String)
.
map
- The map functions to apply to each selected document.public MapReduce.Builder outputDatabase(String outputDatabase)
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.
This method delegates to setOutputDatabase(String)
.
outputDatabase
- The name of the output database if the output type is One
of MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
,
or MapReduce.OutputType.REDUCE
.public MapReduce.Builder outputName(String outputName)
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.
This method delegates to setOutputName(String)
.
outputName
- The name of the output collection if the output type is
One of MapReduce.OutputType.REPLACE
,
MapReduce.OutputType.MERGE
, or MapReduce.OutputType.REDUCE
.public MapReduce.Builder outputType(MapReduce.OutputType outputType)
This method delegates to setOutputType(com.allanbank.mongodb.builder.MapReduce.OutputType)
.
outputType
- The handling for the output of the map/reduce.public MapReduce.Builder query(DocumentAssignable query)
This method delegates to setQuery(DocumentAssignable)
.
query
- The query to select the documents to run the map/reduce
against.public MapReduce.Builder readPreference(ReadPreference readPreference)
ReadPreference
specifying which servers may be used
to execute the MapReduce
command.
If not set or set to null
then the
MongoCollection
instance's ReadPreference
will be
used.
This method delegates to setReadPreference(ReadPreference)
.
readPreference
- The read preferences specifying which servers may be used.MongoCollection.getReadPreference()
public MapReduce.Builder reduce(String reduce)
This method delegates to setReduceFunction(String)
.
reduce
- The reduce function to apply to the emitted output of the
map function.public MapReduce.Builder reset()
MapReduce.Builder
for method call chaining.public MapReduce.Builder scope(DocumentAssignable scope)
This method delegates to setScope(DocumentAssignable)
.
scope
- The scoped values to expose to the map/reduce/finalize
functions.public MapReduce.Builder setFinalizeFunction(String finalize)
finalize
- The finalize function to apply to the final results of the
reduce function.public MapReduce.Builder setJsMode(boolean jsMode)
jsMode
- True to limit the translation of the documents to an from
BSON/JavaScript.public MapReduce.Builder setKeepTemp(boolean keepTemp)
keepTemp
- True to drop the temporary collections created during the
map/reduce.public MapReduce.Builder setLimit(int limit)
limit
- The limit for the number of objects to be used as input to
the map/reduce.public MapReduce.Builder setMapFunction(String map)
map
- The map functions to apply to each selected document.public MapReduce.Builder setOutputDatabase(String outputDatabase)
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.outputDatabase
- The name of the output database if the output type is One
of MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
,
or MapReduce.OutputType.REDUCE
.public MapReduce.Builder setOutputName(String outputName)
MapReduce.OutputType.REPLACE
, MapReduce.OutputType.MERGE
, or
MapReduce.OutputType.REDUCE
.outputName
- The name of the output collection if the output type is
One of MapReduce.OutputType.REPLACE
,
MapReduce.OutputType.MERGE
, or MapReduce.OutputType.REDUCE
.public MapReduce.Builder setOutputType(MapReduce.OutputType outputType)
outputType
- The handling for the output of the map/reduce.public MapReduce.Builder setQuery(DocumentAssignable query)
query
- The query to select the documents to run the map/reduce
against.public MapReduce.Builder setReadPreference(ReadPreference readPreference)
ReadPreference
specifying which servers may be used
to execute the MapReduce
command.
If not set or set to null
then the
MongoCollection
instance's ReadPreference
will be
used.
readPreference
- The read preferences specifying which servers may be used.MongoCollection.getReadPreference()
public MapReduce.Builder setReduceFunction(String reduce)
reduce
- The reduce function to apply to the emitted output of the
map function.public MapReduce.Builder setScope(DocumentAssignable scope)
scope
- The scoped values to expose to the map/reduce/finalize
functions.public MapReduce.Builder setSort(DocumentAssignable sort)
sort
- The sort to apply to the input objects. Useful for
optimization, like sorting by the emit key for fewer
reduces.public MapReduce.Builder setSort(IntegerElement... sortFields)
This method is intended to be used with the Sort
class's
static methods:
import static
com.allanbank.mongodb.builder.Sort.asc
; import staticcom.allanbank.mongodb.builder.Sort.desc
; MapReduce.Builder builder = new Find.Builder(); builder.setSort( asc("f"), desc("g") ); ...
sortFields
- The sort to apply to the input objects. Useful for
optimization, like sorting by the emit key for fewer
reduces.public MapReduce.Builder setVerbose(boolean verbose)
verbose
- True to emit progress messages in the server logs.public MapReduce.Builder sort(DocumentAssignable sort)
This method delegates to setSort(DocumentAssignable)
.
sort
- The sort to apply to the input objects. Useful for
optimization, like sorting by the emit key for fewer
reduces.public MapReduce.Builder sort(IntegerElement... sortFields)
This method delegates to setSort(IntegerElement...)
.
This method is intended to be used with the Sort
class's
static methods:
import static
com.allanbank.mongodb.builder.Sort.asc
; import staticcom.allanbank.mongodb.builder.Sort.desc
; MapReduce.Builder builder = new Find.Builder(); builder.setSort( asc("f"), desc("g") ); ...
sortFields
- The sort to apply to the input objects. Useful for
optimization, like sorting by the emit key for fewer
reduces.public MapReduce.Builder verbose()
This method delegates to setVerbose(true)
.
public MapReduce.Builder verbose(boolean verbose)
This method delegates to setVerbose(boolean)
.
verbose
- True to emit progress messages in the server logs.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.