Ejemplo n.º 1
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("insert into MyStream select TheString, IntPrimitive from SupportBean", path);
                env.CompileDeploy("insert into VarStreamMD select TheString as abc from MyStream", path);
                env.CompileDeploy("@Name('Target') select * from VarStreamMD#keepall", path);

                env.SendEventBean(new SupportBean("E1", 1));

                var arr = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("Target"));
                EPAssertionUtil.AssertPropsPerRow(
                    arr,
                    new[] {"abc"},
                    new[] {new object[] {"E1"}});

                env.CompileDeploy("insert into MyStream2 select Feed from SupportMarketDataBean", path);
                env.CompileDeploy("insert into VarStreamMD select Feed as abc from MyStream2", path);

                env.SendEventBean(new SupportMarketDataBean("IBM", 1, 1L, "E2"));

                arr = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("Target"));
                EPAssertionUtil.AssertPropsPerRow(
                    arr,
                    new[] {"abc"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.UndeployAll();
            }
Ejemplo n.º 2
0
        private void RunAssertionNamedWindowModelAfter(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();
            epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S1));

            epService.EPAdministrator.CreateEPL("create schema EmptyPropSchema()");
            EPStatement stmtCreateWindow = epService.EPAdministrator.CreateEPL("create window EmptyPropWin#keepall as EmptyPropSchema");

            epService.EPAdministrator.CreateEPL("insert into EmptyPropWin() select null from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean());

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator());
            Assert.AreEqual(1, events.Length);
            Assert.AreEqual("EmptyPropWin", events[0].EventType.Name);

            // try fire-and-forget query
            epService.EPRuntime.ExecuteQuery("insert into EmptyPropWin select null");
            Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);
            epService.EPRuntime.ExecuteQuery("delete from EmptyPropWin"); // empty window

            // try on-merge
            epService.EPAdministrator.CreateEPL("on SupportBean_S0 merge EmptyPropWin " +
                                                "when not matched then insert select null");
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            Assert.AreEqual(1, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);

            // try on-insert
            epService.EPAdministrator.CreateEPL("on SupportBean_S1 insert into EmptyPropWin select null");
            epService.EPRuntime.SendEvent(new SupportBean_S1(0));
            Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 3
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from SupportMarketDataBean#firstevent()";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeMarketDataEvent("E1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E1"}}, null);

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("E2"));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}});

                env.Milestone(2);

                env.SendEventBean(MakeMarketDataEvent("E3"));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}});

                env.UndeployAll();
            }
        public bool Call()
        {
            try {
                long total = 0;
                for (int loop = 0; loop < _numRepeats; loop++)
                {
                    // Insert event into named window
                    SendMarketBean(_threadKey, loop + 1);
                    total += loop + 1;

                    // iterate over private statement
                    var         safeIter = _statement.GetSafeEnumerator();
                    EventBean[] received = EPAssertionUtil.EnumeratorToArray(safeIter);
                    safeIter.Dispose();

                    for (int i = 0; i < received.Length; i++)
                    {
                        if (received[i].Get("TheString").Equals(_threadKey))
                        {
                            long sum = (long)received[i].Get("sumLong");
                            Assert.AreEqual(total, sum);
                        }
                    }
                }
            } catch (Exception ex) {
                Log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public void TestReclaimAgedHint()
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }                                                                       // exclude from test, too much data

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean));
            String epl = "@Hint('reclaim_group_aged=5,reclaim_group_freq=1') " +
                         "select * from SupportBean.std:groupwin(TheString).win:keepall()";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            int maxSlots         = 10;
            int maxEventsPerSlot = 1000;

            for (int timeSlot = 0; timeSlot < maxSlots; timeSlot++)
            {
                _epService.EPRuntime.SendEvent(new CurrentTimeEvent(timeSlot * 1000 + 1));

                for (int i = 0; i < maxEventsPerSlot; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("E" + timeSlot, 0));
                }
            }

            EventBean[] iterator = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.IsTrue(iterator.Length <= 6 * maxEventsPerSlot);
        }
