Exemple #1
0
        public void SetUp()
        {
            rootCartNodeOneReq = new RootCartProdAssemblyNode(1, 5, false, new[] { 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 (var i = 0; i < childNodes.Count; i++) {
                    _subStreamsNumsPerChild[i] = childNodes[i].Substreams;
                }

                _combinedSubStreams = RootCartProdAssemblyNode.ComputeCombined(_subStreamsNumsPerChild);
            }

            if (_resultsForStream != null) {
                var numNodes = _resultsForStream.Count;
                if (numNodes == 1) {
                    var node = _resultsForStream[0];
                    var 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>();
            }
        }
Exemple #3
0
        public void TestComputeCombined()
        {
            Assert.IsNull(RootCartProdAssemblyNode.ComputeCombined(new[] { new[] { 2 } }));
            Assert.IsNull(RootCartProdAssemblyNode.ComputeCombined(new[] { new[] { 1 }, new[] { 2 } }));

            var 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]);
        }