List of usage examples for com.mongodb MapReduceOutput getDuration
public int getDuration()
From source file:fr.gouv.vitam.mdbes.MainMapReduce.java
License:Open Source License
protected static void oneShot(MongoDbAccess dbvitam) throws InvalidParseOperationException, InvalidExecOperationException, InstantiationException, IllegalAccessException { // Requesting if (map == null) { map = "function() {" + "flattened = serializeDocFiltered(this, MAXDEPTH, FILTER);" + "for (var key in flattened) {" + "var value = flattened[key];" + "var valueType = varietyTypeOf(value);" + "var finalvalue = { types : [ valueType ], occurences : 1};" // + "var finalvalue = { occurences : 1};" + "emit(key, finalvalue); } }"; }/*from ww w . ja v a 2s .co m*/ if (reduce == null) { reduce = "function(key,values) {" + "var typeset = new Set();" + "var occur = 0;" + "for (var idx = 0; idx < values.length; idx++) {" + "occur += values[idx].occurences;" + "typeset.add(values[idx].types);" + "} return { types : typeset.asArray(), occurences : occur }; }"; // + "} return { occurences : occur }; }"; } if (output == null) { output = "AttributeUsage"; } MapReduceCommand mapReduceCommand = new MapReduceCommand(dbvitam.daips.collection, map, reduce, output, OutputType.REDUCE, new BasicDBObject()); if (options != null) { String[] optionsArray = options.split(","); Map<String, Object> mapScope = new HashMap<String, Object>(); for (String string : optionsArray) { String[] kv = string.split("="); mapScope.put(kv[0], getParsedString(kv[1])); } mapReduceCommand.setScope(mapScope); } else { Map<String, Object> mapScope = new HashMap<String, Object>(); mapScope.put("MAXDEPTH", 5); mapScope.put("FILTER", "_dds"); mapReduceCommand.setScope(mapScope); } mapReduceCommand.addExtraOption("nonAtomic", true); mapReduceCommand.addExtraOption("jsMode", true); MapReduceOutput output = dbvitam.daips.collection.mapReduce(mapReduceCommand); System.out.println("Duration: " + output.getDuration() + " Saved into: " + output.getCollectionName() + " Input: " + output.getInputCount() + " Emit: " + output.getEmitCount() + " Output: " + output.getOutputCount() + "\nCmd: " + output.getCommand()); Iterable<DBObject> iterable = output.results(); for (DBObject dbObject : iterable) { System.out.println(dbObject.toString()); } }
From source file:org.springframework.data.mongodb.core.mapreduce.MapReduceResults.java
License:Apache License
private static MapReduceTiming parseTiming(MapReduceOutput mapReduceOutput) { return new MapReduceTiming(-1, -1, mapReduceOutput.getDuration()); }