Class MapReduce
- java.lang.Object
-
- org.restheart.mongodb.handlers.aggregation.AbstractAggregationOperation
-
- org.restheart.mongodb.handlers.aggregation.MapReduce
-
public class MapReduce extends AbstractAggregationOperation
represents a map reduce.- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.restheart.mongodb.handlers.aggregation.AbstractAggregationOperation
AbstractAggregationOperation.TYPE
-
-
Field Summary
Fields Modifier and Type Field Description static StringMAP_ELEMENT_NAMEstatic StringQUERY_ELEMENT_NAMEstatic StringREDUCE_ELEMENT_NAME-
Fields inherited from class org.restheart.mongodb.handlers.aggregation.AbstractAggregationOperation
AGGREGATIONS_ELEMENT_NAME, TYPE_ELEMENT_NAME, URI_ELEMENT_NAME
-
-
Constructor Summary
Constructors Constructor Description MapReduce(org.bson.BsonDocument properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetMap()org.bson.BsonValuegetQuery()StringgetReduce()StringgetResolvedMap(org.bson.BsonDocument aVars)org.bson.BsonDocumentgetResolvedQuery(org.bson.BsonDocument aVars)StringgetResolvedReduce(org.bson.BsonDocument aVars)-
Methods inherited from class org.restheart.mongodb.handlers.aggregation.AbstractAggregationOperation
bindAggregationVariables, checkAggregationVariables, getFromJson, getType, getUri
-
-
-
-
Field Detail
-
MAP_ELEMENT_NAME
public static final String MAP_ELEMENT_NAME
- See Also:
- Constant Field Values
-
REDUCE_ELEMENT_NAME
public static final String REDUCE_ELEMENT_NAME
- See Also:
- Constant Field Values
-
QUERY_ELEMENT_NAME
public static final String QUERY_ELEMENT_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapReduce
public MapReduce(org.bson.BsonDocument properties) throws InvalidMetadataException- Parameters:
properties- the json properties object. It must include the following properties:typeurimapreduce
query
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 Detail
-
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:
InvalidMetadataExceptionQueryVariableNotBoundException
-
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
-
-