Aggregates parsing results sequencially
972896
def aggregate(parsed_files)
      agr = Aggregator.new
      parsed_files.each do |file|
        Logger.log("Aggregating", file.filename)
        agr.aggregate(file)
      end
      agr.result
    end
290989
def get_aggregations_fields(cls, params):
        
        fields = []
        for key, val in params.items():
            if isinstance(val, dict):
                fields += cls.get_aggregations_fields(val)
            if key == 'field':
                fields.append(val)
        return fields
172541
function parseCollection (type, data, relations, options) {
  var result = []

  _.each(data, function (value) {
    result.push(parseResource(type, value, relations, options))
  })

  return result
}
1208220
def scan_aggs(search, source_aggs, inner_aggs={}, size=10):
    
    def run_search(**kwargs):
        s = search[:0]
        s.aggs.bucket('comp', 'composite', sources=source_aggs, size=size, **kwargs)
        for agg_name, agg in inner_aggs.items():
            s.aggs['comp'][agg_name] = agg
        return s.execute()

    response = run_search()
    while response.aggregations.comp.buckets:
        for b in response.aggregations.comp.buckets:
            yield b
        if 'after_key' in response.aggregations.comp:
            after = response.aggregations.comp.after_key
        else:
            after= response.aggregations.comp.buckets[-1].key
        response = run_search(after=after)
98335
function _aggregate(method, column) {
    this._statements.push({
      grouping: 'columns',
      type: 'aggregate',
      method: method,
      value: column
    });
    return this;
  }
1021842
function aggregateParams(_, pulse) {
  var key    = _.field,
  value  = _.value,
      op     = (_.op === 'count' ? '__count__' : _.op) || 'sum',
      fields = accessorFields(key).concat(accessorFields(value)),
      keys   = pivotKeys(key, _.limit || 0, pulse);

  return {
    key:      _.key,
    groupby:  _.groupby,
    ops:      keys.map(function() { return op; }),
    fields:   keys.map(function(k) { return get(k, key, value, fields); }),
    as:       keys.map(function(k) { return k + ''; }),
    modified: _.modified.bind(_)
  };
}
888426
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'key' in _dict:
            args['key'] = _dict.get('key')
        if 'matching_results' in _dict:
            args['matching_results'] = _dict.get('matching_results')
        if 'aggregations' in _dict:
            args['aggregations'] = [
                QueryAggregation._from_dict(x)
                for x in (_dict.get('aggregations'))
            ]
        return cls(**args)
235181
def aggregate_group_loop(*args, **kwargs):
    """"""
    func = kwargs['func']
    del kwargs['func']
    return aggregate_np(*args, func=lambda x: func(x), **kwargs)
289987
def aggregate(cls, pipeline=None, **kwargs):
        
        return list(cls.collection.aggregate(pipeline or [], **kwargs))
462006
function filterResults(results, maximum) {
  var filteredResults = []
  var indices = []
  var matrix = {}
  var column
  var key
  var score
  var interpolated
  var index
  var otherIndex
  var maxScore

  for (key in results) {
    score = results[key].score

    if (!matrix[score]) {
      matrix[score] = []
      indices.push(score)
    }

    matrix[score].push(results[key])
  }

  indices.sort(reverse)

  maxScore = indices[0]

  index = -1

  while (indices[++index]) {
    score = indices[index]
    column = matrix[score]

    interpolated = score / maxScore
    otherIndex = -1

    while (column[++otherIndex]) {
      column[otherIndex].score = interpolated
    }

    filteredResults = filteredResults.concat(column)

    if (filteredResults.length >= maximum) {
      break
    }
  }

  return filteredResults
}
939025
private Map<String, Object> toAggsMap(Map<String, Aggregation> fields) throws SqlParseException {
		Map<String, Object> result = new HashMap<>();
		for (Entry<String, Aggregation> entry : fields.entrySet()) {
			result.put(entry.getKey(), covenValue(entry.getValue()));
		}
		return result;
	}