Ejemplo n.º 6
0
        public object Call()
        {
            try {
                long total = 0;
                for (var loop = 0; loop < numRepeats; loop++) {
                    // Insert event into named window
                    SendMarketBean(threadKey, loop + 1);
                    total += loop + 1;

                    EventBean[] received;

                    // iterate over private statement
                    using (var safeIter = statement.GetSafeEnumerator()) {
                        received = EPAssertionUtil.EnumeratorToArray(safeIter);
                    }

                    for (var i = 0; i < received.Length; i++) {
                        if (received[i].Get("TheString").Equals(threadKey)) {
                            var sum = received[i].Get("sumLong").AsInt64();
                            Assert.AreEqual(total, sum);
                        }
                    }
                }
            }
            catch (Exception ex) {
                log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }

            return true;
        }
Ejemplo n.º 7
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from  SupportMarketDataBean#size(Symbol)";
                env.CompileDeploy(text).AddListener("s0");

                env.SendEventBean(MakeMarketDataEvent("E1"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"size", 1L}, new object[] {"Symbol", "E1"}},
                        new[] {new object[] {"size", 0L}, new object[] {"Symbol", null}});

                env.Milestone(0);

                env.SendEventBean(MakeMarketDataEvent("E2"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"size", 2L}, new object[] {"Symbol", "E2"}},
                        new[] {new object[] {"size", 1L}, new object[] {"Symbol", "E1"}});

                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"size", "Symbol"},
                    new[] {new object[] {2L, "E2"}});

                env.UndeployAll();
            }
Ejemplo n.º 8
0
        private void RunAssertionAnyTypeStaggered(EPServiceProvider epService)
        {
            // test insert into staggered with map
            var configVariantStream = new ConfigurationVariantStream();

            configVariantStream.TypeVariance = TypeVarianceEnum.ANY;
            epService.EPAdministrator.Configuration.AddVariantStream("VarStream", configVariantStream);
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType("SupportMarketDataBean", typeof(SupportMarketDataBean));

            epService.EPAdministrator.CreateEPL("insert into MyStream select TheString, IntPrimitive from SupportBean");
            epService.EPAdministrator.CreateEPL("insert into VarStream select TheString as abc from MyStream");
            epService.EPAdministrator.CreateEPL("@Name('Target') select * from VarStream#keepall");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));

            EventBean[] arr = EPAssertionUtil.EnumeratorToArray(epService.EPAdministrator.GetStatement("Target").GetEnumerator());
            EPAssertionUtil.AssertPropsPerRow(arr, new string[] { "abc" }, new object[][] { new object[] { "E1" } });

            epService.EPAdministrator.CreateEPL("insert into MyStream2 select feed from SupportMarketDataBean");
            epService.EPAdministrator.CreateEPL("insert into VarStream select feed as abc from MyStream2");

            epService.EPRuntime.SendEvent(new SupportMarketDataBean("IBM", 1, 1L, "E2"));

            arr = EPAssertionUtil.EnumeratorToArray(epService.EPAdministrator.GetStatement("Target").GetEnumerator());
            EPAssertionUtil.AssertPropsPerRow(arr, new string[] { "abc" }, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 9
0
        private static void TrySend(
            RegressionEnvironment env,
            EPStatement stmtWindow,
            int numThreads,
            int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtNamedWindowPriority)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtNamedWindowPriorityCallable(i, env.Runtime, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            SupportCompileDeployUtil.AssertFutures(future);

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);

            var events = EPAssertionUtil.EnumeratorToArray(stmtWindow.GetEnumerator());
            Assert.AreEqual(numThreads * numRepeats, events.Length);
            for (var i = 0; i < events.Length; i++) {
                var valueC1 = (string) events[i].Get("c1");
                Assert.AreEqual("y", valueC1);
            }
        }
        private void TrySend(EPServiceProvider epService, EPStatement stmtWindow, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtNamedWindowPriorityCallable(i, epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            for (int i = 0; i < numThreads; i++)
            {
                future[i].GetValueOrDefault();
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmtWindow.GetEnumerator());
            Assert.AreEqual(numThreads * numRepeats, events.Length);
            for (int i = 0; i < events.Length; i++)
            {
                string valueC1 = (string)events[i].Get("c1");
                Assert.AreEqual("y", valueC1);
            }
        }
Ejemplo n.º 11
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create schema EmptyPropSchema()", path);
                env.CompileDeploy("@Name('window') create window EmptyPropWin#keepall as EmptyPropSchema", path);
                env.CompileDeploy("insert into EmptyPropWin() select null from SupportBean", path);

                env.SendEventBean(new SupportBean());

                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window"));
                Assert.AreEqual(1, events.Length);
                Assert.AreEqual("EmptyPropWin", events[0].EventType.Name);

                // try fire-and-forget query
                env.CompileExecuteFAF("insert into EmptyPropWin select null", path);
                Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);
                env.CompileExecuteFAF("delete from EmptyPropWin", path); // empty window

                // try on-merge
                env.CompileDeploy(
                    "on SupportBean_S0 merge EmptyPropWin " +
                    "when not matched then insert select null",
                    path);
                env.SendEventBean(new SupportBean_S0(0));
                Assert.AreEqual(1, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);

                // try on-insert
                env.CompileDeploy("on SupportBean_S1 insert into EmptyPropWin select null", path);
                env.SendEventBean(new SupportBean_S1(0));
                Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);

                env.UndeployAll();
            }
