Exemplo n.º 1
0
 private void AssertInners(
     int[][] innersPerStream,
     OuterInnerDirectionalGraph graph)
 {
     for (var i = 0; i < innersPerStream.Length; i++)
     {
         EPAssertionUtil.AssertEqualsAnyOrder(innersPerStream[i], graph.GetInner(i));
     }
 }
        private static bool RecursiveHasInnerJoin(
            int toStream,
            OuterInnerDirectionalGraph outerInnerGraph,
            InnerJoinGraph innerJoinGraph,
            ISet<int> completedStreams)
        {
            // Check if the to-stream is in any of the inner joins
            var hasInnerJoin = innerJoinGraph.HasInnerJoin(toStream);

            if (hasInnerJoin) {
                return true;
            }

            var innerToToStream = outerInnerGraph.GetInner(toStream);
            if (innerToToStream != null) {
                foreach (var nextStream in innerToToStream) {
                    if (completedStreams.Contains(nextStream)) {
                        continue;
                    }

                    var notConsider = new HashSet<int>(completedStreams);
                    notConsider.Add(toStream);
                    var result = RecursiveHasInnerJoin(nextStream, outerInnerGraph, innerJoinGraph, notConsider);

                    if (result) {
                        return true;
                    }
                }
            }

            var outerToToStream = outerInnerGraph.GetOuter(toStream);
            if (outerToToStream != null) {
                foreach (var nextStream in outerToToStream) {
                    if (completedStreams.Contains(nextStream)) {
                        continue;
                    }

                    var notConsider = new HashSet<int>(completedStreams);
                    notConsider.Add(toStream);
                    var result = RecursiveHasInnerJoin(nextStream, outerInnerGraph, innerJoinGraph, notConsider);

                    if (result) {
                        return true;
                    }
                }
            }

            return false;
        }