class MapReduceIterableImpl<TDocument,TResult> extends java.lang.Object implements MapReduceIterable<TResult>
Modifier and Type | Field and Description |
---|---|
private MapReduceAction |
action |
private int |
batchSize |
private java.lang.Boolean |
bypassDocumentValidation |
private CodecRegistry |
codecRegistry |
private Collation |
collation |
private java.lang.String |
collectionName |
private java.lang.String |
databaseName |
private java.lang.Class<TDocument> |
documentClass |
private OperationExecutor |
executor |
private Bson |
filter |
private java.lang.String |
finalizeFunction |
private boolean |
inline |
private boolean |
jsMode |
private int |
limit |
private java.lang.String |
mapFunction |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
private boolean |
nonAtomic |
private ReadConcern |
readConcern |
private ReadPreference |
readPreference |
private java.lang.String |
reduceFunction |
private java.lang.Class<TResult> |
resultClass |
private Bson |
scope |
private boolean |
sharded |
private Bson |
sort |
private boolean |
verbose |
private WriteConcern |
writeConcern |
Constructor and Description |
---|
MapReduceIterableImpl(MongoNamespace namespace,
java.lang.Class<TDocument> documentClass,
java.lang.Class<TResult> resultClass,
CodecRegistry codecRegistry,
ReadPreference readPreference,
ReadConcern readConcern,
WriteConcern writeConcern,
OperationExecutor executor,
java.lang.String mapFunction,
java.lang.String reduceFunction) |
Modifier and Type | Method and Description |
---|---|
MapReduceIterable<TResult> |
action(MapReduceAction action)
Specify the
MapReduceAction to be used when writing to a collection. |
MapReduceIterable<TResult> |
batchSize(int batchSize)
Sets the number of documents to return per batch.
|
MapReduceIterable<TResult> |
bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
Sets the bypass document level validation flag.
|
MapReduceIterable<TResult> |
collation(Collation collation)
Sets the collation options
|
MapReduceIterable<TResult> |
collectionName(java.lang.String collectionName)
Sets the collectionName for the output of the MapReduce
|
private MapReduceToCollectionOperation |
createMapReduceToCollectionOperation() |
MapReduceIterable<TResult> |
databaseName(java.lang.String databaseName)
Sets the name of the database to output into.
|
(package private) MongoIterable<TResult> |
execute() |
MapReduceIterable<TResult> |
filter(Bson filter)
Sets the query filter to apply to the query.
|
MapReduceIterable<TResult> |
finalizeFunction(java.lang.String finalizeFunction)
Sets the JavaScript function that follows the reduce method and modifies the output.
|
TResult |
first()
Helper to return the first item in the iterator or null.
|
void |
forEach(Block<? super TResult> block)
Iterates over all documents in the view, applying the given block to each.
|
<A extends java.util.Collection<? super TResult>> |
into(A target)
Iterates over all the documents, adding each to the given target.
|
MongoCursor<TResult> |
iterator() |
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.
|
MapReduceIterable<TResult> |
limit(int limit)
Sets the limit to apply.
|
<U> MongoIterable<U> |
map(Function<TResult,U> mapper)
Maps this iterable from the source document type to the target document type.
|
MapReduceIterable<TResult> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
MapReduceIterable<TResult> |
nonAtomic(boolean nonAtomic)
Sets if the post-processing step will prevent MongoDB from locking the database.
|
MapReduceIterable<TResult> |
scope(Bson scope)
Sets the global variables that are accessible in the map, reduce and finalize functions.
|
MapReduceIterable<TResult> |
sharded(boolean sharded)
Sets if the output database is sharded
|
MapReduceIterable<TResult> |
sort(Bson sort)
Sets the sort criteria to apply to the query.
|
private BsonDocument |
toBsonDocument(Bson document) |
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.
|
MapReduceIterable<TResult> |
verbose(boolean verbose)
Sets whether to include the timing information in the result information.
|
private final MongoNamespace namespace
private final java.lang.Class<TDocument> documentClass
private final java.lang.Class<TResult> resultClass
private final ReadPreference readPreference
private final ReadConcern readConcern
private final CodecRegistry codecRegistry
private final WriteConcern writeConcern
private final OperationExecutor executor
private final java.lang.String mapFunction
private final java.lang.String reduceFunction
private boolean inline
private java.lang.String collectionName
private java.lang.String finalizeFunction
private Bson scope
private Bson filter
private Bson sort
private int limit
private boolean jsMode
private boolean verbose
private long maxTimeMS
private MapReduceAction action
private java.lang.String databaseName
private boolean sharded
private boolean nonAtomic
private int batchSize
private java.lang.Boolean bypassDocumentValidation
private Collation collation
MapReduceIterableImpl(MongoNamespace namespace, java.lang.Class<TDocument> documentClass, java.lang.Class<TResult> resultClass, CodecRegistry codecRegistry, ReadPreference readPreference, ReadConcern readConcern, WriteConcern writeConcern, OperationExecutor executor, java.lang.String mapFunction, java.lang.String reduceFunction)
public void toCollection()
MapReduceIterable
toCollection
in interface MapReduceIterable<TResult>
MapReduceIterable.collectionName(String)
public MapReduceIterable<TResult> collectionName(java.lang.String collectionName)
MapReduceIterable
The default action is replace the collection if it exists, to change this use MapReduceIterable.action(com.mongodb.client.model.MapReduceAction)
.
collectionName
in interface MapReduceIterable<TResult>
collectionName
- the name of the collection that you want the map-reduce operation to write its output.public MapReduceIterable<TResult> finalizeFunction(java.lang.String finalizeFunction)
MapReduceIterable
finalizeFunction
in interface MapReduceIterable<TResult>
finalizeFunction
- the JavaScript function that follows the reduce method and modifies the output.public MapReduceIterable<TResult> scope(Bson scope)
MapReduceIterable
scope
in interface MapReduceIterable<TResult>
scope
- the global variables that are accessible in the map, reduce and finalize functions.public MapReduceIterable<TResult> sort(Bson sort)
MapReduceIterable
sort
in interface MapReduceIterable<TResult>
sort
- the sort criteria, which may be null.public MapReduceIterable<TResult> filter(Bson filter)
MapReduceIterable
filter
in interface MapReduceIterable<TResult>
filter
- the filter to apply to the query.public MapReduceIterable<TResult> limit(int limit)
MapReduceIterable
limit
in interface MapReduceIterable<TResult>
limit
- the limit, which may be nullpublic MapReduceIterable<TResult> jsMode(boolean jsMode)
MapReduceIterable
jsMode
in interface MapReduceIterable<TResult>
jsMode
- the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and
reduce functionspublic MapReduceIterable<TResult> verbose(boolean verbose)
MapReduceIterable
verbose
in interface MapReduceIterable<TResult>
verbose
- whether to include the timing information in the result information.public MapReduceIterable<TResult> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
MapReduceIterable
maxTime
in interface MapReduceIterable<TResult>
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic MapReduceIterable<TResult> action(MapReduceAction action)
MapReduceIterable
MapReduceAction
to be used when writing to a collection.action
in interface MapReduceIterable<TResult>
action
- an MapReduceAction
to perform on the collectionpublic MapReduceIterable<TResult> databaseName(java.lang.String databaseName)
MapReduceIterable
databaseName
in interface MapReduceIterable<TResult>
databaseName
- the name of the database to output into.public MapReduceIterable<TResult> sharded(boolean sharded)
MapReduceIterable
sharded
in interface MapReduceIterable<TResult>
sharded
- if the output database is shardedpublic MapReduceIterable<TResult> nonAtomic(boolean nonAtomic)
MapReduceIterable
MapReduceAction.MERGE
or MapReduceAction.REDUCE
actions.nonAtomic
in interface MapReduceIterable<TResult>
nonAtomic
- if the post-processing step will prevent MongoDB from locking the database.public MapReduceIterable<TResult> batchSize(int batchSize)
MapReduceIterable
batchSize
in interface MapReduceIterable<TResult>
batchSize
in interface MongoIterable<TResult>
batchSize
- the batch sizepublic MapReduceIterable<TResult> bypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)
MapReduceIterable
Note: This only applies when an $out stage is specified
.bypassDocumentValidation
in interface MapReduceIterable<TResult>
bypassDocumentValidation
- If true, allows the write to opt-out of document level validation.public MapReduceIterable<TResult> collation(Collation collation)
MapReduceIterable
A null value represents the server default.
collation
in interface MapReduceIterable<TResult>
collation
- the collation options to usepublic MongoCursor<TResult> iterator()
iterator
in interface MongoIterable<TResult>
iterator
in interface java.lang.Iterable<TResult>
public TResult first()
MongoIterable
first
in interface MongoIterable<TResult>
public <U> MongoIterable<U> map(Function<TResult,U> mapper)
MongoIterable
map
in interface MongoIterable<TResult>
U
- the target document typemapper
- a function that maps from the source to the target document typepublic void forEach(Block<? super TResult> block)
MongoIterable
Similar to map
but the function is fully encapsulated with no returned result.
forEach
in interface MongoIterable<TResult>
block
- the block to apply to each document of type T.public <A extends java.util.Collection<? super TResult>> A into(A target)
MongoIterable
into
in interface MongoIterable<TResult>
A
- the collection typetarget
- the collection to insert intoMongoIterable<TResult> execute()
private MapReduceToCollectionOperation createMapReduceToCollectionOperation()
private BsonDocument toBsonDocument(Bson document)