/// <summary> /// Aggregate the results of the parallel aggregations. /// </summary> /// <param name="results"> /// Results to aggregate. /// </param> /// <returns> /// The aggregation of the parallel aggregation results. /// </returns> public virtual object AggregateResults(ICollection results) { IParallelAwareAggregator aggregator = (IParallelAwareAggregator)m_aggregator; IDictionary dictionaryResult = new HashDictionary(); foreach (IDictionary dictPart in results) { // partial aggregation results are maps with distinct values // as keys and partial aggregation results as values foreach (DictionaryEntry entry in dictPart) { object distinct = entry.Key; object result = entry.Value; // collect all the aggregation results per group ICollection group = (ICollection)dictionaryResult[distinct]; if (group == null) { dictionaryResult.Add(distinct, group = new ArrayList()); } CollectionUtils.Add(group, result); } } IDictionary newResult = new HashDictionary(dictionaryResult); if (dictionaryResult.Count == 0) { // we need to call "AggregateResults" on the underlying // aggregator to fulfill our contract, even though any result // will be discarded aggregator.AggregateResults(NullImplementation.GetCollection()); } else { IFilter filter = m_filter; foreach (DictionaryEntry entry in dictionaryResult) { ICollection group = (ICollection)entry.Value; object result = aggregator.AggregateResults(group); if (filter == null || filter.Evaluate(result)) { newResult[entry.Key] = result; } else { newResult.Remove(entry.Key); } } } return(newResult); }
/// <summary> /// Construct a PriorityAggregator. /// </summary> /// <param name="aggregator"> /// The <see cref="IParallelAwareAggregator"/> wrapped by this /// PriorityAggregator. /// </param> public PriorityAggregator(IParallelAwareAggregator aggregator) { m_aggregator = aggregator; }
/// <summary> /// Construct a Parallel aggregator based on a specified /// <b>IValueExtractor</b> and underlying /// <b>IParallelAwareAggregator</b>. /// </summary> /// <param name="extractor"> /// An <b>IValueExtractor</b> object; may not be <c>null</c>. /// </param> /// <param name="aggregator"> /// An <b>IEntryAggregator</b> object; may not be <c>null</c>. /// </param> /// <param name="filter"> /// An <b>IFilter</b> object. /// </param> protected internal Parallel(IValueExtractor extractor, IParallelAwareAggregator aggregator, IFilter filter) : base(extractor, aggregator, filter) { }