<editor-fold defaultstate="collapsed" desc="Aggregates">
777878
public function count()
    {
        if($this->elements instanceof \Countable) {
            return $this->elements->count();
        }

        $count = 0;

        foreach($this->elements as $value) {
            $count++;
        }

        return $count;
    }
856466
private static <K, V> List<V> aggregateCacheValues(Map<K, CacheValue<V>> map) {
    List<V> values = new ArrayList<>(map.size());
    for (Map.Entry<K, CacheValue<V>> entry : map.entrySet()) {
      values.add(entry.getValue().getValue());
    }
    return values;
  }
543397
public AggregationResult aggregate(String fields) throws DDFException {
    return this.getAggregationHandler().aggregate(AggregateField.fromSqlFieldSpecs(fields));
  }
1027956
function (aggregate, cmd) {
    if (!aggregate || !_.isObject(aggregate)) {
      var err = new Error('Please pass a valid aggregate!');
      debug(err);
      throw err;
    }
    if (!cmd || !_.isObject(cmd)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      throw err;
    }

    var contextName, aggregateName, aggregateId;

    if (!!this.definitions.command.context) {
      contextName = dotty.get(cmd, this.definitions.command.context);
    }

    if (!!this.definitions.command.aggregate) {
      aggregateName = dotty.get(cmd, this.definitions.command.aggregate);
    }

    if (!!this.definitions.command.aggregateId) {
      aggregateId = dotty.get(cmd, this.definitions.command.aggregateId);
    }

    var streamInfo = {
      context: contextName,
      aggregate: aggregateName,
      aggregateId: aggregateId
    };

    if (aggregate.isDestroyed()) {
      return new AggregateDestroyedError('Aggregate has already been destroyed!', {
        aggregateId: aggregate.id,
        aggregateRevision: aggregate.getRevision(streamInfo)
      });
    }

    return null;
  }
749542
def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None,
                 AggList=None, interspersed=True):
        
        data = spreadsheet.aggregate_in(Data=self, On=On, 
               AggFuncDict=AggFuncDict, AggFunc=AggFunc, 
               AggList = AggList, interspersed=interspersed)
        data = data.view(tabarray)
        data.view = self.coloring
        return data
378241
public void setEntityAggregates(java.util.Collection<EntityAggregate> entityAggregates) {
        if (entityAggregates == null) {
            this.entityAggregates = null;
            return;
        }

        this.entityAggregates = new java.util.ArrayList<EntityAggregate>(entityAggregates);
    }
190035
void addSubAggs(QueryConverter queryConverter, Aggregation agg, AggregationBuilder builder) {
        Map<String, Aggregation> aggs = agg.getAggs();
        for (String key : aggs.keySet()) {
            Aggregation subAgg = aggs.get(key);
            AbstractAggregationBuilder subBuilder = queryConverter.converterAggregation(subAgg);
            if (subBuilder != null) {
                builder.subAggregation(subBuilder);
            }
        }
    }
496555
public void setProductViewAggregations(java.util.Map<String, java.util.List<ProductViewAggregationValue>> productViewAggregations) {
        this.productViewAggregations = productViewAggregations;
    }
193449
public static <K, V> Map<K, V> aggregate(Map<K, V> map1, Map<K, V> map2) {
        return new AggregatingMap<K, V>(map1, map2);
    }
946647
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList =
                  None, returnsort=False,KeepOthers=True, keyfuncdict=None):
        
        if returnsort:
            [data, s] = spreadsheet.aggregate(X=self, 
                     On=On, 
                     AggFuncDict=AggFuncDict, 
                     AggFunc=AggFunc, 
                     AggList=AggList, 
                     returnsort=returnsort, 
                     keyfuncdict=keyfuncdict)
        else:
            data = spreadsheet.aggregate(X=self, On=On, AggFuncDict=AggFuncDict, 
                     AggFunc=AggFunc, AggList = AggList, returnsort=returnsort, 
                     KeepOthers=KeepOthers,
                     keyfuncdict=keyfuncdict)
        data = data.view(tabarray)
        data.coloring = self.coloring
        if returnsort:
            return [data, s]
        else:
            return data
