Ejemplo n.º 1
0
        public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node)
        {
            StreamAggregateIterator streamAggregateIterator = new StreamAggregateIterator();

            streamAggregateIterator.RowBuffer   = new object[node.OutputList.Length];
            streamAggregateIterator.Input       = ConvertAlgebraNode(node.Input);
            streamAggregateIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);

            BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(streamAggregateIterator.Input.RowBuffer, node.Input.OutputList);

            if (node.Groups == null)
            {
                streamAggregateIterator.GroupByEntries = new IteratorInput[0];
                streamAggregateIterator.DefinedValues  = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);
            }
            else
            {
                streamAggregateIterator.GroupByEntries = GetIteratorInput(node.Input.OutputList, node.Groups);
                streamAggregateIterator.DefinedValues  = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);
            }

            SetLastIterator(node, streamAggregateIterator);

            return(node);
        }
Ejemplo n.º 2
0
        public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node)
        {
            string message;

            switch (node.AssertionType)
            {
            case AssertionType.MaxOneRow:
                message = Resources.SubqueryReturnedMoreThanRow;
                break;

            case AssertionType.BelowRecursionLimit:
                message = Resources.MaximumRecursionLevelExceeded;
                break;

            default:
                throw ExceptionBuilder.UnhandledCaseLabel(node.AssertionType);
            }

            AssertIterator assertIterator = new AssertIterator();

            assertIterator.RowBuffer   = new object[node.OutputList.Length];
            assertIterator.Input       = ConvertAlgebraNode(node.Input);
            assertIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
            assertIterator.Message     = message;

            BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(assertIterator.Input.RowBuffer, node.Input.OutputList);

            assertIterator.Predicate = CreateRuntimeExpression(node.Predicate, boundRowBufferEntrySet);
            SetLastIterator(node, assertIterator);

            return(node);
        }
Ejemplo n.º 3
0
 private void UpdatePredicateRowBufferReferences(HashMatchIterator hashMatchIterator, HashMatchAlgebraNode node)
 {
     if (node.ProbeResidual != null)
     {
         BoundRowBufferEntrySet leftBoundRowBufferEntrySet  = new BoundRowBufferEntrySet(hashMatchIterator.Left.RowBuffer, node.Left.OutputList);
         BoundRowBufferEntrySet rightBoundRowBufferEntrySet = new BoundRowBufferEntrySet(hashMatchIterator.Right.RowBuffer, node.Right.OutputList);
         hashMatchIterator.ProbeResidual = CreateRuntimeExpression(node.ProbeResidual, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);
     }
 }
Ejemplo n.º 4
0
        public override AlgebraNode VisitFilterAlgebraNode(FilterAlgebraNode node)
        {
            FilterIterator filterIterator = new FilterIterator();

            filterIterator.RowBuffer   = new object[node.OutputList.Length];
            filterIterator.Input       = ConvertAlgebraNode(node.Input);
            filterIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
            BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(filterIterator.Input.RowBuffer, node.Input.OutputList);

            filterIterator.Predicate = CreateRuntimeExpression(node.Predicate, boundRowBufferEntrySet);
            SetLastIterator(node, filterIterator);

            return(node);
        }
Ejemplo n.º 5
0
        private void UpdatePredicateRowBufferReferences(NestedLoopsIterator nestedLoopsIterator, JoinAlgebraNode node)
        {
            BoundRowBufferEntrySet leftBoundRowBufferEntrySet  = new BoundRowBufferEntrySet(nestedLoopsIterator.Left.RowBuffer, node.Left.OutputList);
            BoundRowBufferEntrySet rightBoundRowBufferEntrySet = new BoundRowBufferEntrySet(nestedLoopsIterator.Right.RowBuffer, node.Right.OutputList);

            if (node.Predicate != null)
            {
                nestedLoopsIterator.Predicate = CreateRuntimeExpression(node.Predicate, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);
            }

            if (node.PassthruPredicate != null)
            {
                nestedLoopsIterator.PassthruPredicate = CreateRuntimeExpression(node.PassthruPredicate, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);
            }
        }
Ejemplo n.º 6
0
        public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node)
        {
            ComputeScalarIterator computeScalarIterator = new ComputeScalarIterator();

            computeScalarIterator.RowBuffer   = new object[node.OutputList.Length];
            computeScalarIterator.Input       = ConvertAlgebraNode(node.Input);
            computeScalarIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);

            BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(computeScalarIterator.Input.RowBuffer, node.Input.OutputList);

            computeScalarIterator.DefinedValues = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);

            SetLastIterator(node, computeScalarIterator);

            return(node);
        }