Ejemplo n.º 12
0
        public void TestAnyTypeStaggered()
        {
            // test insert into staggered with map
            ConfigurationVariantStream configVariantStream = new ConfigurationVariantStream();

            configVariantStream.TypeVariance = TypeVarianceEnum.ANY;
            _epService.EPAdministrator.Configuration.AddVariantStream("VarStream", configVariantStream);
            _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean));
            _epService.EPAdministrator.Configuration.AddEventType("SupportMarketDataBean", typeof(SupportMarketDataBean));

            _epService.EPAdministrator.CreateEPL("insert into MyStream select TheString, IntPrimitive from SupportBean");
            _epService.EPAdministrator.CreateEPL("insert into VarStream select TheString as abc from MyStream");
            _epService.EPAdministrator.CreateEPL("@Name('Target') select * from VarStream.win:keepall()");

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));

            EventBean[] arr = EPAssertionUtil.EnumeratorToArray(_epService.EPAdministrator.GetStatement("Target").GetEnumerator());
            EPAssertionUtil.AssertPropsPerRow(arr, new String[] { "abc" }, new Object[][] { new Object[] { "E1" } });

            _epService.EPAdministrator.CreateEPL("insert into MyStream2 select Feed from SupportMarketDataBean");
            _epService.EPAdministrator.CreateEPL("insert into VarStream select Feed as abc from MyStream2");

            _epService.EPRuntime.SendEvent(new SupportMarketDataBean("IBM", 1, 1L, "E2"));

            arr = EPAssertionUtil.EnumeratorToArray(_epService.EPAdministrator.GetStatement("Target").GetEnumerator());
            EPAssertionUtil.AssertPropsPerRow(arr, new String[] { "abc" }, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" } });
        }
Ejemplo n.º 13
0
        private void TrySend(EPServiceProvider epService, int numThreads, int numEventsPerThread)
        {
            // setup statements
            epService.EPAdministrator.CreateEPL("create schema MyUpdateEvent as (key string, intupd int)");
            epService.EPAdministrator.CreateEPL("create schema MySchema as (TheString string, intval int)");
            EPStatement namedWindow = epService.EPAdministrator.CreateEPL("create window MyWindow#keepall as MySchema");

            epService.EPAdministrator.CreateEPL("on MyUpdateEvent mue merge MyWindow mw " +
                                                "where mw.TheString = mue.key " +
                                                "when not matched then insert select key as TheString, intupd as intval " +
                                                "when matched then delete");
            EPStatement targetStatement = epService.EPAdministrator.CreateEPL("select (select intval from MyWindow mw where mw.TheString = sb.TheString) as val from SupportBean sb");

            // execute
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(new StmtNamedWindowSubqueryLookupCallable(i, epService, numEventsPerThread, targetStatement));
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            // total up result
            for (int i = 0; i < numThreads; i++)
            {
                bool?result = future[i].GetValueOrDefault();
                Assert.IsTrue(result);
            }

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(namedWindow.GetEnumerator());
            Assert.AreEqual(0, events.Length);
        }
