Exemple #1
0
        private static void AnalyzeInNodeMultiIndex(ExprInNode inNode, QueryGraph queryGraph)
        {
            ExprNode[] setExpressions = GetInNodeSetExpressions(inNode);
            if (setExpressions.Length == 0)
            {
                return;
            }

            var perStreamExprs = new LinkedHashMap <int?, IList <ExprNode> >();

            foreach (ExprNode exprNodeSet in setExpressions)
            {
                if (!(exprNodeSet is ExprIdentNode))
                {
                    continue;
                }
                var setIdent = (ExprIdentNode)exprNodeSet;
                AddToList(setIdent.StreamId, setIdent, perStreamExprs);
            }
            if (perStreamExprs.IsEmpty())
            {
                return;
            }

            var testExpr     = inNode.ChildNodes[0];
            var testExprType = testExpr.ExprEvaluator.ReturnType.GetBoxedType();

            if (perStreamExprs.Count > 1)
            {
                return;
            }
            var entry = perStreamExprs.First();

            ExprNode[] exprNodes = ExprNodeUtility.ToArray(entry.Value);
            foreach (ExprNode node in exprNodes)
            {
                var exprType = node.ExprEvaluator.ReturnType;
                if (exprType.GetBoxedType() != testExprType)
                {
                    return;
                }
            }

            int?testStreamNum;
            int setStream = entry.Key.Value;

            if (!(testExpr is ExprIdentNode))
            {
                EligibilityDesc eligibility = EligibilityUtil.VerifyInputStream(testExpr, setStream);
                if (!eligibility.Eligibility.IsEligible())
                {
                    return;
                }
                if (eligibility.Eligibility == Eligibility.REQUIRE_ONE && setStream == eligibility.StreamNum)
                {
                    return;
                }
                testStreamNum = eligibility.StreamNum;
            }
            else
            {
                testStreamNum = ((ExprIdentNode)testExpr).StreamId;
            }

            if (testStreamNum == null)
            {
                queryGraph.AddInSetMultiIndexUnkeyed(testExpr, setStream, exprNodes);
            }
            else
            {
                if (testStreamNum.Equals(entry.Key))
                {
                    return;
                }
                queryGraph.AddInSetMultiIndex(testStreamNum.Value, testExpr, setStream, exprNodes);
            }
        }