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); }
public static ExprNode Make3SubNodeAnd() { ExprNode topNode = new ExprAndNodeImpl(); var equalNodes = new ExprEqualsNode[3]; for (var i = 0; i < equalNodes.Length; i++) { equalNodes[i] = new ExprEqualsNodeImpl(false, false); topNode.AddChildNode(equalNodes[i]); } ExprIdentNode i1_1 = new ExprIdentNodeImpl("IntPrimitive", "s0"); ExprIdentNode i1_2 = new ExprIdentNodeImpl("IntBoxed", "s1"); equalNodes[0].AddChildNode(i1_1); equalNodes[0].AddChildNode(i1_2); ExprIdentNode i2_1 = new ExprIdentNodeImpl("TheString", "s1"); ExprIdentNode i2_2 = new ExprIdentNodeImpl("TheString", "s0"); equalNodes[1].AddChildNode(i2_1); equalNodes[1].AddChildNode(i2_2); ExprIdentNode i3_1 = new ExprIdentNodeImpl("BoolBoxed", "s0"); ExprIdentNode i3_2 = new ExprIdentNodeImpl("BoolPrimitive", "s1"); equalNodes[2].AddChildNode(i3_1); equalNodes[2].AddChildNode(i3_2); Validate3Stream(topNode); return(topNode); }
/// <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); }
/// <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); }
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; }
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); }
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); }
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); }
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); }
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); }
public void SetUp() { _equalsNodes = new ExprEqualsNode[4]; _equalsNodes[0] = new ExprEqualsNodeImpl(false, false); _equalsNodes[1] = new ExprEqualsNodeImpl(false, false); _equalsNodes[1].AddChildNode(new SupportExprNode(1L)); _equalsNodes[1].AddChildNode(new SupportExprNode(1)); _equalsNodes[1].Validate(ExprValidationContextFactory.MakeEmpty()); _equalsNodes[2] = new ExprEqualsNodeImpl(true, false); _equalsNodes[2].AddChildNode(new SupportExprNode(1.5D)); _equalsNodes[2].AddChildNode(new SupportExprNode(1)); _equalsNodes[2].Validate(ExprValidationContextFactory.MakeEmpty()); _equalsNodes[3] = new ExprEqualsNodeImpl(false, false); _equalsNodes[3].AddChildNode(new SupportExprNode(1D)); _equalsNodes[3].AddChildNode(new SupportExprNode(1)); _equalsNodes[3].Validate(ExprValidationContextFactory.MakeEmpty()); }
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)); }
public void QExprIs(ExprEqualsNodeImpl exprNode) { }
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); }