protected OrderByResultProcessor(ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars)
 {
     this.comparers       = comparers;
     this.executionHelper = executionHelper;
     this.ColumnCount     = columnCount;
     this.usedVars        = usedVars;
 }
Beispiel #2
0
 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);
     }
 }
        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);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates an order by object.
        /// </summary>
        /// <param name="graph"> A graph the query is computed on. </param>
        /// <param name="variableMap"> A map of query variables. </param>
        /// <param name="executionHelper"> An order by execution helper. </param>
        /// <param name="orderByNode"> A parse tree of order by expression. </param>
        /// <param name="exprInfo"> A query expression information. </param>
        public OrderByObject(Graph graph, VariableMap variableMap, IOrderByExecutionHelper executionHelper, OrderByNode orderByNode, QueryExpressionInfo exprInfo)
        {
            if (executionHelper == null || orderByNode == null || variableMap == null || graph == null || exprInfo == null)
            {
                throw new ArgumentNullException($"{this.GetType()}, passing null arguments to the constructor.");
            }

            this.helper = executionHelper;

            var orderByVisitor = new OrderByVisitor(graph.labels, variableMap, exprInfo);

            orderByVisitor.Visit(orderByNode);
            var comps = orderByVisitor.GetResult();

            executionHelper.IsSetOrderBy = true;
            this.comparers = comps.ToArray();
        }
 public ABTreeGenSorterHalfStreamed(ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars) : base(comparers, executionHelper, columnCount, usedVars, false)
 {
 }
Beispiel #6
0
 public ABTreeAccumSorterStreamed(ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars) : base(comparers, executionHelper, columnCount, usedVars, true)
 {
 }
 /// <summary>
 /// Constructs Order by result processor.
 /// The suffix HS stands for Half Streamed solution, whereas the S stands for Full Streamed solution.
 /// </summary>
 public static ResultProcessor Factory(QueryExpressionInfo exprInfo, ExpressionComparer[] comparers, IOrderByExecutionHelper executionHelper, int columnCount, int[] usedVars)
 {
     if (executionHelper.SorterAlias == SorterAlias.AbtreeHS)
     {
         return(new ABTreeGenSorterHalfStreamed(comparers, executionHelper, columnCount, usedVars));
     }
     else if (executionHelper.SorterAlias == SorterAlias.AbtreeAccumHS)
     {
         return(new ABTreeAccumSorterHalfStreamed(comparers, executionHelper, columnCount, usedVars));
     }
     else if (executionHelper.SorterAlias == SorterAlias.AbtreeS)
     {
         var typeOfFirstKey = exprInfo.OrderByComparerExprs[0].GetExpressionType();
         if (typeOfFirstKey == typeof(int))
         {
             return(new ABTreeGenSorterStreamed <int>(comparers, executionHelper, columnCount, usedVars));
         }
         else if (typeOfFirstKey == typeof(string))
         {
             return(new ABTreeGenSorterStreamed <string>(comparers, executionHelper, columnCount, usedVars));
         }
         else
         {
             throw new ArgumentException($"Order by result processor factory, trying to create an unknown type of the streamed sorted.");
         }
     }
     else if (executionHelper.SorterAlias == SorterAlias.AbtreeAccumS)
     {
         var typeOfFirstKey = exprInfo.OrderByComparerExprs[0].GetExpressionType();
         if (typeOfFirstKey == typeof(int))
         {
             return(new ABTreeAccumSorterStreamed <int>(comparers, executionHelper, columnCount, usedVars));
         }
         else if (typeOfFirstKey == typeof(string))
         {
             return(new ABTreeAccumSorterStreamed <string>(comparers, executionHelper, columnCount, usedVars));
         }
         else
         {
             throw new ArgumentException($"Order by result processor factory, trying to create an unknown type of the streamed sorted.");
         }
     }
     else
     {
         throw new ArgumentException($"Order by result processor factory, trying to create an unknown sorter.");
     }
 }
        public static ExpressionComparer[] ParseOrderBy(Graph graph, VariableMap variableMap, IOrderByExecutionHelper executionHelper, OrderByNode orderByNode, QueryExpressionInfo exprInfo, int columnCount)
        {
            if (executionHelper == null || orderByNode == null || variableMap == null || graph == null || exprInfo == null)
            {
                throw new ArgumentNullException($"Order by result processor, passing null arguments to the constructor.");
            }

            var orderByVisitor = new OrderByVisitor(graph.labels, variableMap, exprInfo);

            orderByVisitor.Visit(orderByNode);
            var comps = orderByVisitor.GetResult();

            executionHelper.IsSetOrderBy = true;

            return(comps.ToArray());
        }