Ejemplo n.º 14
0
        public void TestNamedWindowModelAfter()
        {
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S1>();

            _epService.EPAdministrator.CreateEPL("create schema EmptyPropSchema()");
            var stmtCreateWindow = _epService.EPAdministrator.CreateEPL("create window EmptyPropWin.win:keepall() as EmptyPropSchema");

            _epService.EPAdministrator.CreateEPL("insert into EmptyPropWin() select null from SupportBean");

            _epService.EPRuntime.SendEvent(new SupportBean());

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator());
            Assert.AreEqual(1, events.Length);
            Assert.AreEqual("EmptyPropWin", events[0].EventType.Name);

            // try fire-and-forget query
            _epService.EPRuntime.ExecuteQuery("insert into EmptyPropWin select null");
            Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);
            _epService.EPRuntime.ExecuteQuery("delete from EmptyPropWin");     // empty window

            // try on-merge
            _epService.EPAdministrator.CreateEPL("on SupportBean_S0 merge EmptyPropWin " +
                                                 "when not matched then insert select null");
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            Assert.AreEqual(1, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);

            // try on-insert
            _epService.EPAdministrator.CreateEPL("on SupportBean_S1 insert into EmptyPropWin select null");
            _epService.EPRuntime.SendEvent(new SupportBean_S1(0));
            Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(stmtCreateWindow.GetEnumerator()).Length);
        }
Ejemplo n.º 15
0
        public void TestIterateAndListen()
        {
            _epService.EPAdministrator.CreateEPL("@Name('ctx') create context MyCtx as initiated by SupportBean_S0 s0 terminated after 24 hours");

            var fields = "mycontextvar".Split(',');
            var listenerCreateVariable = new SupportUpdateListener();
            var stmtVar = _epService.EPAdministrator.CreateEPL("@Name('var') context MyCtx create variable int mycontextvar = 5");

            stmtVar.Events += listenerCreateVariable.Update;

            var listenerUpdate = new SupportUpdateListener();
            var stmtUpd        = _epService.EPAdministrator.CreateEPL("@Name('upd') context MyCtx on SupportBean(TheString = context.s0.p00) set mycontextvar = IntPrimitive");

            stmtUpd.Events += listenerUpdate.Update;

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "P1"));   // allocate partition P1
            _epService.EPRuntime.SendEvent(new SupportBean("P1", 100));    // update
            EPAssertionUtil.AssertProps(listenerUpdate.AssertOneGetNewAndReset(), "mycontextvar".Split(','), new object[] { 100 });
            EPAssertionUtil.AssertPropsPerRow(EPAssertionUtil.EnumeratorToArray(stmtUpd.GetEnumerator()), fields, new object[][] { new object[] { 100 } });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "P2"));   // allocate partition P1
            _epService.EPRuntime.SendEvent(new SupportBean("P2", 101));    // update
            EPAssertionUtil.AssertProps(listenerUpdate.AssertOneGetNewAndReset(), "mycontextvar".Split(','), new object[] { 101 });
            EPAssertionUtil.AssertPropsPerRow(EPAssertionUtil.EnumeratorToArray(stmtUpd.GetEnumerator()), fields, new object[][] { new object[] { 100 }, new object[] { 101 } });

            var events = EPAssertionUtil.EnumeratorToArray(stmtVar.GetEnumerator());

            EPAssertionUtil.AssertPropsPerRowAnyOrder(events, "mycontextvar".SplitCsv(), new Object[][] { new Object[] { 100 }, new Object[] { 101 } });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(listenerCreateVariable.GetNewDataListFlattened(), "mycontextvar".SplitCsv(), new Object[][] { new Object[] { 100 }, new Object[] { 101 } });
        }
Ejemplo n.º 16
0
        private void RunAssertionReclaimAgedHint(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            string epl = "@Hint('reclaim_group_aged=5,reclaim_group_freq=1') " +
                         "select * from SupportBean#groupwin(TheString)#keepall";
            EPStatement stmt = epService.EPAdministrator.CreateEPL(epl);

            int maxSlots         = 10;
            int maxEventsPerSlot = 1000;

            for (int timeSlot = 0; timeSlot < maxSlots; timeSlot++)
            {
                epService.EPRuntime.SendEvent(new CurrentTimeEvent(timeSlot * 1000 + 1));

                for (int i = 0; i < maxEventsPerSlot; i++)
                {
                    epService.EPRuntime.SendEvent(new SupportBean("E" + timeSlot, 0));
                }
            }

            EventBean[] iterator = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.IsTrue(iterator.Length <= 6 * maxEventsPerSlot);
            stmt.Dispose();
        }
