public void SetUp()
        {
            _rootCartNodeOneReq = new RootCartProdAssemblyNode(1, 5, false, new int[] { 0, 0, 0, 1, 2 });

            _parentNode = new SupportJoinProcNode(-1, 5);
            _parentNode.AddChild(_rootCartNodeOneReq);

            // add child nodes to indicate what sub-streams to build the cartesian product from
            _rootCartNodeOneReq.AddChild(new SupportJoinProcNode(2, 5));
            _rootCartNodeOneReq.AddChild(new SupportJoinProcNode(3, 5));
            _rootCartNodeOneReq.AddChild(new SupportJoinProcNode(4, 5));
        }
        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 TestFlowOptional()
        {
            RootCartProdAssemblyNode rootCartNodeAllOpt = (RootCartProdAssemblyNode) new RootCartProdAssemblyNodeFactory(1, 5, true).MakeAssemblerUnassociated();

            rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(2, 5));
            rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(3, 5));
            rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(4, 5));

            _parentNode.AddChild(rootCartNodeAllOpt);

            rootCartNodeAllOpt.Init(null);
            List <EventBean[]> resultFinalRows = new List <EventBean[]>();

            rootCartNodeAllOpt.Process(null, resultFinalRows, null);

            // 5 generated rows: 2 (stream 2) + 2 (stream 3) + 1 (self, Node 2)
            Assert.AreEqual(1, _parentNode.RowsList.Count);

            EventBean[][] rowArr = SupportJoinResultNodeFactory.ConvertTo2DimArr(_parentNode.RowsList);
            EPAssertionUtil.AssertEqualsAnyOrder(
                new[] { new EventBean[] { null, null, null, null, null } }, rowArr);
        }
        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]);
        }