public void TestMaxTimeWindow() { SendTimer(0); var viewExpr = "select irstream Volume, max(Price) as maxVol" + " from " + typeof(SupportMarketDataBean).FullName + ".win:time(1 sec) " + "output every 1 seconds"; var stmt = _epService.EPAdministrator.CreateEPL(viewExpr); stmt.AddListener(_listener); SendEvent("SYM1", 1d); SendEvent("SYM1", 2d); _listener.Reset(); // moves all events out of the window, SendTimer(1000); // newdata is 2 eventa, old data is the same 2 events, therefore the sum is null UniformPair <EventBean[]> result = _listener.GetDataListsFlattened(); Assert.AreEqual(2, result.First.Length); Assert.AreEqual(1.0, result.First[0].Get("maxVol")); Assert.AreEqual(2.0, result.First[1].Get("maxVol")); Assert.AreEqual(2, result.Second.Length); Assert.AreEqual(null, result.Second[0].Get("maxVol")); Assert.AreEqual(null, result.Second[1].Get("maxVol")); }
private void RunAssertion() { _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); SupportUpdateListener listenerOne = new SupportUpdateListener(); String[] fields = "c0,c1".Split(','); EPStatement statementOne = _epService.EPAdministrator.CreateEPL("context NestedContext " + "select TheString as c0, Sum(IntPrimitive) as c1 from SupportBean \n" + "output last when terminated"); statementOne.Events += listenerOne.Update; _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); _epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); _epService.EPRuntime.SendEvent(new CurrentTimeEvent(10000)); EPAssertionUtil.AssertPropsPerRow(listenerOne.GetDataListsFlattened(), fields, new Object[][] { new Object[] { "E1", 1 }, new Object[] { "E2", 2 } }, null); listenerOne.Reset(); _epService.EPRuntime.SendEvent(new SupportBean("E1", 3)); _epService.EPRuntime.SendEvent(new SupportBean("E3", 4)); _epService.EPRuntime.SendEvent(new CurrentTimeEvent(20000)); EPAssertionUtil.AssertPropsPerRow(listenerOne.GetDataListsFlattened(), fields, new Object[][] { new Object[] { "E1", 3 }, new Object[] { "E3", 4 } }, null); }
private void RunAssertionUniqueInBatch(EPServiceProvider epService) { string stmtOne = "insert into MyStream select symbol, price from " + typeof(SupportMarketDataBean).FullName + "#time_batch(1 sec)"; epService.EPAdministrator.CreateEPL(stmtOne); SendTimer(epService, 0); string epl = "select symbol " + "from MyStream#time_batch(1 sec)#unique(symbol) " + "group by symbol"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(epService, "IBM", 100); SendEvent(epService, "IBM", 101); SendEvent(epService, "IBM", 102); SendTimer(epService, 1000); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, 2000); UniformPair <EventBean[]> received = listener.GetDataListsFlattened(); Assert.AreEqual("IBM", received.First[0].Get("symbol")); epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionJoinSortWindow(EPServiceProvider epService) { SendTimer(epService, 0); string epl = "select irstream volume, max(price) as maxVol" + " from " + typeof(SupportMarketDataBean).FullName + "#sort(1, volume desc) as s0," + typeof(SupportBean).FullName + "#keepall as s1 " + "output every 1 seconds"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("JOIN_KEY", -1)); SendEvent(epService, "JOIN_KEY", 1d); SendEvent(epService, "JOIN_KEY", 2d); listener.Reset(); // moves all events out of the window, SendTimer(epService, 1000); // newdata is 2 eventa, old data is the same 2 events, therefore the sum is null UniformPair <EventBean[]> result = listener.GetDataListsFlattened(); Assert.AreEqual(2, result.First.Length); Assert.AreEqual(1.0, result.First[0].Get("maxVol")); Assert.AreEqual(2.0, result.First[1].Get("maxVol")); Assert.AreEqual(1, result.Second.Length); Assert.AreEqual(2.0, result.Second[0].Get("maxVol")); stmt.Dispose(); }
public void TestUniqueInBatch() { var stmtOne = "insert into MyStream select Symbol, price from " + typeof(SupportMarketDataBean).FullName + ".win:time_batch(1 sec)"; _epService.EPAdministrator.CreateEPL(stmtOne); SendTimer(0); var viewExpr = "select Symbol " + "from MyStream.win:time_batch(1 sec).std:unique(Symbol) " + "group by Symbol"; var selectTestView = _epService.EPAdministrator.CreateEPL(viewExpr); selectTestView.AddListener(_listener); SendEvent("IBM", 100); SendEvent("IBM", 101); SendEvent("IBM", 102); SendTimer(1000); Assert.IsFalse(_listener.IsInvoked); SendTimer(2000); UniformPair <EventBean[]> received = _listener.GetDataListsFlattened(); Assert.AreEqual("IBM", received.First[0].Get("Symbol")); }
public void TestExpressionGrouped() { _epService.EPAdministrator.Configuration.AddEventType <SupportBeanTimestamp>(); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select irstream * from SupportBeanTimestamp.std:groupwin(timestamp.getDayOfWeek()).win:length(2)"); stmt.AddListener(_listener); _epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E1", DateTimeParser.ParseDefaultMSec("2002-01-01T9:0:00.000"))); _epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E2", DateTimeParser.ParseDefaultMSec("2002-01-08T9:0:00.000"))); _epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E3", DateTimeParser.ParseDefaultMSec("2002-01-015T9:0:00.000"))); Assert.AreEqual(1, _listener.GetDataListsFlattened().Second.Length); }
private void RunAssertionExpressionGrouped(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBeanTimestamp)); EPStatement stmt = epService.EPAdministrator.CreateEPL ("select irstream * from SupportBeanTimestamp#groupwin(timestamp.getDayOfWeek())#length(2)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E1", DateTimeParser.ParseDefaultMSec("2002-01-01T09:0:00.000"))); epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E2", DateTimeParser.ParseDefaultMSec("2002-01-08T09:0:00.000"))); epService.EPRuntime.SendEvent(new SupportBeanTimestamp("E3", DateTimeParser.ParseDefaultMSec("2002-01-015T09:0:00.000"))); Assert.AreEqual(1, listener.GetDataListsFlattened().Second.Length); stmt.Dispose(); }