Ejemplo n.º 7
0
        public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node)
        {
            IndexSpoolIterator indexSpoolIterator = new IndexSpoolIterator();

            indexSpoolIterator.RowBuffer   = new object[node.OutputList.Length];
            indexSpoolIterator.Input       = ConvertAlgebraNode(node.Input);
            indexSpoolIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
            indexSpoolIterator.IndexEntry  = GetIteratorInput(node.Input.OutputList, new RowBufferEntry[] { node.IndexEntry })[0];

            BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(indexSpoolIterator.Input.RowBuffer, node.Input.OutputList);

            indexSpoolIterator.ProbeExpression = CreateRuntimeExpression(node.ProbeExpression, boundRowBufferEntrySet);

            SetLastIterator(node, indexSpoolIterator);

            return(node);
        }
Ejemplo n.º 8
0
        private void PushOuterReferences(object[] rowBuffer, JoinAlgebraNode node)
        {
            if (node.OuterReferences != null && node.OuterReferences.Length > 0)
            {
                // Important: We cannot use node.OuterReferences as argument for BoundRowBufferEntrySet().
                // The replacment strategy below will replace occurences to the entries by their index
                // within the array. Therefore we need an array with the same layout as the row buffer.

                RowBufferEntry[] outerReferences = new RowBufferEntry[node.Left.OutputList.Length];
                for (int i = 0; i < outerReferences.Length; i++)
                {
                    if (ArrayHelpers.Contains(node.OuterReferences, node.Left.OutputList[i]))
                    {
                        outerReferences[i] = node.Left.OutputList[i];
                    }
                }

                BoundRowBufferEntrySet bufferEntrySet = new BoundRowBufferEntrySet(rowBuffer, outerReferences);
                _outerReferenceStack.Push(bufferEntrySet);
            }
        }
Ejemplo n.º 9
0
		public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node)
		{
			string message;
			switch(node.AssertionType)
			{
				case AssertionType.MaxOneRow:
					message = Resources.SubqueryReturnedMoreThanRow;
					break;
				case AssertionType.BelowRecursionLimit:
					message = Resources.MaximumRecursionLevelExceeded;
					break;
				default:
					throw ExceptionBuilder.UnhandledCaseLabel(node.AssertionType);
			}

			AssertIterator assertIterator = new AssertIterator();
			assertIterator.RowBuffer = new object[node.OutputList.Length];
			assertIterator.Input = ConvertAlgebraNode(node.Input);
			assertIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
			assertIterator.Message = message;

			BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(assertIterator.Input.RowBuffer, node.Input.OutputList);
			assertIterator.Predicate = CreateRuntimeExpression(node.Predicate, boundRowBufferEntrySet);
			SetLastIterator(node, assertIterator);

			return node;
		}
Ejemplo n.º 10
0
		public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node)
		{
			ComputeScalarIterator computeScalarIterator = new ComputeScalarIterator();
			computeScalarIterator.RowBuffer = new object[node.OutputList.Length];
			computeScalarIterator.Input = ConvertAlgebraNode(node.Input);
			computeScalarIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);

			BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(computeScalarIterator.Input.RowBuffer, node.Input.OutputList);
			computeScalarIterator.DefinedValues = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);

			SetLastIterator(node, computeScalarIterator);

			return node;
		}
Ejemplo n.º 11
0
		public override AlgebraNode VisitFilterAlgebraNode(FilterAlgebraNode node)
		{
			FilterIterator filterIterator = new FilterIterator();
			filterIterator.RowBuffer = new object[node.OutputList.Length];
			filterIterator.Input = ConvertAlgebraNode(node.Input);
			filterIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
			BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(filterIterator.Input.RowBuffer, node.Input.OutputList);
			filterIterator.Predicate = CreateRuntimeExpression(node.Predicate, boundRowBufferEntrySet);
			SetLastIterator(node, filterIterator);

			return node;
		}
