String outputCollection = null;
if (params.get("out") instanceof DBObject) {
DBObject out = (DBObject) params.get("out");
if (out.get("sharded") != null) {
throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "sharded is not yet supported. Please remove it and run again");
}
if (out.get("replace") != null) {
if (out.get("nonAtomic") != null) {
throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "nonAtomic is not supported in replace mode. Please remove it and run again");
}
outputCollection = (String) out.get("replace");
outputDb = (String) out.get("db");
outputType = MapReduceCommand.OutputType.REPLACE;
} else if (out.get("merge") != null) {
outputCollection = (String) out.get("merge");
outputDb = (String) out.get("db");
outputType = MapReduceCommand.OutputType.INLINE;
} else if (out.get("reduce") != null) {
outputCollection = (String) out.get("reduce");
outputDb = (String) out.get("db");
outputType = MapReduceCommand.OutputType.INLINE;
} else if (out.get("inline") != null) {
outputType = MapReduceCommand.OutputType.INLINE;
if (out.get("nonAtomic") != null) {
throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "nonAtomic is not supported in inline mode. Please remove it and run again");
}
}
} else if (params.get("out") instanceof String) {
outputCollection = (String) params.get("out");
}
DBObject query = (DBObject) params.get("query");
DBObject sort = (DBObject) params.get("sort");
int limit = 0;
if (params.get("limit") != null) {
limit = (Integer) params.get("limit");
}
String finalize = (String) params.get("finalize");
Map scope = (Map) params.get("scope");
if (params.get("jsMode") != null) {
throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "jsMode is not yet supported. Please remove it and run again");
}
boolean verbose = true;
if (params.get("verbose") != null) {
verbose = (Boolean) params.get("verbose ");
}