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() { 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 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 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 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); }
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); }
public void TestCanReuse() { factory.SetViewParameters(new ViewFactoryContext(null, 1, 1, null, null), TestViewSupport.ToExprListMD(new object[] { "Price", "Volume" })); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(factory.CanReuse(new FirstElementView(null))); EventType type = CorrelationView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); Assert.IsFalse(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null))); Assert.IsFalse(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Feed"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null))); Assert.IsTrue(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null))); }
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()))); }
public void SetUp() { StatementContext stmtContext = SupportStatementContextFactory.MakeContext(new SchedulingServiceImpl(new TimeSourceServiceImpl())); _scheduleService = stmtContext.SchedulingService; PatternAgentInstanceContext agentInstanceContext = SupportPatternContextFactory.MakePatternAgentInstanceContext(_scheduleService); _quitable = new SupportQuitable(agentInstanceContext); _guard = new TimerWithinGuard(1000, _quitable); }
public void SetUp() { // Set up sum view and a test child view EventType type = RegressionLinestView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); RegressionLinestViewFactory viewFactory = new RegressionLinestViewFactory(); _myView = new RegressionLinestView(viewFactory, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
private static IList <ViewFactory> MakeFactories(EventType parentEventType, IList <ViewSpec> viewSpecs) { ViewServiceImpl svc = new ViewServiceImpl(); ViewFactoryChain viewFactories = svc.CreateFactories( 1, parentEventType, ViewSpec.ToArray(viewSpecs), StreamSpecOptions.DEFAULT, SupportStatementContextFactory.MakeContext(SupportContainer.Instance), false, -1); return(viewFactories.FactoryChain); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Price", "Volume" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); EventType type = RegressionLinestView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); Assert.IsFalse(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null), agentInstanceContext)); }
private void TryParameter(Object[] parameters, String[] fieldNames) { var factory = new GroupByViewFactory(); factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(parameters)); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); var view = (GroupByView)factory.MakeView( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container)); Assert.AreEqual(fieldNames[0], view.CriteriaExpressions[0].ToExpressionStringMinPrecedenceSafe()); }
public void TestGetProcessorValid() { var selectionList = new SelectClauseElementCompiled[1]; var identNode = SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0"); selectionList[0] = new SelectClauseExprCompiledSpec(identNode, "result", null, false); var statementContext = SupportStatementContextFactory.MakeContext(); var processor = SelectExprProcessorFactory.GetProcessor(Collections.GetEmptyList <int>(), selectionList, false, null, null, null, new SupportStreamTypeSvc3Stream(), SupportEventAdapterService.Service, _statementResultService, null, _selectExprEventTypeRegistry, statementContext.MethodResolutionService, null, null, null, null, null, null, null, null, null, null, new Configuration(), null, null, null); Assert.IsTrue(processor != null); }
public void SetUp() { _container = SupportContainer.Reset(); var stmtContext = SupportStatementContextFactory.MakeContext( _container, new SchedulingServiceImpl(new TimeSourceServiceImpl(), _container)); _scheduleService = stmtContext.SchedulingService; var agentInstanceContext = SupportPatternContextFactory.MakePatternAgentInstanceContext(_scheduleService); _quitable = new SupportQuitable(agentInstanceContext); _guard = new TimerWithinGuard(1000, _quitable); }
public void SetUp() { // Set up sum view and a test child view var type = UnivariateStatisticsView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); var factory = new UnivariateStatisticsViewFactory(); factory.EventType = type; factory.FieldExpression = SupportExprNodeFactory.MakeIdentNodeMD("Price"); _myView = new UnivariateStatisticsView(factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void SetUp() { _container = SupportContainer.Reset(); _factory = new MergeViewFactory(); _viewFactoryContext = new ViewFactoryContext(SupportStatementContextFactory.MakeContext(_container), 1, null, null, false, -1, false); _parents = new List <ViewFactory>(); GroupByViewFactory groupByView = new GroupByViewFactory(); groupByView.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Symbol", "Feed" })); groupByView.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(_container), null, null); _parents.Add(groupByView); }
public void SetUp() { _beginState = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[0], false)); _scheduleService = new SchedulingServiceImpl(new TimeSourceServiceImpl()); StatementContext stmtContext = SupportStatementContextFactory.MakeContext(_scheduleService); _context = new PatternContext(stmtContext, 1, new MatchedEventMapMeta(new String[0], false), false); _agentContext = SupportPatternContextFactory.MakePatternAgentInstanceContext(_scheduleService); _evaluator = new SupportObserverEvaluator(_agentContext); _observer = new TimerIntervalObserver(1000, _beginState, _evaluator); }
public void TestCanReuse() { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Price", "Volume" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); EventType type = WeightedAverageView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); WeightedAverageViewFactory factoryTwo = new WeightedAverageViewFactory(); factoryTwo.FieldNameX = SupportExprNodeFactory.MakeIdentNodeMD("Price"); factoryTwo.EventType = type; factoryTwo.FieldNameWeight = SupportExprNodeFactory.MakeIdentNodeMD("Price"); Assert.IsFalse(_factory.CanReuse(new WeightedAverageView(factoryTwo, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()))); factoryTwo.FieldNameWeight = SupportExprNodeFactory.MakeIdentNodeMD("Volume"); Assert.IsTrue(_factory.CanReuse(new WeightedAverageView(factoryTwo, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()))); }
public void SetUp() { // Set up sum view and a test child view EventType type = WeightedAverageView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); WeightedAverageViewFactory factory = new WeightedAverageViewFactory(); factory.FieldNameX = SupportExprNodeFactory.MakeIdentNodeMD("Price"); factory.EventType = type; factory.FieldNameWeight = SupportExprNodeFactory.MakeIdentNodeMD("Volume"); _myView = new WeightedAverageView(factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public static PatternAgentInstanceContext MakePatternAgentInstanceContext(SchedulingService scheduleService) { StatementContext stmtContext; if (scheduleService == null) { stmtContext = SupportStatementContextFactory.MakeContext(); } else { stmtContext = SupportStatementContextFactory.MakeContext(scheduleService); } PatternContext context = new PatternContext(stmtContext, 1, new MatchedEventMapMeta(new String[0], false), false); return(new PatternAgentInstanceContext(context, SupportStatementContextFactory.MakeAgentInstanceContext(), false)); }
public void SetUp() { _container = SupportContainer.Reset(); // Set up sum view and a test child view EventType type = CorrelationView.CreateEventType(SupportStatementContextFactory.MakeContext(_container), null, 1); CorrelationViewFactory factory = new CorrelationViewFactory(); _myView = new CorrelationView(factory, SupportStatementContextFactory.MakeAgentInstanceContext(_container), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
private void TryInvalidParameter(Object[] parameters) { try { var factory = new GroupByViewFactory(); factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(parameters)); factory.Attach( SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); Assert.Fail(); } catch (ViewParameterException) { // expected } }
public void TestGetCache() { var statementContext = SupportStatementContextFactory.MakeContext(); var dataCacheFactory = new DataCacheFactory(); Assert.That(_databaseServiceImpl.GetDataCache("name1", null, null, dataCacheFactory, 0), Is.InstanceOf <DataCacheNullImpl>()); var lru = (DataCacheLRUImpl)_databaseServiceImpl.GetDataCache("name2", statementContext, null, dataCacheFactory, 0); Assert.AreEqual(10000, lru.CacheSize); var exp = (DataCacheExpiringImpl)_databaseServiceImpl.GetDataCache("name3", statementContext, null, dataCacheFactory, 0); Assert.AreEqual(1.0d, exp.MaxAgeSec); Assert.AreEqual(3.0d, exp.PurgeIntervalSec); }
public void TestCanReuse() { StatementContext context = SupportStatementContextFactory.MakeContext(); _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Volume"), new ExprEvaluator[0], new bool[] { true }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 99, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null))); _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price", "Volume" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Volume"), new ExprEvaluator[0], new bool[] { false, false }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Symbol"), new ExprEvaluator[0], new bool[] { true, false }, 100, null, false, null))); }
public void TestDBStatementViewFactory() { DBStatementStreamSpec spec = new DBStatementStreamSpec("s0", ViewSpec.EMPTY_VIEWSPEC_ARRAY, "mydb", "select * from mytesttable where mybigint=${idnum}", null); EventCollection eventCollection = DatabasePollingViewableFactory.CreateDBStatementView( 1, 1, spec, SupportDatabaseService.MakeService(), SupportEventAdapterService.Service, null, null, null, null, true, new DataCacheFactory(), SupportStatementContextFactory.MakeContext()); Assert.AreEqual(typeof(long?), eventCollection.EventType.GetPropertyType("mybigint")); Assert.AreEqual(typeof(string), eventCollection.EventType.GetPropertyType("myvarchar")); Assert.AreEqual(typeof(bool?), eventCollection.EventType.GetPropertyType("mybool")); Assert.AreEqual(typeof(decimal?), eventCollection.EventType.GetPropertyType("mynumeric")); Assert.AreEqual(typeof(decimal?), eventCollection.EventType.GetPropertyType("mydecimal")); }
public void SetUp() { _container = SupportContainer.Reset(); var inputProperties = new[] { "s0.IntPrimitive" }; var dataCache = new DataCacheLRUImpl(100); var resultProperties = new Dictionary <String, Object>(); resultProperties["myvarchar"] = typeof(string); var resultEventType = _container.Resolve <EventAdapterService>().CreateAnonymousMapType("test", resultProperties, true); var pollResults = new Dictionary <MultiKey <Object>, IList <EventBean> >(); pollResults.Put(new MultiKey <Object>(new Object[] { -1 }), new List <EventBean>()); pollResults.Put(new MultiKey <Object>(new Object[] { 500 }), new List <EventBean>()); var supportPollingStrategy = new SupportPollingStrategy(pollResults); _pollingViewable = new DatabasePollingViewable( 1, inputProperties, supportPollingStrategy, dataCache, resultEventType, _container.Resolve <IThreadLocalManager>()); var sqlParameters = new Dictionary <int, IList <ExprNode> >(); sqlParameters.Put(1, ((ExprNode) new ExprIdentNodeImpl("IntPrimitive", "s0")).AsSingleton()); _pollingViewable.Validate( null, new SupportStreamTypeSvc3Stream(), null, null, null, null, null, null, null, null, sqlParameters, null, SupportStatementContextFactory.MakeContext(_container)); _indexingStrategy = new ProxyPollResultIndexingStrategy { ProcIndex = (pollResult, isActiveCache, statementContext) => new EventTable[] { new UnindexedEventTableList(pollResult, -1) }, ProcToQueryPlan = () => GetType().Name + " unindexed" }; }
public void SetUp() { var selectExprEventTypeRegistry = new SelectExprEventTypeRegistry("abc", new StatementEventTypeRefImpl()); var statementContext = SupportStatementContextFactory.MakeContext(); var factory = new SelectExprProcessorHelper( Collections.GetEmptyList <int>(), SupportSelectExprFactory.MakeNoAggregateSelectList(), Collections.GetEmptyList <SelectExprStreamDesc>(), null, null, false, new SupportStreamTypeSvc1Stream(), SupportEventAdapterService.Service, null, selectExprEventTypeRegistry, statementContext.EngineImportService, 1, "stmtname", null, new Configuration(), null, new TableServiceImpl(), null); _selectExprProcessor = factory.Evaluator; _orderByProcessor = null; var prototype = new ResultSetProcessorSimpleFactory(_selectExprProcessor, null, true, null, false, null, 1); _outputProcessorAll = (ResultSetProcessorSimple)prototype.Instantiate(null, null, null); }
public void TestAttaches() { // Should attach to anything as long as the fields exists EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)); _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price" })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); try { _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { true, "Price" })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException) { // expected; } }