Ejemplo n.º 17
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl =
                    "@Name('create') create window MyWindowFO#groupwin(TheString, IntPrimitive)#length(3) as select TheString, IntPrimitive, BoolPrimitive from SupportBean;\n" +
                    "insert into MyWindowFO select TheString, IntPrimitive, BoolPrimitive from SupportBean;\n";
                env.CompileDeploy(epl, path).AddListener("create");

                // fill window
                string[] stringValues = {"c0", "c1", "c2"};
                for (var i = 0; i < stringValues.Length; i++) {
                    for (var j = 0; j < 3; j++) {
                        for (var k = 0; k < 2; k++) {
                            env.SendEventBean(
                                new SupportBean(stringValues[i], j) {
                                    BoolPrimitive = true
                                });
                        }
                    }
                }

                env.SendEventBean(new SupportBean("c1", 2) {BoolPrimitive = true});

                var received = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("create"));
                Assert.AreEqual(19, received.Length);

                // create select stmt
                var stmtTextSelect =
                    "@Name('select') select TheString, IntPrimitive, count(BoolPrimitive) as cntBool, Symbol " +
                    "from MyWindowFO full outer join SupportMarketDataBean#keepall " +
                    "on TheString = Symbol " +
                    "group by TheString, IntPrimitive, Symbol order by TheString, IntPrimitive, Symbol";
                env.CompileDeploy(stmtTextSelect, path);

                // send outer join events
                SendMarketBean(env, "c0");
                SendMarketBean(env, "c3");

                // get iterator results
                received = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("select"));
                EPAssertionUtil.AssertPropsPerRow(
                    received,
                    new [] { "TheString","IntPrimitive","cntBool","Symbol" },
                    new[] {
                        new object[] {null, null, 0L, "c3"},
                        new object[] {"c0", 0, 2L, "c0"},
                        new object[] {"c0", 1, 2L, "c0"},
                        new object[] {"c0", 2, 2L, "c0"},
                        new object[] {"c1", 0, 2L, null},
                        new object[] {"c1", 1, 2L, null},
                        new object[] {"c1", 2, 3L, null},
                        new object[] {"c2", 0, 2L, null},
                        new object[] {"c2", 1, 2L, null},
                        new object[] {"c2", 2, 2L, null}
                    });

                env.UndeployModuleContaining("select");
                env.UndeployModuleContaining("create");
            }
Ejemplo n.º 18
0
        private void AssertIterator(EPStatementSPI statement, string[] fields, object[][] expected)
        {
            EventBean[] rows = EPAssertionUtil.EnumeratorToArray(statement.GetEnumerator());
            AssertIterator(rows, fields, expected);

            rows = EPAssertionUtil.EnumeratorToArray(statement.GetSafeEnumerator());
            AssertIterator(rows, fields, expected);
        }
Ejemplo n.º 19
0
        private static void TrySend(
            RegressionEnvironment env,
            int numThreads,
            int numEventsPerThread,
            bool indexShare)
        {
            // setup statements
            var path = new RegressionPath();
            var schemas = "create schema UpdateEvent as (uekey string, ueint int);\n" +
                          "create schema WindowSchema as (wskey string, wsint int);\n";
            env.CompileDeployWBusPublicType(schemas, path);

            var createEpl = "@Name('namedWindow') create window MyWindow#keepall as WindowSchema";
            if (indexShare) {
                createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl;
            }

            env.CompileDeploy(createEpl, path);

            env.CompileDeploy("create index ABC on MyWindow(wskey)", path);
            env.CompileDeploy(
                "on UpdateEvent mue merge MyWindow mw " +
                "where uekey = wskey and ueint = wsint " +
                "when not matched then insert select uekey as wskey, ueint as wsint " +
                "when matched then delete",
                path);
            // note: here all threads use the same string key to insert/delete and different values for the int
            env.CompileDeploy(
                "@Name('target') select (select intListAgg(wsint) from MyWindow mw where wskey = sb.TheString) as val from SupportBean sb",
                path);

            // execute
            var executor = Executors.NewMultiThreadedExecutor(numThreads);
            // new SupportThreadFactory(typeof(MultithreadStmtNamedWindowSubqueryAgg)).ThreadFactory)
            var futures = new List<IFuture<bool?>>();
            for (var i = 0; i < numThreads; i++) {
                futures.Add(executor.Submit(
                    new StmtNamedWindowSubqueryAggCallable(
                        i,
                        env.Runtime,
                        numEventsPerThread,
                        env.Statement("target"))));
            }
            
            // Give the futures 10 seconds to complete the futures...
            futures.AsParallel().ForAll(future => future.Wait(TimeSpan.FromSeconds(10)));

            executor.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(executor, TimeSpan.FromSeconds(10));
            SupportCompileDeployUtil.AssertFutures(futures);

            var events = EPAssertionUtil.EnumeratorToArray(env.Statement("namedWindow").GetEnumerator());
            Assert.AreEqual(0, events.Length);

            env.UndeployAll();
        }
