public static AggregateArrayResults[] CreateArrayResults(Aggregate[] aggregates) { AggregateArrayResults[] aggResults = new AggregateArrayResults[aggregates.Length]; for (int i = 0; i < aggregates.Length; i++) { aggResults[i] = (AggregateArrayResults.Factory(aggregates[i].GetAggregateReturnType(), aggregates[i].GetFuncName())); } return(aggResults); }
protected override GroupByJob[] CreateSpecJobs(GroupByJob[] jobs, RowEqualityComparerInt equalityComparer, ITableResults resTable, int current, int addition) { var aggResults = AggregateArrayResults.CreateArrayResults(this.aggregates); var concurrentDictArrays = new ConcurrentDictionary <int, int>(equalityComparer); int capture = 0; Func <int, int> positionFactory = (int x) => { return(Interlocked.Increment(ref capture)); }; Semaphore semaphore = new Semaphore(this.ThreadCount, this.ThreadCount); for (int i = 0; i < jobs.Length - 1; i++) { jobs[i] = new GroupByJobArrays(concurrentDictArrays, this.aggregates, resTable, current, current + addition, aggResults, positionFactory, semaphore, jobs.Length); current += addition; } jobs[jobs.Length - 1] = new GroupByJobArrays(concurrentDictArrays, this.aggregates, resTable, current, resTable.NumberOfMatchedElements, aggResults, positionFactory, semaphore, jobs.Length); return(jobs); }