16271
static Map<String, Object> sumOfDelta(Map<String, Object> state, Map<String, Object> delta) {
        InstanceKey instanceId = (InstanceKey) delta.get("InstanceKey");
        if (instanceId == null) {
            throw new RuntimeException("InstanceKey can not be null");
        }
        for (String key : delta.keySet()) {
            Object existing = state.get(key);
            Object current = delta.get(key);
            if (current instanceof Number) {
                if (existing == null) {
                    existing = 0;
                }
                Number v = (Number) existing;
                Number d = (Number) delta.get(key);
                state.put(key, v.longValue() + d.longValue());
            } else if (current instanceof NumberList) {
                if (existing == null) {
                    state.put(key, current);
                } else {
                    state.put(key, ((NumberList) existing).sum((NumberList) current));
                }
            } else {
                Object o = delta.get(key);
                if (o instanceof String[]) {
                    String[] vs = (String[]) o;
                    if (vs.length == 1) {
                        Object previousAggregateString = state.get(key);
                        if (previousAggregateString instanceof AggregateString) {
                            state.put(key, ((AggregateString) previousAggregateString).update(null, vs[0], instanceId));
                        } else {
                            state.put(key, AggregateString.create(vs[0], instanceId));
                        }
                    } else {
                        // it should always be AggregateString here since that's all we add above
                        AggregateString pas = (AggregateString) state.get(key);
                        state.put(key, pas.update(vs[0], vs[1], instanceId));
                    }
                } else {
                    state.put(key, String.valueOf(o));
                }

            }
        }
        return state;
    }
771581
public void aggregateValue(TridentTuple tuple) {
        K key = mapper.getKey(tuple);
        V value = mapper.getValue(tuple);
        V currentValue = aggregateValues.get(key);
        V newValue;
        if (currentValue == null) {
            newValue = aggregator.init(tuple);
        } else {
            newValue = aggregator.combine(currentValue, value);
        }
        LOG.debug("Updating state [{}] ==> [{}]", new Object[]{key, newValue});
        aggregateValues.put(key, newValue);
    }
178455
private void buildAggregation(DBObject group, Expression expression, EntityMetadata metadata, EntityType entityType,
            boolean hasLob)
    {
        if (expression instanceof AggregateFunction)
        {
            AggregateFunction aggregateFunction = (AggregateFunction) expression;
            String identifier = aggregateFunction.getIdentifier().toLowerCase();

            Expression child = aggregateFunction.getExpression();

            if (child instanceof StateFieldPathExpression)
            {
                StateFieldPathExpression sfpExp = (StateFieldPathExpression) child;
                String columnName = getColumnName(metadata, entityType, sfpExp.toActualText());
                String actualColumnName = columnName;
                if (hasLob)
                {
                    actualColumnName = "metadata." + columnName;
                }
                else if (metadata.getIdAttribute().equals(entityType.getAttribute(metadata.getFieldName(columnName))))
                {
                    actualColumnName = "_id";
                }

                BasicDBObject item = new BasicDBObject("$" + identifier, "$" + actualColumnName);
                group.put(identifier + "_" + columnName, item);
            }
            else if (expression instanceof CountFunction)
            {
                group.put("count", new BasicDBObject("$sum", 1));
            }
        }
        else if (expression instanceof CollectionExpression)
        {
            for (Expression child : expression.children())
            {
                buildAggregation(group, child, metadata, entityType, hasLob);
            }
        }
        else if (expression instanceof StateFieldPathExpression)
        {
            StateFieldPathExpression sfpExp = (StateFieldPathExpression) expression;

            BasicDBObject idObject;
            Object existing = group.get("_id");
            if (existing != null)
            {
                idObject = (BasicDBObject) existing;
            }
            else
            {
                idObject = new BasicDBObject();
                group.put("_id", idObject);
            }

            String columnName = getColumnName(metadata, entityType, sfpExp.toActualText());
            String actualColumnName = columnName;
            if (hasLob)
            {
                actualColumnName = "metadata." + columnName;
            }

            idObject.put(columnName, "$" + actualColumnName);
        }
    }
860976
public void setAggregateComplianceByConfigRules(java.util.Collection<AggregateComplianceByConfigRule> aggregateComplianceByConfigRules) {
        if (aggregateComplianceByConfigRules == null) {
            this.aggregateComplianceByConfigRules = null;
            return;
        }

        this.aggregateComplianceByConfigRules = new com.amazonaws.internal.SdkInternalList<AggregateComplianceByConfigRule>(aggregateComplianceByConfigRules);
    }
398548
function AggregateModel (id, modelInitValues) {
  if (!id || !_.isString(id)) {
    var err = new Error('No id injected!');
    debug(err);
    throw err;
  }

  this.id = id;

  if (modelInitValues instanceof AggregateModel) {
    this.attributes = modelInitValues.toJSON();
  } else {
    this.attributes = _.cloneDeep(modelInitValues || {});
  }

  this.attributes.id = this.id;
  this.attributes._destroyed = this.attributes._destroyed || false;
  this.attributes._revisions = this.attributes._revisions || {};
  this.attributes._revision = this.attributes._revision || 0;

  this.uncommittedEvents = [];
}
457178
protected void aggregateEntry(Entry other, long currentTime,
            double negLambda) {
        this.data.aggregate(other.data, currentTime - this.timestamp,
                negLambda);
        this.timestamp = currentTime;
    }
1357392
function (aggregate) {
    if (!aggregate || !_.isObject(aggregate)) {
      var err = new Error('Please pass a valid aggregate!');
      debug(err);
      throw err;
    }
    this.aggregate = aggregate;
  }