1034831
function groupBy(collection, iteratee) {
    return collection.reduce(function (records, record) {
        var key = iteratee(record);
        if (records[key] === undefined) {
            records[key] = [];
        }
        records[key].push(record);
        return records;
    }, {});
}
751326
def aggregate(self, aggregates=None, drilldowns=None, cuts=None,
                  order=None, page=None, page_size=None, page_max=None):
        

        def prep(cuts, drilldowns=False, aggregates=False, columns=None):
            q = select(columns)
            bindings = []
            cuts, q, bindings = Cuts(self).apply(q, bindings, cuts)

            attributes = None
            if drilldowns is not False:
                attributes, q, bindings = Drilldowns(self).apply(
                    q,
                    bindings,
                    drilldowns
                )

            if aggregates is not False:
                aggregates, q, bindings = Aggregates(self).apply(
                    q,
                    bindings,
                    aggregates
                )

            q = self.restrict_joins(q, bindings)
            return q, bindings, attributes, aggregates, cuts

        # Count
        count = count_results(self, prep(cuts,
                                         drilldowns=drilldowns,
                                         columns=[1])[0])

        # Summary
        summary = first_result(self, prep(cuts,
                                          aggregates=aggregates)[0].limit(1))

        # Results
        q, bindings, attributes, aggregates, cuts = \
            prep(cuts, drilldowns=drilldowns, aggregates=aggregates)
        page, q = Pagination(self).apply(q, page, page_size, page_max)
        ordering, q, bindings = Ordering(self).apply(q, bindings, order)
        q = self.restrict_joins(q, bindings)

        cells = list(generate_results(self, q))

        return {
            'total_cell_count': count,
            'cells': cells,
            'summary': summary,
            'cell': cuts,
            'aggregates': aggregates,
            'attributes': attributes,
            'order': ordering,
            'page': page['page'],
            'page_size': page['page_size']
        }
615884
function getAggregationFields(query, aggParam, supplimentalBanList) {
    let retVal = [];
    const _aggParam = aggParam || 'aggregations';

    if (!query[_aggParam]) {
      return retVal;
    }
    const _supplimentalBanList = supplimentalBanList || {};

    _.each(query[_aggParam].split(','), (agg) => {
      assertAggNameIsAllowed(agg, _supplimentalBanList);
      _supplimentalBanList[agg] = true;
      let _type = query[`${agg}.type`];
      !_type && (_type = 'terms');
      const aggOptions = permittedAggOptions[_type];
      _.each(aggOptions, (aggOption) => {
        const expectedOptionName = `${agg}.${aggOption}`;
        retVal.push(expectedOptionName);
      });

      if (query[`${agg}.aggregations`]) {
        const nestedAggFields = getAggregationFields(query, `${agg}.aggregations`, _supplimentalBanList);
        retVal = retVal.concat(nestedAggFields);
      }
    });
    return retVal;
  }
98704
def aggregate!(ts = Time.now.floor)
      unless self.ancestors.include?MongoMapper::Document
        raise NoMethodError, "aggregate! not defined for this counter"
      end

      aggr = aggregate(ts)
      aggr.each do |_ts, counterVals|
        counterVals.each do |obj, count|
          args = gen_args_for_instance obj, count, _ts, TYPE_MINUTE
          counter = self.new args
          counter.save!
        end
      end
      call_completion_hook(TYPE_MINUTE, ts)
    end
397542
def GotAll(self, baseline, results):
    """"""
    num_base = len(baseline)
    num_rslt = len(results)
    if num_rslt > num_base:
      raise ProcessingError("Filter generated more results than base data: "
                            "%s > %s" % (num_rslt, num_base))
    if num_rslt == num_base and num_base > 0:
      return self.Issue("Found all", results)
    return []
817773
def ParseMultiple(self, result_dicts):
    """"""
    for result_dict in result_dicts:
      kb_user = rdf_client.User()
      for wmi_key, kb_key in iteritems(self.account_mapping):
        try:
          kb_user.Set(kb_key, result_dict[wmi_key])
        except KeyError:
          pass
      # We need at least a sid or a username.  If these are missing its likely
      # we retrieved just the userdomain for an AD account that has a name
      # collision with a local account that is correctly populated.  We drop the
      # bogus domain account.
      if kb_user.sid or kb_user.username:
        yield kb_user