public void TestAnalyze()
        {
            var descList = new OuterJoinDesc[2];

            descList[0] = SupportOuterJoinDescFactory.MakeDesc("IntPrimitive", "s0", "IntBoxed", "s1", OuterJoinType.LEFT);
            descList[1] = SupportOuterJoinDescFactory.MakeDesc("SimpleProperty", "s2", "TheString", "s1", OuterJoinType.LEFT);
            // simpleProperty in s2

            var graph = new QueryGraph(3, null, false);

            OuterJoinAnalyzer.Analyze(descList, graph);
            Assert.AreEqual(3, graph.NumStreams);

            Assert.IsTrue(graph.IsNavigableAtAll(0, 1));
            Assert.AreEqual(1, QueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1).Count);
            Assert.AreEqual("IntPrimitive", QueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1)[0]);
            Assert.AreEqual(1, QueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0).Count);
            Assert.AreEqual("IntBoxed", QueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0)[0]);

            Assert.IsTrue(graph.IsNavigableAtAll(1, 2));
            Assert.AreEqual("TheString", QueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 2)[0]);
            Assert.AreEqual("SimpleProperty", QueryGraphTestUtil.GetStrictKeyProperties(graph, 2, 1)[0]);
        }
        public void TestAnalyzeAnd()
        {
            ExprAndNode andNode = SupportExprNodeFactory.Make2SubNodeAnd();

            QueryGraph graph = new QueryGraph(2, null, false);

            FilterExprAnalyzer.AnalyzeAndNode(andNode, graph, false);

            Assert.IsTrue(graph.IsNavigableAtAll(0, 1));
            EPAssertionUtil.AssertEqualsExactOrder(QueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1), new String[] { "IntPrimitive", "TheString" });
            EPAssertionUtil.AssertEqualsExactOrder(QueryGraphTestUtil.GetIndexProperties(graph, 1, 0), new String[] { "IntPrimitive", "TheString" });
            EPAssertionUtil.AssertEqualsExactOrder(QueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0), new String[] { "IntBoxed", "TheString" });
            EPAssertionUtil.AssertEqualsExactOrder(QueryGraphTestUtil.GetIndexProperties(graph, 0, 1), new String[] { "IntBoxed", "TheString" });
        }
        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));
        }
Exemple #4
0
        /// <summary>
        /// Given a chain of streams to look up and indexing information, compute the index within the
        /// chain of the first non-index lookup.
        /// </summary>
        /// <param name="lookupStream">stream to start lookup for</param>
        /// <param name="nextStreams">list of stream numbers next in lookup</param>
        /// <param name="queryGraph">indexing information</param>
        /// <returns>value between 0 and (nextStreams.lenght - 1)</returns>
        internal static int ComputeNavigableDepth(int lookupStream, int[] nextStreams, QueryGraph queryGraph)
        {
            var currentStream = lookupStream;
            var currentDepth  = 0;

            for (var i = 0; i < nextStreams.Length; i++)
            {
                var nextStream = nextStreams[i];
                var navigable  = queryGraph.IsNavigableAtAll(currentStream, nextStream);
                if (!navigable)
                {
                    break;
                }
                currentStream = nextStream;
                currentDepth++;
            }

            return(currentDepth);
        }
Exemple #5
0
        public void TestFillEquivalency()
        {
            // test with just 3 streams
            _queryGraph.AddStrictEquals(0, "p00", Make(0, "p00"), 1, "p10", Make(1, "p10"));
            _queryGraph.AddStrictEquals(1, "p10", Make(1, "p10"), 2, "p20", Make(2, "p20"));

            Assert.IsFalse(_queryGraph.IsNavigableAtAll(0, 2));
            Assert.AreEqual(0, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 0, 2).Count);
            Assert.AreEqual(0, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 0, 2).Count);

            QueryGraph.FillEquivalentNav(_types, _queryGraph);

            Assert.IsTrue(_queryGraph.IsNavigableAtAll(0, 2));
            String[] expectedOne = new String[] { "p00" };
            String[] expectedTwo = new String[] { "p20" };
            Assert.IsTrue(Collections.AreEqual(expectedOne, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 0, 2)));
            Assert.IsTrue(Collections.AreEqual(expectedTwo, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 0, 2)));

            // test with 5 streams, connect all streams to all streams
            _queryGraph = new QueryGraph(5, null, false);
            _queryGraph.AddStrictEquals(0, "p0", Make(0, "p0"), 1, "p1", Make(1, "p1"));
            _queryGraph.AddStrictEquals(3, "p3", Make(3, "p3"), 4, "p4", Make(4, "p4"));
            _queryGraph.AddStrictEquals(2, "p2", Make(2, "p2"), 3, "p3", Make(3, "p3"));
            _queryGraph.AddStrictEquals(1, "p1", Make(1, "p1"), 2, "p2", Make(2, "p2"));

            QueryGraph.FillEquivalentNav(_types, _queryGraph);

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    Assert.IsTrue(_queryGraph.IsNavigableAtAll(i, j), "Not navigable: i=" + i + " j=" + j);
                }
            }
        }