public void TestCanReuse() { _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new TimeBatchView(null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new ExprTimePeriodEvalDeltaConstMsec(1000), null, false, false, null))); Assert.IsTrue(_factory.CanReuse(new TimeWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), _factory, new ExprTimePeriodEvalDeltaConstMsec(1000000), null))); }
public void TestViewPushWithRefPoint() { long startTime = 50000; _schedulingServiceStub.Time = startTime; _myView = new TimeBatchView(new TimeBatchViewFactory(), SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_schedulingServiceStub), new ExprTimePeriodEvalDeltaConstMsec(TEST_INTERVAL_MSEC), 1505L, false, false, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap( new String[] { "A1", "A2", "A3" }); // Send new events to the view - should have scheduled a callback for X msec after _myView.Update(new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") }, null); Assert.IsTrue(_schedulingServiceStub.Added.Count == 1); Assert.IsTrue(_schedulingServiceStub.Added.Get(1505L) != null); _schedulingServiceStub.Added.Clear(); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") }, _myView.GetEnumerator()); SupportViewDataChecker.CheckOldData(_childView, null); SupportViewDataChecker.CheckNewData(_childView, null); // Data got batched, no data release till later // Pretend we have a callback, check data, check scheduled new callback _schedulingServiceStub.Time = (startTime + 1505); _myView.SendBatch(); EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator()); SupportViewDataChecker.CheckOldData(_childView, null); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") }); Assert.IsTrue(_schedulingServiceStub.Added.Count == 1); Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null); }
public void TestCanReuse() { Assert.IsFalse(_factory.CanReuse(new LastElementView(null))); EventType type = SizeView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); Assert.IsTrue(_factory.CanReuse(new SizeView(SupportStatementContextFactory.MakeAgentInstanceContext(), type, null))); }
public void SetUp() { var schema = new Dictionary <String, Object>(); schema["STDDEV"] = typeof(double?); _parentEventType = SupportEventTypeFactory.CreateMapType(schema); var addProps = new Dictionary <String, Object>(); addProps["Symbol"] = typeof(string); var mergeEventType = SupportEventAdapterService.Service.CreateAnonymousWrapperType( "test", _parentEventType, addProps); // Set up length window view and a test child view _myView = new AddPropertyValueOptionalView( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new String[] { "Symbol" }, "IBM", mergeEventType); _parentView = new SupportMapView(schema); _parentView.AddView(_myView); _childView = new SupportSchemaNeutralView(); _myView.AddView(_childView); }
public void TestGetValue() { ExprEvaluatorContext exprEvaluatorContext = SupportStatementContextFactory.MakeEvaluatorContext(); // apply 3 rows to group key 1, all aggregators evaluated their sub-expressions(constants 5 and 2) _service.ApplyEnter(new EventBean[1], _groupOneKey, exprEvaluatorContext); _service.ApplyEnter(new EventBean[1], _groupOneKey, exprEvaluatorContext); _service.ApplyEnter(new EventBean[1], _groupTwoKey, exprEvaluatorContext); _service.SetCurrentAccess(_groupOneKey, -1, null); Assert.AreEqual(10, _service.GetValue(0, -1, EvaluateParams.EmptyTrue)); Assert.AreEqual(4, _service.GetValue(1, -1, EvaluateParams.EmptyTrue)); _service.SetCurrentAccess(_groupTwoKey, -1, null); Assert.AreEqual(5, _service.GetValue(0, -1, EvaluateParams.EmptyTrue)); Assert.AreEqual(2, _service.GetValue(1, -1, EvaluateParams.EmptyTrue)); _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext); _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext); _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext); _service.ApplyLeave(new EventBean[1], _groupOneKey, exprEvaluatorContext); _service.SetCurrentAccess(_groupOneKey, -1, null); Assert.AreEqual(10 - 5, _service.GetValue(0, -1, EvaluateParams.EmptyTrue)); Assert.AreEqual(4 - 2, _service.GetValue(1, -1, EvaluateParams.EmptyTrue)); _service.SetCurrentAccess(_groupTwoKey, -1, null); Assert.AreEqual(5 - 15, _service.GetValue(0, -1, EvaluateParams.EmptyTrue)); Assert.AreEqual(2 - 6, _service.GetValue(1, -1, EvaluateParams.EmptyTrue)); }
public void SetUp() { _container = SupportContainer.Reset(); _factory = new GroupByViewFactory(); _viewFactoryContext = new ViewFactoryContext( SupportStatementContextFactory.MakeContext(_container), 1, null, null, false, -1, false); }
public static PatternContext MakeContext() { var container = SupportContainer.Instance; StatementContext stmtContext = SupportStatementContextFactory.MakeContext(container); return(new PatternContext(stmtContext, 1, new MatchedEventMapMeta(new String[0], false), false)); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new LastElementView(null), agentInstanceContext)); }
private void TryParameter(Object[] param) { LastElementViewFactory factory = new LastElementViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); Assert.IsTrue(factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()) is LastElementView); }
public void TestInvalid() { EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); try { _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { 50, 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected } try { _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "TheString", 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected } _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "LongPrimitive", 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.AreSame(parentType, _factory.EventType); }
public void SetUp() { _container = SupportContainer.Reset(); _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); var selectExprEventTypeRegistry = new SelectExprEventTypeRegistry( "abc", new StatementEventTypeRefImpl(_container.RWLockManager())); var factory = new SelectExprProcessorHelper( Collections.GetEmptyList <int>(), SupportSelectExprFactory.MakeSelectListFromIdent("TheString", "s0"), Collections.GetEmptyList <SelectExprStreamDesc>(), null, null, false, new SupportStreamTypeSvc1Stream(), _container.Resolve <EventAdapterService>(), null, selectExprEventTypeRegistry, _agentInstanceContext.StatementContext.EngineImportService, 1, "stmtname", null, new Configuration(_container), null, new TableServiceImpl(_container), null); var selectProcessor = factory.GetEvaluator(); _supportAggregationService = new SupportAggregationService(); var groupKeyNodes = new ExprEvaluator[2]; groupKeyNodes[0] = SupportExprNodeFactory.MakeIdentNode("IntPrimitive", "s0").ExprEvaluator; groupKeyNodes[1] = SupportExprNodeFactory.MakeIdentNode("IntBoxed", "s0").ExprEvaluator; var prototype = new ResultSetProcessorRowPerGroupFactory(selectProcessor, null, groupKeyNodes, null, true, false, null, false, false, false, false, null, false, 1, null); _processor = (ResultSetProcessorRowPerGroup)prototype.Instantiate(null, _supportAggregationService, _agentInstanceContext); }
public void TestCanReuse() { _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), _factory, 1, null))); Assert.IsTrue(_factory.CanReuse(new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), _factory, 1000, null))); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "IntPrimitive" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); }
public void TestCanReuse() { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Symbol", "Feed" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, _parents); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), null, true))); Assert.IsTrue(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesMD("Symbol", "Feed"), null, true))); }
public void TestAttaches() { // Should attach to anything as long as the fields exists EventType parentType = SupportEventTypeFactory.CreateBeanType( typeof(SupportBean)); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(new Object[] { "IntBoxed" })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(_container), null, null); }
private void TryParameter(Object[] @params, String fieldNameX, String fieldNameY) { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(@params)); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); RegressionLinestView view = (RegressionLinestView)_factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldNameX, view.ExpressionX.ToExpressionStringMinPrecedenceSafe()); Assert.AreEqual(fieldNameY, view.ExpressionY.ToExpressionStringMinPrecedenceSafe()); }
private void TryParameter(object[] parameters, string fieldNameX, string fieldNameY) { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(parameters)); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); CorrelationView view = (CorrelationView)_factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldNameX, ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(view.ExpressionX)); Assert.AreEqual(fieldNameY, ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(view.ExpressionY)); }
private void TryParameter(Object[] param, int size) { var factory = new LengthWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); var view = (LengthWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(size, view.Size); }
public void TestSchema() { EventType type = SizeView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); SizeView view = new SizeView(SupportStatementContextFactory.MakeAgentInstanceContext(), type, null); EventType eventType = view.EventType; Assert.AreEqual(typeof(long?), eventType.GetPropertyType(ViewFieldEnum.SIZE_VIEW__SIZE.GetName())); }
public virtual void TestEvaluate() { SupportAggregationResultFuture future = new SupportAggregationResultFuture(new Object[] { 10, 20 }); ValidatedNodeToTest.SetAggregationResultFuture(future, 1); AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); Assert.AreEqual(20, ValidatedNodeToTest.Evaluate(new EvaluateParams(null, false, agentInstanceContext))); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(_container), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.False(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.False(_factory.CanReuse(new LengthBatchView(null, _factory, 1, null), agentInstanceContext)); Assert.True(_factory.CanReuse(new LengthBatchView(null, _factory, 1000, null), agentInstanceContext)); }
public void SetUp() { _typeService1Stream = new SupportStreamTypeSvc1Stream(); _typeService3Stream = new SupportStreamTypeSvc3Stream(); _groupByList = new List <ExprNode>(); _orderByList = new List <OrderByItem>(); _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _stmtContext = _agentInstanceContext.StatementContext; }
private void TryParameter(Object param, long msec) { var factory = new TimeWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(_container), TestViewSupport.ToExprListBean(new Object[] { param })); var view = (TimeWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container)); Assert.AreEqual(msec, view.TimeDeltaComputation.DeltaAdd(0)); }
public void SetUp() { // Set the scheduling service to use _schedulingServiceStub = new SupportSchedulingServiceImpl(); // Set up length window view and a test child view _myView = new TimeWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_schedulingServiceStub), new TimeWindowViewFactory(), new ExprTimePeriodEvalDeltaConstMsec(TEST_WINDOW_MSEC), null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
private void TryParameter(Object[] param, long msec, long?referencePoint) { var factory = new TimeBatchViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); var view = (TimeBatchView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.IsTrue(new ExprTimePeriodEvalDeltaConstGivenDelta(msec).EqualsTimePeriod(view.TimeDeltaComputation)); Assert.AreEqual(referencePoint, view.InitialReferencePoint); }
public void SetUp() { // Set up length window view and a test child view _myView = new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), false); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void SetUp() { // Set up length window view and a test child view EventType type = SizeView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); _myView = new SizeView(SupportStatementContextFactory.MakeAgentInstanceContext(), type, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
private void TryParameter(Object param, String fieldName) { UniqueByPropertyViewFactory factory = new UniqueByPropertyViewFactory(); factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { param })); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); UniqueByPropertyView view = (UniqueByPropertyView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldName, view.CriteriaExpressions[0].ToExpressionStringMinPrecedenceSafe()); }
private void TryParameter(Object[] @params, String fieldName, long msec) { ExternallyTimedWindowViewFactory factory = new ExternallyTimedWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(@params)); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); ExternallyTimedWindowView view = (ExternallyTimedWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldName, view.TimestampExpression.ToExpressionStringMinPrecedenceSafe()); Assert.IsTrue(new ExprTimePeriodEvalDeltaConstGivenDelta(msec).EqualsTimePeriod(view.TimeDeltaComputation)); }
public void TestCanReuse() { EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { "LongBoxed", 1000 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongPrimitive"), null, new ExprTimePeriodEvalDeltaConstMsec(1000), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()))); Assert.IsFalse(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongBoxed"), null, new ExprTimePeriodEvalDeltaConstMsec(999), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()))); Assert.IsTrue(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongBoxed"), null, new ExprTimePeriodEvalDeltaConstMsec(1000000), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()))); }