Example usage for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getOutputSharded

List of usage examples for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getOutputSharded

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.mapreduce MapReduceOptions getOutputSharded.

Prototype

public Optional<Boolean> getOutputSharded() 

Source Link

Usage

From source file:org.springframework.data.mongodb.core.MongoTemplate.java

private DBObject copyMapReduceOptions(MapReduceOptions mapReduceOptions, MapReduceCommand command) {
    if (mapReduceOptions.getJavaScriptMode() != null) {
        command.addExtraOption("jsMode", true);
    }//from w  ww  .java2s.c  o m
    if (!mapReduceOptions.getExtraOptions().isEmpty()) {
        for (Map.Entry<String, Object> entry : mapReduceOptions.getExtraOptions().entrySet()) {
            command.addExtraOption(entry.getKey(), entry.getValue());
        }
    }
    if (mapReduceOptions.getFinalizeFunction() != null) {
        command.setFinalize(this.replaceWithResourceIfNecessary(mapReduceOptions.getFinalizeFunction()));
    }
    if (mapReduceOptions.getOutputDatabase() != null) {
        command.setOutputDB(mapReduceOptions.getOutputDatabase());
    }
    if (!mapReduceOptions.getScopeVariables().isEmpty()) {
        command.setScope(mapReduceOptions.getScopeVariables());
    }

    DBObject commandObject = command.toDBObject();
    DBObject outObject = (DBObject) commandObject.get("out");

    if (mapReduceOptions.getOutputSharded() != null) {
        outObject.put("sharded", mapReduceOptions.getOutputSharded());
    }
    return commandObject;
}