Exemplo n.º 1
0
        public static ExprAndNode Make2SubNodeAnd()
        {
            ExprAndNode topNode = new ExprAndNodeImpl();

            ExprEqualsNode e1 = new ExprEqualsNodeImpl(false, false);
            ExprEqualsNode e2 = new ExprEqualsNodeImpl(false, false);

            topNode.AddChildNode(e1);
            topNode.AddChildNode(e2);

            ExprIdentNode i1_1 = new ExprIdentNodeImpl("IntPrimitive", "s0");
            ExprIdentNode i1_2 = new ExprIdentNodeImpl("IntBoxed", "s1");

            e1.AddChildNode(i1_1);
            e1.AddChildNode(i1_2);

            ExprIdentNode i2_1 = new ExprIdentNodeImpl("TheString", "s1");
            ExprIdentNode i2_2 = new ExprIdentNodeImpl("TheString", "s0");

            e2.AddChildNode(i2_1);
            e2.AddChildNode(i2_2);

            Validate3Stream(topNode);

            return(topNode);
        }
Exemplo n.º 2
0
        /// <summary>Make an expression node that represents the outer join criteria as specified in the on-clause. </summary>
        /// <param name="exprEvaluatorContext">context for expression evalauation</param>
        /// <returns>expression node for outer join criteria</returns>
        public ExprNode MakeExprNode(ExprEvaluatorContext exprEvaluatorContext)
        {
            ExprNode representativeNode = new ExprEqualsNodeImpl(false, false);

            representativeNode.AddChildNode(OptLeftNode);
            representativeNode.AddChildNode(OptRightNode);

            if (AdditionalLeftNodes == null)
            {
                TopValidate(representativeNode, exprEvaluatorContext);
                return(representativeNode);
            }

            ExprAndNode andNode = new ExprAndNodeImpl();

            TopValidate(representativeNode, exprEvaluatorContext);
            andNode.AddChildNode(representativeNode);
            representativeNode = andNode;

            for (int i = 0; i < AdditionalLeftNodes.Length; i++)
            {
                ExprEqualsNode eqNode = new ExprEqualsNodeImpl(false, false);
                eqNode.AddChildNode(AdditionalLeftNodes[i]);
                eqNode.AddChildNode(AdditionalRightNodes[i]);
                TopValidate(eqNode, exprEvaluatorContext);
                andNode.AddChildNode(eqNode);
            }

            TopValidate(andNode, exprEvaluatorContext);
            return(representativeNode);
        }
