public ABTreeSorterHalfStreamed(ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars, bool allowDup) : base(comparers, executionHelper, columnCount, usedVars) { this.sortJobs = new SortJob[this.executionHelper.ThreadCount]; for (int i = 0; i < sortJobs.Length; i++) { var results = new TableResults(this.ColumnCount, this.executionHelper.FixedArraySize, this.usedVars); this.sortJobs[i] = CreateJob(new IndexToRowProxyComparer(RowComparer.Factory(this.comparers, true), results, allowDup), results); } }
/// <summary> /// Constructs multi column sorter. /// It comprises of row comparers wrapped inside an integer comparer. /// </summary> /// <param name="resTable"> A result table to sort. </param> /// <param name="expressionComparers"> Comparers for comparing rows in the table. </param> /// <param name="inParallel"> A flag if the table should be sorted in parallel. </param> public MultiColumnTableSorter(ITableResults resTable, ExpressionComparer[] expressionComparers, bool inParallel) : base(resTable, inParallel) { if (resTable == null || expressionComparers == null || expressionComparers.Length == 0) { throw new ArgumentNullException($"{this.GetType()}, trying to assign null to a construtor."); } var rowComparer = RowComparer.Factory(expressionComparers, !inParallel); this.indexComparer = new IndexToRowProxyComparer(rowComparer, resTable, true); }
public ABTreeStreamedSorter(ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars, bool allowDup) : base(comparers, executionHelper, columnCount, usedVars) { this.firstKeyHasher = (TypeRangeHasher <T>)TypeRangeHasher.Factory(this.executionHelper.ThreadCount, typeof(T)); this.firstKeyExpressionHolder = this.comparers[0].GetExpressionHolder(); this.firstKeyExpression = (ExpressionReturnValue <T>) this.firstKeyExpressionHolder.Expr; this.rangeBuckets = new RangeBucket[this.firstKeyHasher.BucketCount]; this.firstKeyComparers = new ExpressionComparer <T> [this.rangeBuckets.Length]; for (int i = 0; i < this.rangeBuckets.Length; i++) { var results = new TableResults(this.ColumnCount, this.executionHelper.FixedArraySize, this.usedVars); var tmpRowComparer = RowComparer.Factory(this.comparers, true); this.firstKeyComparers[i] = (ExpressionComparer <T>)tmpRowComparer.comparers[0]; this.rangeBuckets[i] = CreateBucket(new IndexToRowProxyComparer(tmpRowComparer, results, allowDup), results); } }
protected override void MergeResuls() { this.mergeJob = new MergeObjectRowProxy(this.sortJobs, RowComparer.Factory(this.comparers, false)); if (this.mergeJob.jobsToMerge.Length >= 2) { this.sortJobs = null; this.mergedResults = this.mergeJob.Merge(); } else if (this.mergeJob.jobsToMerge.Length == 1) { this.sortJobs = this.mergeJob.jobsToMerge; } else { this.sortJobs = new SortJob[] { this.sortJobs[0] } }; }