Ejemplo n.º 20
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);

                var text = "@Name('s0') select irstream * from SupportMarketDataBean#time(1 sec)";
                env.CompileDeployAddListenerMileZero(text, "s0");
                string[] fields = {"Symbol"};

                env.AdvanceTime(500);
                env.SendEventBean(MakeMarketDataEvent("E1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E1"}}, null);

                env.Milestone(1);

                env.AdvanceTime(600);
                env.SendEventBean(MakeMarketDataEvent("E2"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E2"}}, null);

                env.Milestone(2);

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.Statement("s0").GetEnumerator());
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.AdvanceTime(1500);
                env.Listener("s0")
                    .AssertNewOldData(
                        null,
                        new[] {new object[] {"Symbol", "E1"}}); // olddata

                env.Milestone(3);

                env.AdvanceTime(1600);
                env.Listener("s0")
                    .AssertNewOldData(
                        null,
                        new[] {new object[] {"Symbol", "E2"}}); // olddata

                env.Milestone(4);

                env.AdvanceTime(2000);

                env.Milestone(5);

                env.SendEventBean(MakeMarketDataEvent("E3"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E3"}}, null);

                env.Milestone(6);

                env.UndeployAll();
            }
Ejemplo n.º 21
0
        private static void AssertIterator(
            RegressionEnvironment env,
            string statementName,
            string[] fields,
            object[][] expected)
        {
            var rows = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator(statementName));
            AssertIterator(rows, fields, expected);

            rows = EPAssertionUtil.EnumeratorToArray(env.Statement(statementName).GetSafeEnumerator());
            AssertIterator(rows, fields, expected);
        }
Ejemplo n.º 22
0
            public void Run(RegressionEnvironment env)
            {
                var text =
                    "@Name('s0') select irstream * from SupportMarketDataBean#length(3)#linest(Price, Volume, Feed)";
                env.CompileDeploy(text).AddListener("s0");

                env.SendEventBean(MakeBean(70, 1000, "f1"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN},
                            new object[] {"Feed", "f1"}
                        },
                        new[] {
                            new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN},
                            new object[] {"Feed", null}
                        });

                env.Milestone(0);

                env.SendEventBean(MakeBean(70.5, 1500, "f2"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"slope", 1000.0}, new object[] {"YIntercept", -69000.0},
                            new object[] {"Feed", "f2"}
                        },
                        new[] {
                            new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN},
                            new object[] {"Feed", "f1"}
                        });

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"slope", "YIntercept", "Feed"},
                    new[] {new object[] {1000.0, -69000.0, "f2"}});

                env.SendEventBean(MakeBean(70.1, 1200, "f3"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"slope", 928.571428587354}, new object[] {"YIntercept", -63952.38095349892},
                            new object[] {"Feed", "f3"}
                        },
                        new[] {
                            new object[] {"slope", 1000.0}, new object[] {"YIntercept", -69000.0},
                            new object[] {"Feed", "f2"}
                        });

                env.UndeployAll();
            }
Ejemplo n.º 23
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from  SupportMarketDataBean#sort(3, Symbol)";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeMarketDataEvent("B1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "B1"}}, null);

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("D1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "D1"}}, null);

                env.Milestone(2);

                env.SendEventBean(MakeMarketDataEvent("C1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "C1"}}, null);

                env.Milestone(3);

                env.SendEventBean(MakeMarketDataEvent("A1"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"Symbol", "A1"}},
                        new[] {new object[] {"Symbol", "D1"}});

                env.Milestone(4);

                env.SendEventBean(MakeMarketDataEvent("F1"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"Symbol", "F1"}},
                        new[] {new object[] {"Symbol", "F1"}});

                env.Milestone(5);

                env.SendEventBean(MakeMarketDataEvent("B2"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"Symbol", "B2"}},
                        new[] {new object[] {"Symbol", "C1"}});

                env.Milestone(6);

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"Symbol"},
                    new[] {new object[] {"A1"}, new object[] {"B1"}, new object[] {"B2"}});

                env.UndeployAll();
            }