Exemplo n.º 3
0
        public ExprNode MakeExprNode(
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices compileTimeServices)
        {
            ExprNode representativeNode = new ExprEqualsNodeImpl(false, false);
            representativeNode.AddChildNode(OptLeftNode);
            representativeNode.AddChildNode(OptRightNode);

            if (AdditionalLeftNodes == null) {
                TopValidate(representativeNode, statementRawInfo, compileTimeServices);
                return representativeNode;
            }

            ExprAndNode andNode = new ExprAndNodeImpl();
            TopValidate(representativeNode, statementRawInfo, compileTimeServices);
            andNode.AddChildNode(representativeNode);
            representativeNode = andNode;

            for (var i = 0; i < AdditionalLeftNodes.Length; i++) {
                ExprEqualsNode eqNode = new ExprEqualsNodeImpl(false, false);
                eqNode.AddChildNode(AdditionalLeftNodes[i]);
                eqNode.AddChildNode(AdditionalRightNodes[i]);
                TopValidate(eqNode, statementRawInfo, compileTimeServices);
                andNode.AddChildNode(eqNode);
            }

            TopValidate(andNode, statementRawInfo, compileTimeServices);
            return representativeNode;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the list of set-variable assignments under the given node.
        /// </summary>
        /// <param name="astExprNodeMap">map of AST to expression</param>
        /// <returns>list of assignments</returns>
        internal static IList <OnTriggerSetAssignment> GetOnTriggerSetAssignments(EsperEPL2GrammarParser.OnSetAssignmentListContext ctx, IDictionary <ITree, ExprNode> astExprNodeMap)
        {
            if (ctx == null || ctx.onSetAssignment().IsEmpty())
            {
                return(Collections.GetEmptyList <OnTriggerSetAssignment>());
            }
            IList <EsperEPL2GrammarParser.OnSetAssignmentContext> ctxs = ctx.onSetAssignment();
            IList <OnTriggerSetAssignment> assignments = new List <OnTriggerSetAssignment>(ctx.onSetAssignment().Length);

            foreach (var assign in ctxs)
            {
                ExprNode childEvalNode;
                if (assign.eventProperty() != null)
                {
                    var            prop   = ASTExprHelper.ExprCollectSubNodes(assign.eventProperty(), 0, astExprNodeMap)[0];
                    var            value  = ASTExprHelper.ExprCollectSubNodes(assign.expression(), 0, astExprNodeMap)[0];
                    ExprEqualsNode equals = new ExprEqualsNodeImpl(false, false);
                    equals.AddChildNode(prop);
                    equals.AddChildNode(value);
                    childEvalNode = equals;
                }
                else
                {
                    childEvalNode = ASTExprHelper.ExprCollectSubNodes(assign, 0, astExprNodeMap)[0];
                }
                assignments.Add(new OnTriggerSetAssignment(childEvalNode));
            }
            return(assignments);
        }
Exemplo n.º 5
0
        private ExprEqualsNode MakeNode(Object valueLeft, Type typeLeft, Object valueRight, Type typeRight, bool isNot)
        {
            ExprEqualsNode equalsNode = new ExprEqualsNodeImpl(isNot, false);

            equalsNode.AddChildNode(new SupportExprNode(valueLeft, typeLeft));
            equalsNode.AddChildNode(new SupportExprNode(valueRight, typeRight));
            SupportExprNodeUtil.Validate(equalsNode);
            return(equalsNode);
        }
Exemplo n.º 6
0
        private static ExprEqualsNode MakeEqualsNode(string ident1, string stream1, object value)
        {
            ExprEqualsNode topNode      = new ExprEqualsNodeImpl(false, false);
            ExprIdentNode  i1_1         = new ExprIdentNodeImpl(ident1, stream1);
            var            constantNode = new SupportExprNode(value);

            topNode.AddChildNode(i1_1);
            topNode.AddChildNode(constantNode);
            return(topNode);
        }
Exemplo n.º 7
0
        public static ExprEqualsNode MakeEqualsNode()
        {
            ExprEqualsNode topNode = new ExprEqualsNodeImpl(false, false);
            ExprIdentNode  i1_1    = new ExprIdentNodeImpl("IntPrimitive");
            ExprIdentNode  i1_2    = new ExprIdentNodeImpl("IntBoxed");

            topNode.AddChildNode(i1_1);
            topNode.AddChildNode(i1_2);
            return(topNode);
        }
Exemplo n.º 8
0
        public static ExprEqualsNode MakeEqualsNode()
        {
            ExprEqualsNode topNode = new ExprEqualsNodeImpl(false, false);
            ExprIdentNode  i1_1    = new ExprIdentNodeImpl("IntPrimitive");
            ExprIdentNode  i1_2    = new ExprIdentNodeImpl("IntBoxed");

            topNode.AddChildNode(i1_1);
            topNode.AddChildNode(i1_2);

            SupportExprNodeFactory.Validate1StreamBean(topNode);

            return(topNode);
        }
Exemplo n.º 9
0
        public ExprEqualsNode MakeEqualsNode()
        {
            ExprEqualsNode topNode = new ExprEqualsNodeImpl(false, false);
            ExprIdentNode  i1_1    = new ExprIdentNodeImpl("IntPrimitive", "s0");
            ExprIdentNode  i1_2    = new ExprIdentNodeImpl("IntBoxed", "s1");

            topNode.AddChildNode(i1_1);
            topNode.AddChildNode(i1_2);

            Validate3Stream(topNode);

            return(topNode);
        }
        internal static UniformPair <int?> ValidateOuterJoinPropertyPair(
            StatementContext statementContext,
            ExprIdentNode leftNode,
            ExprIdentNode rightNode,
            int outerJoinCount,
            StreamTypeService typeService,
            ViewResourceDelegateUnverified viewResourceDelegate)
        {
            // Validate the outer join clause using an artificial equals-node on top.
            // Thus types are checked via equals.
            // Sets stream ids used for validated nodes.
            ExprNode equalsNode = new ExprEqualsNodeImpl(false, false);

            equalsNode.AddChildNode(leftNode);
            equalsNode.AddChildNode(rightNode);
            var evaluatorContextStmt = new ExprEvaluatorContextStatement(statementContext, false);

            try
            {
                var validationContext = new ExprValidationContext(
                    typeService,
                    statementContext.MethodResolutionService, viewResourceDelegate,
                    statementContext.SchedulingService,
                    statementContext.VariableService,
                    statementContext.TableService,
                    evaluatorContextStmt,
                    statementContext.EventAdapterService,
                    statementContext.StatementName,
                    statementContext.StatementId,
                    statementContext.Annotations,
                    statementContext.ContextDescriptor,
                    statementContext.ScriptingService,
                    false, false, true, false,
                    null, false);
                ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.JOINON, equalsNode, validationContext);
            }
            catch (ExprValidationException ex)
            {
                Log.Debug("Validation exception for outer join node=" + ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(equalsNode), ex);
                throw new EPStatementException("Error validating expression: " + ex.Message, statementContext.Expression);
            }

            // Make sure we have left-hand-side and right-hand-side refering to different streams
            var streamIdLeft  = leftNode.StreamId;
            var streamIdRight = rightNode.StreamId;

            if (streamIdLeft == streamIdRight)
            {
                const string message = "Outer join ON-clause cannot refer to properties of the same stream";
                throw new EPStatementException("Error validating expression: " + message, statementContext.Expression);
            }

            // Make sure one of the properties refers to the acutual stream currently being joined
            var expectedStreamJoined = outerJoinCount + 1;

            if ((streamIdLeft != expectedStreamJoined) && (streamIdRight != expectedStreamJoined))
            {
                var message = "Outer join ON-clause must refer to at least one property of the joined stream" +
                              " for stream " + expectedStreamJoined;
                throw new EPStatementException("Error validating expression: " + message, statementContext.Expression);
            }

            // Make sure neither of the streams refer to a 'future' stream
            String badPropertyName = null;

            if (streamIdLeft > outerJoinCount + 1)
            {
                badPropertyName = leftNode.ResolvedPropertyName;
            }
            if (streamIdRight > outerJoinCount + 1)
            {
                badPropertyName = rightNode.ResolvedPropertyName;
            }
            if (badPropertyName != null)
            {
                var message = "Outer join ON-clause invalid scope for property" +
                              " '" + badPropertyName + "', expecting the current or a prior stream scope";
                throw new EPStatementException("Error validating expression: " + message, statementContext.Expression);
            }

            return(new UniformPair <int?>(streamIdLeft, streamIdRight));
        }
