public override void Init(IList <Node>[] result) { _resultsForStream = result[StreamNum]; _singleResultNode = null; _singleResultParentEvent = null; _singleResultRowsPerStream = null; _haveChildResults = false; if (_subStreamsNumsPerChild == null) { if (ChildNodes.Count < 2) { throw new IllegalStateException("Expecting at least 2 child nodes"); } _subStreamsNumsPerChild = new int[ChildNodes.Count][]; for (int i = 0; i < ChildNodes.Count; i++) { _subStreamsNumsPerChild[i] = ChildNodes[i].Substreams; } _combinedSubStreams = RootCartProdAssemblyNode.ComputeCombined(_subStreamsNumsPerChild); } if (_resultsForStream != null) { int numNodes = _resultsForStream.Count; if (numNodes == 1) { Node node = _resultsForStream[0]; ICollection <EventBean> nodeEvents = node.Events; // If there is a single result event (typical case) if (nodeEvents.Count == 1) { _singleResultNode = node; _singleResultParentEvent = nodeEvents.First(); _singleResultRowsPerStream = new IList <EventBean[]> [ChildNodes.Count]; } } if (_singleResultNode == null) { _completedEvents = new Dictionary <EventBean, ChildStreamResults>(); } } else { _completedEvents = new Dictionary <EventBean, ChildStreamResults>(); } }
public void TestComputeCombined() { Assert.IsNull(RootCartProdAssemblyNode.ComputeCombined(new[] { new [] { 2 } })); Assert.IsNull(RootCartProdAssemblyNode.ComputeCombined(new[] { new [] { 1 }, new [] { 2 } })); int[][] result = RootCartProdAssemblyNode.ComputeCombined( new[] { new[] { 3, 4 }, new[] { 2, 5 }, new[] { 6 } }); Assert.AreEqual(1, result.Length); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5 }, result[0]); result = RootCartProdAssemblyNode.ComputeCombined( new[] { new[] { 3, 4 }, new[] { 2, 5 }, new[] { 6 }, new[] { 0, 8, 9 } }); Assert.AreEqual(2, result.Length); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5 }, result[0]); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5, 6 }, result[1]); result = RootCartProdAssemblyNode.ComputeCombined( new[] { new[] { 3, 4 }, new[] { 2, 5 }, new[] { 6 }, new[] { 0, 8, 9 }, new[] { 1 } }); Assert.AreEqual(3, result.Length); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5 }, result[0]); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5, 6 }, result[1]); EPAssertionUtil.AssertEqualsAnyOrder(new[] { 3, 4, 2, 5, 6, 0, 8, 9 }, result[2]); }