public class MapReduce extends AbstractAggregationOperation
represents a map reduce.
Author:
Andrea Di Cesare <andrea@softinstigate.com>
  • Field Details

  • Constructor Details

    • MapReduce

      public MapReduce(org.bson.BsonDocument properties) throws InvalidMetadataException
      Parameters:
      properties - the json properties object. It must include the following properties:
      • type
      • uri
      • map
      • reduce
      Optionally it can include the following property:
      • query
      Note that the dollar prefixed operators in the query must be underscore escaped, e.g. "_$exits"

      Example: aggregations: [ { "type":"mapReduce", "uri":"test", "map":"function() { emit(this.name, this.age) }", "reduce":"function(key, values) { return Array.avg(values) }", "query": {"name":{"_$exists":true}} }]

      Throws:
      InvalidMetadataException
  • Method Details

    • getMap

      public String getMap()
      Returns:
      the map
    • getReduce

      public String getReduce()
      Returns:
      the reduce
    • getQuery

      public org.bson.BsonValue getQuery()
      Returns:
      the query
    • getResolvedQuery

      public org.bson.BsonDocument getResolvedQuery(org.bson.BsonDocument aVars) throws InvalidMetadataException, QueryVariableNotBoundException
      Parameters:
      aVars - RequestContext.getAggregationVars()
      Returns:
      the query with unescaped operators and bound variables
      Throws:
      InvalidMetadataException
      QueryVariableNotBoundException
    • getResolvedMap

      public String getResolvedMap(org.bson.BsonDocument aVars)
      Parameters:
      aVars - RequestContext.getAggregationVars()
      Returns:
      the map function with bound aggregation variables
    • getResolvedReduce

      public String getResolvedReduce(org.bson.BsonDocument aVars)
      Parameters:
      aVars - RequestContext.getAggregationVars()
      Returns:
      the reduce function with bound aggregation variables