Example #1
0
        private Iterator BuildJoin(BoundJoinRelation relation)
        {
            var left = BuildRelation(relation.Left);

            _outerRowBufferAllocation = BuildRowBufferAllocation(relation.Left, left.RowBuffer);

            var right = BuildRelation(relation.Right);
            var combinedAllocation = BuildRowBufferAllocation(relation.Right, right.RowBuffer);

            _outerRowBufferAllocation = _outerRowBufferAllocation.Parent;

            var predicate = BuildPredicate(relation.Condition, true, combinedAllocation);

            var passthruPredicate = BuildPredicate(relation.PassthruPredicate, false, combinedAllocation);

            switch (relation.JoinType)
            {
            case BoundJoinType.Inner:
                Debug.Assert(relation.Probe == null);
                return(new InnerNestedLoopsIterator(left, right, predicate, passthruPredicate));

            case BoundJoinType.LeftSemi:
                return(relation.Probe == null
                        ? (Iterator) new LeftSemiNestedLoopsIterator(left, right, predicate, passthruPredicate)
                        : new ProbingLeftSemiNestedLoopsIterator(left, right, predicate));

            case BoundJoinType.LeftAntiSemi:
                Debug.Assert(relation.Probe == null);
                return(new LeftAntiSemiNestedLoopsIterator(left, right, predicate, passthruPredicate));

            case BoundJoinType.LeftOuter:
                return(new LeftOuterNestedLoopsIterator(left, right, predicate, passthruPredicate));

            default:
                throw ExceptionBuilder.UnexpectedValue(relation.JoinType);
            }
        }
Example #2
0
 public RowBufferAllocation(RowBufferAllocation parent, RowBuffer rowBuffer, IEnumerable <ValueSlot> valueSlots)
 {
     Parent    = parent;
     RowBuffer = rowBuffer;
     _mapping  = GetValueMapping(valueSlots.ToImmutableArray());
 }
Example #3
0
        private static TDelegate BuildExpression <TDelegate>(BoundExpression expression, Type targetType, RowBufferAllocation allocation)
        {
            var builder = new ExpressionBuilder(allocation);

            return(builder.BuildExpression <TDelegate>(expression, targetType));
        }
Example #4
0
        public static IteratorPredicate BuildIteratorPredicate(BoundExpression predicate, bool nullValue, RowBufferAllocation allocation)
        {
            if (predicate == null)
            {
                return(() => nullValue);
            }

            return(BuildExpression <IteratorPredicate>(predicate, typeof(bool), allocation));
        }
Example #5
0
 public static IteratorFunction BuildIteratorFunction(BoundExpression expression, RowBufferAllocation allocation)
 {
     return(BuildExpression <IteratorFunction>(expression, typeof(object), allocation));
 }
Example #6
0
 private ExpressionBuilder(RowBufferAllocation allocation)
 {
     _rowBufferAllocation = allocation;
 }
Example #7
0
 private static IteratorPredicate BuildPredicate(BoundExpression predicate, bool nullValue, RowBufferAllocation allocation)
 {
     return(ExpressionBuilder.BuildIteratorPredicate(predicate, nullValue, allocation));
 }
Example #8
0
 private static IteratorFunction BuildFunction(BoundExpression expression, RowBufferAllocation allocation)
 {
     return(ExpressionBuilder.BuildIteratorFunction(expression, allocation));
 }