Ejemplo n.º 24
0
        public void TestTimeViewUnique()
        {
            // Testing the two forms of the case expression
            // Furthermore the test checks the different when clauses and actions related.
            String caseExpr = "select Volume " +
                              "from " + typeof(SupportMarketDataBean).FullName + ".std:unique(symbol).win:time(10)";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(caseExpr);

            stmt.Events += _listener.Update;
            SendMarketDataEvent("DELL", 1, 50);
            SendMarketDataEvent("DELL", 2, 50);
            Object[] values = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.AreEqual(1, values.Length);
        }
Ejemplo n.º 25
0
        public void TestFullOuterIteratorGroupBy()
        {
            String stmt = "select TheString, IntPrimitive, Symbol, Volume " +
                          "from " + typeof(SupportMarketDataBean).FullName + ".win:keepall() " +
                          "full outer join " +
                          typeof(SupportBean).FullName + ".std:groupwin(TheString, IntPrimitive).win:length(2) " +
                          "on TheString = Symbol " +
                          "group by TheString, IntPrimitive, Symbol " +
                          "order by TheString, IntPrimitive, Symbol, Volume";

            EPStatement outerJoinView = _epService.EPAdministrator.CreateEPL(stmt);

            outerJoinView.Events += _listener.Update;

            SendEventMD("c0", 200L);
            SendEventMD("c3", 400L);

            SendEvent("c0", 0);
            SendEvent("c0", 1);
            SendEvent("c0", 2);
            SendEvent("c1", 0);
            SendEvent("c1", 1);
            SendEvent("c1", 2);
            SendEvent("c2", 0);
            SendEvent("c2", 1);
            SendEvent("c2", 2);

            IEnumerator <EventBean> iterator = outerJoinView.GetSafeEnumerator();

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(iterator);
            Assert.AreEqual(10, events.Length);

            EPAssertionUtil.AssertPropsPerRow(
                events, "TheString,IntPrimitive,Symbol,Volume".Split(','),
                new[]
            {
                new Object[] { null, null, "c3", 400L },
                new Object[] { "c0", 0, "c0", 200L },
                new Object[] { "c0", 1, "c0", 200L },
                new Object[] { "c0", 2, "c0", 200L },
                new Object[] { "c1", 0, null, null },
                new Object[] { "c1", 1, null, null },
                new Object[] { "c1", 2, null, null },
                new Object[] { "c2", 0, null, null },
                new Object[] { "c2", 1, null, null },
                new Object[] { "c2", 2, null, null }
            });
        }
Ejemplo n.º 26
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from SupportMarketDataBean#length(3)#linest(Price, Volume)";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeBean(70, 1000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN}},
                        new[] {new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN}});
                env.Milestone(1);

                env.SendEventBean(MakeBean(70.5, 1500));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"slope", 1000.0}, new object[] {"YIntercept", -69000.0}},
                        new[] {new object[] {"slope", double.NaN}, new object[] {"YIntercept", double.NaN}});
                env.Milestone(2);

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"slope", "YIntercept"},
                    new[] {new object[] {1000.0, -69000.0}});

                env.SendEventBean(MakeBean(70.1, 1200));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"slope", 928.571428587354}, new object[] {"YIntercept", -63952.38095349892}
                        },
                        new[] {new object[] {"slope", 1000.0}, new object[] {"YIntercept", -69000.0}});
                env.Milestone(3);

                env.SendEventBean(MakeBean(70.25, 1000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"slope", 877.5510204634593}, new object[] {"YIntercept", -60443.8775549068}
                        },
                        new[] {
                            new object[] {"slope", 928.571428587354}, new object[] {"YIntercept", -63952.38095349892}
                        });
                env.Milestone(4);

                env.UndeployAll();
            }
