public void TestAnalyze() { var descList = new OuterJoinDesc[2]; descList[0] = SupportOuterJoinDescFactory.MakeDesc( container, "IntPrimitive", "s0", "IntBoxed", "s1", OuterJoinType.LEFT); descList[1] = SupportOuterJoinDescFactory.MakeDesc( container, "SimpleProperty", "s2", "TheString", "s1", OuterJoinType.LEFT); // simpleProperty in s2 var graph = new QueryGraphForge(3, null, false); OuterJoinAnalyzer.Analyze(descList, graph); Assert.AreEqual(3, graph.NumStreams); Assert.IsTrue(graph.IsNavigableAtAll(0, 1)); Assert.AreEqual(1, SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1).Length); Assert.AreEqual("IntPrimitive", SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 0, 1)[0]); Assert.AreEqual(1, SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0).Length); Assert.AreEqual("IntBoxed", SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 0)[0]); Assert.IsTrue(graph.IsNavigableAtAll(1, 2)); Assert.AreEqual("TheString", SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 1, 2)[0]); Assert.AreEqual("SimpleProperty", SupportQueryGraphTestUtil.GetStrictKeyProperties(graph, 2, 1)[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> public static int ComputeNavigableDepth( int lookupStream, int[] nextStreams, QueryGraphForge 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; }