Exemplo n.º 11
0
        protected internal static UniformPair<int> ValidateOuterJoinPropertyPair(
            ExprIdentNode leftNode,
            ExprIdentNode rightNode,
            int outerJoinCount,
            StreamTypeService typeService,
            ViewResourceDelegateExpr viewResourceDelegate,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices compileTimeServices)
        {
            // Validate the outer join clause using an artificial equals-node on top.
            // Thus types are checked via equals.
            // Sets stream ids used for validated nodes.
            ExprNode equalsNode = new ExprEqualsNodeImpl(false, false);
            equalsNode.AddChildNode(leftNode);
            equalsNode.AddChildNode(rightNode);
            try {
                var validationContext = new ExprValidationContextBuilder(
                        typeService,
                        statementRawInfo,
                        compileTimeServices)
                    .WithViewResourceDelegate(viewResourceDelegate)
                    .WithAllowBindingConsumption(true)
                    .WithIsFilterExpression(true)
                    .Build();
                ExprNodeUtilityValidate.GetValidatedSubtree(ExprNodeOrigin.JOINON, equalsNode, validationContext);
            }
            catch (ExprValidationException ex) {
                throw new ExprValidationException("Failed to validate outer-join expression: " + ex.Message, ex);
            }

            // Make sure we have left-hand-side and right-hand-side refering to different streams
            var streamIdLeft = leftNode.StreamId;
            var streamIdRight = rightNode.StreamId;
            if (streamIdLeft == streamIdRight) {
                var message = "Outer join ON-clause cannot refer to properties of the same stream";
                throw new ExprValidationException("Failed to validate outer-join expression: " + message);
            }

            // Make sure one of the properties refers to the acutual stream currently being joined
            var expectedStreamJoined = outerJoinCount + 1;
            if (streamIdLeft != expectedStreamJoined && streamIdRight != expectedStreamJoined) {
                var message = "Outer join ON-clause must refer to at least one property of the joined stream" +
                              " for stream " +
                              expectedStreamJoined;
                throw new ExprValidationException("Failed to validate outer-join expression: " + message);
            }

            // Make sure neither of the streams refer to a 'future' stream
            string badPropertyName = null;
            if (streamIdLeft > outerJoinCount + 1) {
                badPropertyName = leftNode.ResolvedPropertyName;
            }

            if (streamIdRight > outerJoinCount + 1) {
                badPropertyName = rightNode.ResolvedPropertyName;
            }

            if (badPropertyName != null) {
                var message = "Outer join ON-clause invalid scope for property" +
                              " '" +
                              badPropertyName +
                              "', expecting the current or a prior stream scope";
                throw new ExprValidationException("Failed to validate outer-join expression: " + message);
            }

            return new UniformPair<int>(streamIdLeft, streamIdRight);
        }