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> /// Analye EQUALS (=) node. /// </summary> /// <param name="equalsNode">node to analyze</param> /// <param name="queryGraph">store relationships between stream properties</param> /// <param name="isOuterJoin">if set to <c>true</c> [is outer join].</param> internal static void AnalyzeEqualsNode(ExprEqualsNode equalsNode, QueryGraph queryGraph, bool isOuterJoin) { if ((equalsNode.ChildNodes[0] is ExprIdentNode) && (equalsNode.ChildNodes[1] is ExprIdentNode)) { var identNodeLeft = (ExprIdentNode)equalsNode.ChildNodes[0]; var identNodeRight = (ExprIdentNode)equalsNode.ChildNodes[1]; if (identNodeLeft.StreamId != identNodeRight.StreamId) { queryGraph.AddStrictEquals(identNodeLeft.StreamId, identNodeLeft.ResolvedPropertyName, identNodeLeft, identNodeRight.StreamId, identNodeRight.ResolvedPropertyName, identNodeRight); } return; } if (isOuterJoin) // outerjoins don't use constants or one-way expression-derived information to evaluate join { return; } // handle constant-compare or transformation case var indexedStream = -1; ExprIdentNode indexedPropExpr = null; ExprNode exprNodeNoIdent = null; if (equalsNode.ChildNodes[0] is ExprIdentNode) { indexedPropExpr = (ExprIdentNode)equalsNode.ChildNodes[0]; indexedStream = indexedPropExpr.StreamId; exprNodeNoIdent = equalsNode.ChildNodes[1]; } else if (equalsNode.ChildNodes[1] is ExprIdentNode) { indexedPropExpr = (ExprIdentNode)equalsNode.ChildNodes[1]; indexedStream = indexedPropExpr.StreamId; exprNodeNoIdent = equalsNode.ChildNodes[0]; } if (indexedStream == -1) { return; // require property of right/left side of equals } var eligibility = EligibilityUtil.VerifyInputStream(exprNodeNoIdent, indexedStream); if (!eligibility.Eligibility.IsEligible()) { return; } if (eligibility.Eligibility == Eligibility.REQUIRE_NONE) { queryGraph.AddUnkeyedExpression(indexedStream, indexedPropExpr, exprNodeNoIdent); } else { queryGraph.AddKeyedExpression(indexedStream, indexedPropExpr, eligibility.StreamNum.Value, exprNodeNoIdent); } }
public static Pair<string, ExprNode> CheckGetAssignmentToProp(ExprNode node) { if (!(node is ExprEqualsNode)) { return null; } ExprEqualsNode equals = (ExprEqualsNode) node; if (!(equals.ChildNodes[0] is ExprIdentNode)) { return null; } ExprIdentNode identNode = (ExprIdentNode) equals.ChildNodes[0]; return new Pair<string, ExprNode>(identNode.FullUnresolvedName, equals.ChildNodes[1]); }
public void TestAnalyzeEquals() { // s0.IntPrimitive = s1.IntBoxed ExprEqualsNode equalsNode = SupportExprNodeFactory.MakeEqualsNode(); QueryGraph graph = new QueryGraph(2, null, false); FilterExprAnalyzer.AnalyzeEqualsNode(equalsNode, graph, false); Assert.IsTrue(graph.IsNavigableAtAll(0, 1)); EPAssertionUtil.AssertEqualsExactOrder(new String[] { "IntPrimitive" }, QueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1)); EPAssertionUtil.AssertEqualsExactOrder(new String[] { "IntPrimitive" }, QueryGraphTestUtil.GetIndexProperties(graph, 1, 0)); EPAssertionUtil.AssertEqualsExactOrder(new String[] { "IntBoxed" }, QueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0)); EPAssertionUtil.AssertEqualsExactOrder(new String[] { "IntBoxed" }, QueryGraphTestUtil.GetIndexProperties(graph, 0, 1)); }
public static Pair<string, ExprNode> CheckGetAssignmentToVariableOrProp(ExprNode node) { Pair<string, ExprNode> prop = CheckGetAssignmentToProp(node); if (prop != null) { return prop; } if (!(node is ExprEqualsNode)) { return null; } ExprEqualsNode equals = (ExprEqualsNode) node; if (equals.ChildNodes[0] is ExprVariableNode variableNode) { return new Pair<string, ExprNode>(variableNode.VariableNameWithSubProp, equals.ChildNodes[1]); } if (equals.ChildNodes[0] is ExprTableAccessNode) { throw new ExprValidationException( "Table access expression not allowed on the left hand side, please remove the table prefix"); } return null; }