Ejemplo n.º 12
0
		public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node)
		{
			StreamAggregateIterator streamAggregateIterator = new StreamAggregateIterator();
			streamAggregateIterator.RowBuffer = new object[node.OutputList.Length];
			streamAggregateIterator.Input = ConvertAlgebraNode(node.Input);
			streamAggregateIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);

			BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(streamAggregateIterator.Input.RowBuffer, node.Input.OutputList);

			if (node.Groups == null)
			{
				streamAggregateIterator.GroupByEntries = new IteratorInput[0];
				streamAggregateIterator.DefinedValues = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);
			}
			else
			{
				streamAggregateIterator.GroupByEntries = GetIteratorInput(node.Input.OutputList, node.Groups);
				streamAggregateIterator.DefinedValues = GetDefinedValues(node.OutputList, node.DefinedValues, boundRowBufferEntrySet);
			}

			SetLastIterator(node, streamAggregateIterator);

			return node;
		}
Ejemplo n.º 13
0
		private void UpdatePredicateRowBufferReferences(HashMatchIterator hashMatchIterator, HashMatchAlgebraNode node)
		{
			if (node.ProbeResidual != null)
			{
				BoundRowBufferEntrySet leftBoundRowBufferEntrySet = new BoundRowBufferEntrySet(hashMatchIterator.Left.RowBuffer, node.Left.OutputList);
				BoundRowBufferEntrySet rightBoundRowBufferEntrySet = new BoundRowBufferEntrySet(hashMatchIterator.Right.RowBuffer, node.Right.OutputList);
				hashMatchIterator.ProbeResidual = CreateRuntimeExpression(node.ProbeResidual, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);
			}
		}
Ejemplo n.º 14
0
		private void UpdatePredicateRowBufferReferences(NestedLoopsIterator nestedLoopsIterator, JoinAlgebraNode node)
		{
			BoundRowBufferEntrySet leftBoundRowBufferEntrySet = new BoundRowBufferEntrySet(nestedLoopsIterator.Left.RowBuffer, node.Left.OutputList);
			BoundRowBufferEntrySet rightBoundRowBufferEntrySet = new BoundRowBufferEntrySet(nestedLoopsIterator.Right.RowBuffer, node.Right.OutputList);

			if (node.Predicate != null)
				nestedLoopsIterator.Predicate = CreateRuntimeExpression(node.Predicate, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);

			if (node.PassthruPredicate != null)
				nestedLoopsIterator.PassthruPredicate = CreateRuntimeExpression(node.PassthruPredicate, leftBoundRowBufferEntrySet, rightBoundRowBufferEntrySet);
		}
Ejemplo n.º 15
0
		public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node)
		{
			IndexSpoolIterator indexSpoolIterator = new IndexSpoolIterator();
			indexSpoolIterator.RowBuffer = new object[node.OutputList.Length];
			indexSpoolIterator.Input = ConvertAlgebraNode(node.Input);
			indexSpoolIterator.InputOutput = GetIteratorOutput(0, node.Input.OutputList, node.OutputList);
			indexSpoolIterator.IndexEntry = GetIteratorInput(node.Input.OutputList, new RowBufferEntry[] { node.IndexEntry })[0];

			BoundRowBufferEntrySet boundRowBufferEntrySet = new BoundRowBufferEntrySet(indexSpoolIterator.Input.RowBuffer, node.Input.OutputList);
			indexSpoolIterator.ProbeExpression = CreateRuntimeExpression(node.ProbeExpression, boundRowBufferEntrySet);

			SetLastIterator(node, indexSpoolIterator);

			return node;
		}
Ejemplo n.º 16
0
			public RowBufferEntryExpressionUpdater(BoundRowBufferEntrySet[] bufferEntrySets)
			{
				_bufferEntrySets = bufferEntrySets;
			}
Ejemplo n.º 17
0
		private void PushOuterReferences(object[] rowBuffer, JoinAlgebraNode node)
		{
			if (node.OuterReferences != null && node.OuterReferences.Length > 0)
			{
				// Important: We cannot use node.OuterReferences as argument for BoundRowBufferEntrySet().
				// The replacment strategy below will replace occurences to the entries by their index
				// within the array. Therefore we need an array with the same layout as the row buffer.

				RowBufferEntry[] outerReferences = new RowBufferEntry[node.Left.OutputList.Length];
				for (int i = 0; i < outerReferences.Length; i++)
				{
					if (ArrayHelpers.Contains(node.OuterReferences, node.Left.OutputList[i]))
						outerReferences[i] = node.Left.OutputList[i];
				}

				BoundRowBufferEntrySet bufferEntrySet = new BoundRowBufferEntrySet(rowBuffer, outerReferences);
				_outerReferenceStack.Push(bufferEntrySet);
			}
		}