Exemple #1
0
        /// <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);
            }
        }