Ejemplo n.º 27
0
        public override void Run(EPServiceProvider epService)
        {
            // Testing the two forms of the case expression
            // Furthermore the test checks the different when clauses and actions related.
            string caseExpr = "select volume " +
                              "from " + typeof(SupportMarketDataBean).FullName + "#unique(symbol)#time(10)";

            EPStatement stmt     = epService.EPAdministrator.CreateEPL(caseExpr);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            SendMarketDataEvent(epService, "DELL", 1, 50);
            SendMarketDataEvent(epService, "DELL", 2, 50);
            object[] values = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.AreEqual(1, values.Length);
        }
Ejemplo n.º 28
0
            public void Run(RegressionEnvironment env)
            {
                var text =
                    "@Name('s0') select irstream * from SupportMarketDataBean#length(3)#weighted_avg(Price, Volume)";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeBean(10, 1000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"average", 10d}},
                        new[] {new object[] {"average", double.NaN}});

                env.Milestone(1);

                env.SendEventBean(MakeBean(11, 2000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"average", 10.666666666666666}},
                        new[] {new object[] {"average", 10.0}});

                env.Milestone(2);

                env.SendEventBean(MakeBean(10.5, 1500));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"average", 10.61111111111111}},
                        new[] {new object[] {"average", 10.666666666666666}});

                env.Milestone(3);

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"average"},
                    new[] {new object[] {10.61111111111111}});

                env.SendEventBean(MakeBean(9.5, 600));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"average", 10.597560975609756}},
                        new[] {new object[] {"average", 10.61111111111111}});

                env.Milestone(4);

                env.UndeployAll();
            }
Ejemplo n.º 29
0
        public void TestFullOuterIteratorGroupBy()
        {
            var stmt = "select theString, intPrimitive, symbol, volume " +
                       "from " + typeof(SupportMarketDataBean).FullName + "#keepall " +
                       "full outer join " +
                       typeof(SupportBean).FullName + "#groupwin(theString, intPrimitive)#length(2) " +
                       "on theString = symbol " +
                       "group by theString, intPrimitive, symbol " +
                       "order by theString, intPrimitive, symbol, volume";

            var outerJoinView = _epService.EPAdministrator.CreateEPL(stmt);

            outerJoinView.AddListener(_listener);

            SendEventMD("c0", 200L);
            SendEventMD("c3", 400L);

            SendEvent("c0", 0);
            SendEvent("c0", 1);
            SendEvent("c0", 2);
            SendEvent("c1", 0);
            SendEvent("c1", 1);
            SendEvent("c1", 2);
            SendEvent("c2", 0);
            SendEvent("c2", 1);
            SendEvent("c2", 2);

            var iterator = outerJoinView.GetSafeEnumerator();
            var events   = EPAssertionUtil.EnumeratorToArray(iterator);

            Assert.AreEqual(10, events.Length);

            EPAssertionUtil.AssertPropsPerRow(events, "theString,intPrimitive,symbol,volume".SplitCsv(),
                                              new object[][] {
                new object[] { null, null, "c3", 400L },
                new object[] { "c0", 0, "c0", 200L },
                new object[] { "c0", 1, "c0", 200L },
                new object[] { "c0", 2, "c0", 200L },
                new object[] { "c1", 0, null, null },
                new object[] { "c1", 1, null, null },
                new object[] { "c1", 2, null, null },
                new object[] { "c2", 0, null, null },
                new object[] { "c2", 1, null, null },
                new object[] { "c2", 2, null, null }
            });
        }
Ejemplo n.º 30
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from SupportMarketDataBean#length(3)#correl(Price, Volume)";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeBean(70, 1000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"correlation", double.NaN}},
                        new[] {new object[] {"correlation", double.NaN}});

                env.Milestone(1);

                env.SendEventBean(MakeBean(70.5, 1500));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"correlation", 1.0}},
                        new[] {new object[] {"correlation", double.NaN}});

                env.Milestone(2);

                env.SendEventBean(MakeBean(70.1, 1200));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"correlation", 0.9762210399358}},
                        new[] {new object[] {"correlation", 1.0}});

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"correlation"},
                    new[] {new object[] {0.9762210399358}});

                env.Milestone(3);

                env.SendEventBean(MakeBean(70.25, 1000));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"correlation", 0.7046340397673054}},
                        new[] {new object[] {"correlation", 0.9762210399358}});

                env.Milestone(4);

                env.UndeployAll();
            }