@Override
public Map<String, Object> requestMap(DBCollection<?> collection, QueryBuilder query) {
Map<String, Object> request = new LinkedHashMap<String, Object>();
request.put("mapreduce", collection.collectionName());
request.put("map", new Code(map));
request.put("reduce", new Code(reduce));
if (!query.build().isEmpty()) {
request.put("query", query.build());
}
if (!query.order().isEmpty()) {
request.put("sort", query.order());
}
if (query.limit() > 0) {
request.put("limit", query.limit());
}
if (outputCollection != null) {
request.put("out", outputCollection);
}
if (keepTemp != null) {
request.put("keeptemp", keepTemp);
}
if (finalizeFunction != null) {
request.put("finalize", new Code(finalizeFunction));
}
if (verbose != null) {
request.put("verbose", verbose);
}
return request;