Esempio n. 1
0
		private static AlgebraNode NullScanIfInputIsNullScan(UnaryAlgebraNode algebraNode)
		{
			if (algebraNode.Input is NullScanAlgebraNode)
				return CreateNullScan(algebraNode.OutputList);

			return algebraNode;
		}
Esempio n. 2
0
        private AlgebraNode PushOverUnary(ComputeScalarAlgebraNode node)
        {
            UnaryAlgebraNode inputNode = (UnaryAlgebraNode)node.Input;

            node.Input      = inputNode.Input;
            inputNode.Input = VisitAlgebraNode(node);
            return(inputNode);
        }
Esempio n. 3
0
		private AlgebraNode ReturnInputIfItProducesJustOneRow(UnaryAlgebraNode node)
		{
			node.Input = VisitAlgebraNode(node.Input);
            
			if (AstUtil.WillProduceAtMostOneRow(node.Input))
				return node.Input;
            
			return node;
		}
Esempio n. 4
0
        private static AlgebraNode NullScanIfInputIsNullScan(UnaryAlgebraNode algebraNode)
        {
            if (algebraNode.Input is NullScanAlgebraNode)
            {
                return(CreateNullScan(algebraNode.OutputList));
            }

            return(algebraNode);
        }
        private AlgebraNode ReturnInputIfItProducesJustOneRow(UnaryAlgebraNode node)
        {
            node.Input = VisitAlgebraNode(node.Input);

            if (AstUtil.WillProduceAtMostOneRow(node.Input))
            {
                return(node.Input);
            }

            return(node);
        }
Esempio n. 6
0
		private AlgebraNode PullFilterUp(UnaryAlgebraNode unaryAlgebraNode)
		{
			unaryAlgebraNode.Input = VisitAlgebraNode(unaryAlgebraNode.Input);

			FilterAlgebraNode filterAlgebraNode = unaryAlgebraNode.Input as FilterAlgebraNode;
			if (filterAlgebraNode == null)
			{
				return unaryAlgebraNode;
			}
			else
			{
				unaryAlgebraNode.Input = filterAlgebraNode.Input;
				filterAlgebraNode.Input = unaryAlgebraNode;
				return filterAlgebraNode;
			}
		}
Esempio n. 7
0
        private AlgebraNode PullFilterUp(UnaryAlgebraNode unaryAlgebraNode)
        {
            unaryAlgebraNode.Input = VisitAlgebraNode(unaryAlgebraNode.Input);

            FilterAlgebraNode filterAlgebraNode = unaryAlgebraNode.Input as FilterAlgebraNode;

            if (filterAlgebraNode == null)
            {
                return(unaryAlgebraNode);
            }
            else
            {
                unaryAlgebraNode.Input  = filterAlgebraNode.Input;
                filterAlgebraNode.Input = unaryAlgebraNode;
                return(filterAlgebraNode);
            }
        }
Esempio n. 8
0
        private AlgebraNode PushOverValueDefininingUnary(IEnumerable <ValueDefinition> definedValues, FilterAlgebraNode node)
        {
            UnaryAlgebraNode      inputNode            = (UnaryAlgebraNode)node.Input;
            List <ExpressionNode> nonDependingAndParts = new List <ExpressionNode>();
            List <ExpressionNode> dependingAndParts    = new List <ExpressionNode>();

            foreach (ExpressionNode andPart in AstUtil.SplitCondition(LogicalOperator.And, node.Predicate))
            {
                RowBufferEntry[] rowBufferEntries = AstUtil.GetRowBufferEntryReferences(andPart);

                bool dependsOnDefinedValue = false;
                foreach (ValueDefinition definedValue in definedValues)
                {
                    if (ArrayHelpers.Contains(rowBufferEntries, definedValue.Target))
                    {
                        dependsOnDefinedValue = true;
                        break;
                    }
                }

                if (dependsOnDefinedValue)
                {
                    dependingAndParts.Add(andPart);
                }
                else
                {
                    nonDependingAndParts.Add(andPart);
                }
            }

            if (nonDependingAndParts.Count > 0)
            {
                node.Predicate  = AstUtil.CombineConditions(LogicalOperator.And, dependingAndParts);
                inputNode.Input = GetFilterFromAndParts(nonDependingAndParts, inputNode.Input);

                if (node.Predicate == null)
                {
                    node.Input      = inputNode.Input;
                    inputNode.Input = VisitAlgebraNode(node);
                    return(inputNode);
                }
            }

            node.Input = VisitAlgebraNode(node.Input);
            return(node);
        }