Beispiel #1
0
        private BoundRelation PushOverSort(BoundFilterRelation node, BoundSortRelation input)
        {
            var newFilter = RewriteRelation(node.Update(input.Input, node.Condition));
            var newInput  = input.Update(input.IsDistinct, newFilter, input.SortedValues);

            return(newInput);
        }
        private Iterator BuildSort(BoundSortRelation relation)
        {
            var input = BuildRelation(relation.Input);
            var inputRowBufferAllocation = BuildRowBufferAllocation(relation.Input, input.RowBuffer);
            var sortEntries = relation.SortedValues
                              .Select(v => inputRowBufferAllocation[v.ValueSlot])
                              .ToImmutableArray();
            var comparers = relation.SortedValues.Select(v => v.Comparer).ToImmutableArray();

            return(relation.IsDistinct
                ? new DistinctSortIterator(input, sortEntries, comparers)
                : new SortIterator(input, sortEntries, comparers));
        }
Beispiel #3
0
        protected override BoundRelation RewriteSortRelation(BoundSortRelation node)
        {
            var newInput = RewriteRelation(node.Input);

            if (newInput is BoundFilterRelation filter)
            {
                node = node.Update(node.IsDistinct, filter.Input, node.SortedValues);
                return(filter.WithInput(node));
            }
            else
            {
                return(node.WithInput(newInput));
            }
        }
        protected override BoundRelation RewriteIntersectOrExceptRelation(BoundIntersectOrExceptRelation node)
        {
            var left  = RewriteRelation(node.Left);
            var right = RewriteRelation(node.Right);

            var values       = left.GetOutputValues();
            var sortedValues = values.Zip(node.Comparers, (v, c) => new BoundComparedValue(v, c));
            var sortedLeft   = new BoundSortRelation(true, left, sortedValues);

            var valueSlots = sortedLeft.GetOutputValues().Zip(right.GetOutputValues(), ValueTuple.Create);
            var condition  = CreatePredicate(valueSlots);

            var joinOperator = node.IsIntersect
                ? BoundJoinType.LeftSemi
                : BoundJoinType.LeftAntiSemi;

            return(new BoundJoinRelation(joinOperator, sortedLeft, right, condition, null, null));
        }
 private static CardinalityEstimate EstimateSortRelation(BoundSortRelation relation)
 {
     return(Estimate(relation.Input));
 }
Beispiel #6
0
        protected override BoundRelation RewriteSortRelation(BoundSortRelation node)
        {
            _recorder.Record(node.SortedValues);

            return(base.RewriteSortRelation(node));
        }