public void TestAttaches() { // Should attach to anything as long as the fields exists EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)); _factory.SetViewParameters(_viewFactoryContext, new[] { SupportExprNodeFactory.MakeIdentNodeMD("Volume"), SupportExprNodeFactory.MakeIdentNodeMD("Price") }); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.AreEqual(typeof(double?), _factory.EventType.GetPropertyType(ViewFieldEnum.REGRESSION__SLOPE.GetName())); try { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Symbol", "Symbol" })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected; } }
public void TestGetPlan() { var descList = new OuterJoinDesc[] { SupportOuterJoinDescFactory.MakeDesc("IntPrimitive", "s0", "IntBoxed", "s1", OuterJoinType.LEFT) }; var queryGraph = new QueryGraph(2, null, false); var plan = QueryPlanBuilder.GetPlan(_typesPerStream, new OuterJoinDesc[0], queryGraph, null, new HistoricalViewableDesc(5), _dependencyGraph, null, new StreamJoinAnalysisResult(2), true, null, null); AssertPlan(plan); plan = QueryPlanBuilder.GetPlan(_typesPerStream, descList, queryGraph, null, new HistoricalViewableDesc(5), _dependencyGraph, null, new StreamJoinAnalysisResult(2), true, null, null); AssertPlan(plan); FilterExprAnalyzer.Analyze(SupportExprNodeFactory.MakeEqualsNode(), queryGraph, false); plan = QueryPlanBuilder.GetPlan(_typesPerStream, descList, queryGraph, null, new HistoricalViewableDesc(5), _dependencyGraph, null, new StreamJoinAnalysisResult(2), true, null, null); AssertPlan(plan); plan = QueryPlanBuilder.GetPlan(_typesPerStream, new OuterJoinDesc[0], queryGraph, null, new HistoricalViewableDesc(5), _dependencyGraph, null, new StreamJoinAnalysisResult(2), true, null, null); AssertPlan(plan); }
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(_container); var processor = SelectExprProcessorFactory.GetProcessor( _container, Collections.GetEmptyList <int>(), selectionList, false, null, null, null, new SupportStreamTypeSvc3Stream(), _container.Resolve <EventAdapterService>(), _statementResultService, null, _selectExprEventTypeRegistry, statementContext.EngineImportService, null, null, null, null, null, null, 1, null, null, null, new Configuration(_container), null, null, null, null, null); Assert.IsTrue(processor != null); }
public void TestCanReuse() { _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(new Object[] { "TheString", "LongPrimitive" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse( _factory.CanReuse( new GroupByViewImpl( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesBean( "TheString"), null))); Assert.IsTrue( _factory.CanReuse( new GroupByViewImpl( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesBean( "TheString", "LongPrimitive"), null))); _factory.SetViewParameters( _viewFactoryContext, TestViewSupport.ToExprListBean( new Object[] { SupportExprNodeFactory.MakeIdentNodesBean("TheString", "LongPrimitive") })); Assert.IsFalse( _factory.CanReuse( new GroupByViewImpl( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesBean( "TheString"), null))); Assert.IsTrue( _factory.CanReuse( new GroupByViewImpl( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesBean( "TheString", "LongPrimitive"), null))); }
public void SetUp() { _statementContext = SupportStatementContextFactory.MakeContext(); _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(); var expressions = SupportExprNodeFactory.MakeIdentNodesMD("Symbol"); _myGroupByView = new GroupByViewImpl(_agentInstanceContext, expressions, ExprNodeUtility.GetEvaluators(expressions)); var childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); var myMergeView = new MergeView(_agentInstanceContext, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), false); _ultimateChildView = new SupportBeanClassView(typeof(SupportMarketDataBean)); // This is the view hierarchy _myGroupByView.AddView(childView); childView.AddView(myMergeView); myMergeView.AddView(_ultimateChildView); SupportBeanClassView.Instances.Clear(); }
public void TestGetProcessorSimpleSelect() { // empty group-by and no event properties aggregated in select clause (wildcard), no having clause var wildcardSelect = new SelectClauseElementCompiled[] { new SelectClauseElementWildcard() }; var spec = MakeSpec(new SelectClauseSpecCompiled(wildcardSelect, false), null, _groupByList, null, null, _orderByList); var processor = ResultSetProcessorFactoryFactory.GetProcessorPrototype(spec, _stmtContext, _typeService3Stream, null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null, new Configuration()); Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorHandThroughFactory); // empty group-by with select clause elements var selectList = SupportSelectExprFactory.MakeNoAggregateSelectListUnnamed(); spec = MakeSpec(new SelectClauseSpecCompiled(selectList, false), null, _groupByList, null, null, _orderByList); processor = ResultSetProcessorFactoryFactory.GetProcessorPrototype(spec, _stmtContext, _typeService1Stream, null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null, new Configuration()); Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorHandThroughFactory); // non-empty group-by and wildcard select, group by ignored _groupByList.Add(SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0")); spec = MakeSpec(new SelectClauseSpecCompiled(wildcardSelect, false), null, _groupByList, null, null, _orderByList); processor = ResultSetProcessorFactoryFactory.GetProcessorPrototype(spec, _stmtContext, _typeService1Stream, null, new bool[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null, new Configuration()); Assert.IsTrue(processor.ResultSetProcessorFactory is ResultSetProcessorSimpleFactory); }
public void TestGetProcessorInvalid() { var selectionList = new SelectClauseElementCompiled[2]; var identNode = SupportExprNodeFactory.MakeIdentNode("DoubleBoxed", "s0"); var mathNode = SupportExprNodeFactory.MakeMathNode(); selectionList[0] = new SelectClauseExprCompiledSpec(identNode, "result", "result", false); selectionList[1] = new SelectClauseExprCompiledSpec(mathNode, "result", "result", false); try { SelectExprProcessorFactory.GetProcessor( Collections.GetEmptyList <int>(), selectionList, false, null, null, null, new SupportStreamTypeSvc3Stream(), null, null, null, null, null, null, null, null, null, null, null, 1, null, null, null, new Configuration(), null, null, null, null, null); Assert.Fail(); } catch (ExprValidationException) { // Expected } }
private static IList <ExprNode> MakeParams(Type[] clazz, String[] values) { var parameters = new List <ExprNode>(); if (values == null) { return(parameters); } for (int i = 0; i < values.Length; i++) { ExprNode node; String value = values[i]; if (clazz[i] == typeof(string)) { if (value.StartsWith("\"")) { value = value.Replace("\"", ""); node = new ExprConstantNodeImpl(value); } else { node = SupportExprNodeFactory.MakeIdentNodeBean(value); } } else if (clazz[i] == typeof(bool?)) { node = new ExprConstantNodeImpl(bool.Parse(value)); } else { node = new ExprConstantNodeImpl(int.Parse(value)); } parameters.Add(node); } return(parameters); }
public void SetUp() { _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); var selectExprEventTypeRegistry = new SelectExprEventTypeRegistry("abc", new StatementEventTypeRefImpl()); var factory = new SelectExprProcessorHelper( Collections.GetEmptyList <int>(), SupportSelectExprFactory.MakeSelectListFromIdent("TheString", "s0"), Collections.GetEmptyList <SelectExprStreamDesc>(), null, null, false, new SupportStreamTypeSvc1Stream(), SupportEventAdapterService.Service, null, selectExprEventTypeRegistry, _agentInstanceContext.StatementContext.EngineImportService, 1, "stmtname", null, new Configuration(), null, new TableServiceImpl(), null); var selectProcessor = factory.Evaluator; _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 TestFilter() { ExprNode topNode = SupportExprNodeFactory.Make2SubNodeAnd(); var pairOne = new EventBean[2]; pairOne[0] = MakeEvent(1, 2, "a"); pairOne[1] = MakeEvent(2, 1, "a"); var pairTwo = new EventBean[2]; pairTwo[0] = MakeEvent(1, 2, "a"); pairTwo[1] = MakeEvent(2, 999, "a"); var eventSet = new HashSet <MultiKey <EventBean> >(); eventSet.Add(new MultiKey <EventBean>(pairOne)); eventSet.Add(new MultiKey <EventBean>(pairTwo)); JoinSetFilter.Filter(topNode.ExprEvaluator, eventSet, true, null); Assert.AreEqual(1, eventSet.Count); Assert.AreSame(pairOne, eventSet.FirstOrDefault().Array); }
public void TestMatch() { SupportStreamImpl stream = new SupportStreamImpl(TEST_CLASS, 10); IList <ViewFactory> viewFactories = SupportViewSpecFactory.MakeFactoryListOne(stream.EventType); // No views under stream, no matches Pair <Viewable, IList <View> > result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(stream, result.First); Assert.AreEqual(3, viewFactories.Count); Assert.AreEqual(0, result.Second.Count); // One top view under the stream that doesn't match SupportBeanClassView testView = new SupportBeanClassView(TEST_CLASS); stream.AddView(new FirstElementView(null)); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(stream, result.First); Assert.AreEqual(3, viewFactories.Count); Assert.AreEqual(0, result.Second.Count); // Another top view under the stream that doesn't matche again testView = new SupportBeanClassView(TEST_CLASS); stream.AddView(new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), null, 999, null)); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(stream, result.First); Assert.AreEqual(3, viewFactories.Count); Assert.AreEqual(0, result.Second.Count); // One top view under the stream that does actually match LengthWindowView myLengthWindowView = new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), null, 1000, null); stream.AddView(myLengthWindowView); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(myLengthWindowView, result.First); Assert.AreEqual(2, viewFactories.Count); Assert.AreEqual(1, result.Second.Count); Assert.AreEqual(myLengthWindowView, result.Second[0]); // One child view under the top view that does not match testView = new SupportBeanClassView(TEST_CLASS); viewFactories = SupportViewSpecFactory.MakeFactoryListOne(stream.EventType); EventType type = UnivariateStatisticsView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1); UnivariateStatisticsViewFactory factory = new UnivariateStatisticsViewFactory(); factory.EventType = type; factory.FieldExpression = SupportExprNodeFactory.MakeIdentNodeBean("LongBoxed"); myLengthWindowView.AddView(new UnivariateStatisticsView(factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext())); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(1, result.Second.Count); Assert.AreEqual(myLengthWindowView, result.Second[0]); Assert.AreEqual(myLengthWindowView, result.First); Assert.AreEqual(2, viewFactories.Count); // Add child view under the top view that does match viewFactories = SupportViewSpecFactory.MakeFactoryListOne(stream.EventType); UnivariateStatisticsViewFactory factoryTwo = new UnivariateStatisticsViewFactory(); factoryTwo.EventType = type; factoryTwo.FieldExpression = SupportExprNodeFactory.MakeIdentNodeBean("IntPrimitive"); UnivariateStatisticsView myUnivarView = new UnivariateStatisticsView(factoryTwo, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); myLengthWindowView.AddView(myUnivarView); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(myUnivarView, result.First); Assert.AreEqual(1, viewFactories.Count); // Add ultimate child view under the child view that does match viewFactories = SupportViewSpecFactory.MakeFactoryListOne(stream.EventType); LastElementView lastElementView = new LastElementView(null); myUnivarView.AddView(lastElementView); result = ViewServiceHelper.MatchExistingViews(stream, viewFactories); Assert.AreEqual(lastElementView, result.First); Assert.AreEqual(0, viewFactories.Count); }
public void TestEvaluate() { SupportExprNodeFactory.Validate3Stream(_varNode); Assert.AreEqual(_varNode.Evaluate(new EvaluateParams(null, true, null)), "my_variable_value"); }
public void Run(RegressionEnvironment env) { EventType[] types = { env.Runtime.EventTypeService.GetEventTypePreconfigured("SupportBean_S0"), env.Runtime.EventTypeService.GetEventTypePreconfigured("SupportBean_S1") }; var epl = "select * from SupportBean_S0#keepall as S0, SupportBean_S1#keepall as S1 "; var planFullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(0, "i0") .SetIndexFullTableScan(1, "i1") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i1"))) .SetLookupPlanInner(1, new FullTableScanLookupPlanForge(1, 0, false, types, GetIndexKey("i0"))) .Get(); // test "any" var excludeAny = "@Hint('exclude_plan(true)')"; TryAssertionJoin(env, epl, planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = P10", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = 'abc'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 = (P10 || 'A')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 = 'abc'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > P10", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 > 'A'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 > (P10 || 'A')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between P10 and P11", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between 'a' and P11", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between 'a' and 'c'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 between P10 and 'c'", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in (P10, P11)", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in ('a', P11)", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P00 in ('a', 'b')", planFullTableScan); TryAssertionJoin(env, excludeAny + epl + " where P10 in (P00, P01)", planFullTableScan); // test EQUALS var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner( 0, new FullTableScanLookupPlanForge( 0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new IndexedTableLookupPlanHashedOnlyForge( 1, 0, false, types, GetIndexKey("i1"), new[] { SupportExprNodeFactory.MakeKeyed("P10") }, null, null, null)) .Get(); var eplWithWhereEquals = epl + " where P00 = P10"; TryAssertionJoin( env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")') @Hint('exclude_plan(from_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamname=\"S0\")') @Hint('exclude_plan(from_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamname=\"S1\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamname=\"S0\")') @Hint('exclude_plan(to_streamname=\"S1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(from_streamnum=0 and to_streamnum = 1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamnum=1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(to_streamnum = 1, from_streamnum = 0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin( env, "@Hint('exclude_plan(opname=\"equals\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(exprs.anyOf(v-> v=\"P00\"))')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin( env, "@Hint('exclude_plan(\"P10\" in (exprs))')" + eplWithWhereEquals, planFullTableScan); // test greater (relop) var planGreater = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new SortedTableLookupPlanForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeLess("P10"), null)) .Get(); var eplWithWhereGreater = epl + " where P00 > P10"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereGreater, planGreater); TryAssertionJoin( env, "@Hint('exclude_plan(opname=\"relop\")')" + eplWithWhereGreater, planFullTableScan); // test range (relop) var planRange = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new SortedTableLookupPlanForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeIn("P10", "P11"), null)) .Get(); var eplWithWhereRange = epl + " where P00 between P10 and P11"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithWhereRange, planRange); TryAssertionJoin(env, "@Hint('exclude_plan(opname=\"relop\")')" + eplWithWhereRange, planFullTableScan); // test in (relop) var planIn = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "P00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("i2"))) .SetLookupPlanInner( 1, new InKeywordTableLookupPlanSingleIdxForge( 1, 0, false, types, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("P10", "P11"))) .Get(); var eplWithIn = epl + " where P00 in (P10, P11)"; TryAssertionJoin(env, "@Hint('exclude_plan(from_streamnum=0)')" + eplWithIn, planIn); TryAssertionJoin(env, "@Hint('exclude_plan(opname=\"inkw\")')" + eplWithIn, planFullTableScan); env.UndeployAll(); }
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 TestGetType() { SupportExprNodeFactory.Validate3Stream(_varNode); Assert.AreEqual(typeof(string), _varNode.ConstantType); }
public void TestDeepEquals() { Assert.IsFalse(ExprNodeUtility.DeepEquals(SupportExprNodeFactory.Make2SubNodeAnd(), SupportExprNodeFactory.Make3SubNodeAnd(), false)); Assert.IsFalse(ExprNodeUtility.DeepEquals(SupportExprNodeFactory.MakeEqualsNode(), SupportExprNodeFactory.MakeMathNode(), false)); Assert.IsTrue(ExprNodeUtility.DeepEquals(SupportExprNodeFactory.MakeMathNode(), SupportExprNodeFactory.MakeMathNode(), false)); Assert.IsFalse(ExprNodeUtility.DeepEquals(SupportExprNodeFactory.MakeMathNode(), SupportExprNodeFactory.Make2SubNodeAnd(), false)); Assert.IsTrue(ExprNodeUtility.DeepEquals(SupportExprNodeFactory.Make3SubNodeAnd(), SupportExprNodeFactory.Make3SubNodeAnd(), false)); }
public void SetUp() { _container = SupportContainer.Reset(); _inNodeNormal = SupportExprNodeFactory.MakeInSetNode(false); _inNodeNotIn = SupportExprNodeFactory.MakeInSetNode(true); }
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)); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Symbol", "Feed" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(_container), null, _parents); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), null, true), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesMD("Symbol", "Feed"), null, true), agentInstanceContext)); }
public void SetUp() { _prevNode = SupportExprNodeFactory.MakePreviousNode(); }
private void RunAssertionJoin(EPServiceProvider epService) { string epl = "select * from S0#keepall as s0, S1#keepall as s1 "; QueryPlan planFullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(0, "i0") .SetIndexFullTableScan(1, "i1") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i1"))) .SetLookupPlanInner(1, new FullTableScanLookupPlan(1, 0, GetIndexKey("i0"))) .Get(); // test "any" string excludeAny = "@Hint('Exclude_plan(true)')"; TryAssertionJoin(epService, epl, planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = p10", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = 'abc'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 = (p10 || 'A')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 = 'abc'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > p10", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 > 'A'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 > (p10 || 'A')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between p10 and p11", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between 'a' and p11", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between 'a' and 'c'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 between p10 and 'c'", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in (p10, p11)", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in ('a', p11)", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p00 in ('a', 'b')", planFullTableScan); TryAssertionJoin(epService, excludeAny + epl + " where p10 in (p00, p01)", planFullTableScan); // test EQUALS QueryPlan planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new IndexedTableLookupPlanSingle(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeKeyed("p10"))) .Get(); string eplWithWhereEquals = epl + " where p00 = p10"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")') @Hint('Exclude_plan(from_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamname=\"s0\")') @Hint('Exclude_plan(from_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamname=\"s1\")')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamname=\"s0\")') @Hint('Exclude_plan(to_streamname=\"s1\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0 and to_streamnum = 1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamnum=1)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(to_streamnum = 1, from_streamnum = 0)')" + eplWithWhereEquals, planEquals); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"equals\")')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(exprs.anyOf(v=> v=\"p00\"))')" + eplWithWhereEquals, planFullTableScan); TryAssertionJoin(epService, "@Hint('Exclude_plan(\"p10\" in (exprs))')" + eplWithWhereEquals, planFullTableScan); // test greater (relop) QueryPlan planGreater = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new SortedTableLookupPlan(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeLess("p10"))) .Get(); string eplWithWhereGreater = epl + " where p00 > p10"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereGreater, planGreater); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"relop\")')" + eplWithWhereGreater, planFullTableScan); // test range (relop) QueryPlan planRange = SupportQueryPlanBuilder.Start(2) .AddIndexBtreeSingle(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new SortedTableLookupPlan(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeRangeIn("p10", "p11"))) .Get(); string eplWithWhereRange = epl + " where p00 between p10 and p11"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithWhereRange, planRange); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"relop\")')" + eplWithWhereRange, planFullTableScan); // test in (relop) QueryPlan planIn = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(0, "i1", "p00") .SetIndexFullTableScan(1, "i2") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("i2"))) .SetLookupPlanInner(1, new InKeywordTableLookupPlanSingleIdx(1, 0, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p10", "p11"))) .Get(); string eplWithIn = epl + " where p00 in (p10, p11)"; TryAssertionJoin(epService, "@Hint('Exclude_plan(from_streamnum=0)')" + eplWithIn, planIn); TryAssertionJoin(epService, "@Hint('Exclude_plan(opname=\"inkw\")')" + eplWithIn, planFullTableScan); epService.EPAdministrator.DestroyAllStatements(); }
public void TestGetPlan() { OuterJoinDesc[] descList = { SupportOuterJoinDescFactory.MakeDesc( container, "IntPrimitive", "s0", "IntBoxed", "s1", OuterJoinType.LEFT) }; var queryGraph = new QueryGraphForge(2, null, false); var plan = QueryPlanBuilder.GetPlan( typesPerStream, new OuterJoinDesc[0], queryGraph, null, new HistoricalViewableDesc(5), dependencyGraph, null, new StreamJoinAnalysisResultCompileTime(2), true, null, null); AssertPlan(plan.Forge); plan = QueryPlanBuilder.GetPlan( typesPerStream, descList, queryGraph, null, new HistoricalViewableDesc(5), dependencyGraph, null, new StreamJoinAnalysisResultCompileTime(2), true, null, null); AssertPlan(plan.Forge); FilterExprAnalyzer.Analyze(SupportExprNodeFactory.GetInstance(container).MakeEqualsNode(), queryGraph, false); plan = QueryPlanBuilder.GetPlan( typesPerStream, descList, queryGraph, null, new HistoricalViewableDesc(5), dependencyGraph, null, new StreamJoinAnalysisResultCompileTime(2), true, null, null); AssertPlan(plan.Forge); plan = QueryPlanBuilder.GetPlan( typesPerStream, new OuterJoinDesc[0], queryGraph, null, new HistoricalViewableDesc(5), dependencyGraph, null, new StreamJoinAnalysisResultCompileTime(2), true, null, null); AssertPlan(plan.Forge); }
public void TestQueryPlan3Stream() { var epl = "select * from S0 as s0 unidirectional, S1.win:keepall(), S2.win:keepall() "; // 3-stream join with in-multiindex directional var planInMidx = new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("i1a", "i1b"), SupportExprNodeFactory.MakeIdentExprNode("p00")); RunAssertion(epl + " where p00 in (p10, p11)", SupportQueryPlanBuilder.Start(3) .AddIndexHashSingleNonUnique(1, "i1a", "p10") .AddIndexHashSingleNonUnique(1, "i1b", "p11") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction(0, "s0", new LookupInstructionPlan[] { new LookupInstructionPlan(0, "s0", new int[] { 1 }, new TableLookupPlan[] { planInMidx }, null, new bool[3]), new LookupInstructionPlan(0, "s0", new int[] { 2 }, new TableLookupPlan[] { new FullTableScanLookupPlan(1, 2, GetIndexKey("i2")) }, null, new bool[3]) }) .Get()); var planInMidxMulitiSrc = new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("i1", "i2"), SupportExprNodeFactory.MakeIdentExprNode("p00")); RunAssertion(epl + " where p00 in (p10, p20)", SupportQueryPlanBuilder.Start(3) .SetIndexFullTableScan(1, "i1") .SetIndexFullTableScan(2, "i2") .SetLookupPlanInstruction(0, "s0", new LookupInstructionPlan[] { new LookupInstructionPlan(0, "s0", new int[] { 1 }, new TableLookupPlan[] { new FullTableScanLookupPlan(0, 1, GetIndexKey("i1")) }, null, new bool[3]), new LookupInstructionPlan(0, "s0", new int[] { 2 }, new TableLookupPlan[] { new FullTableScanLookupPlan(1, 2, GetIndexKey("i2")) }, null, new bool[3]) }) .Get()); // 3-stream join with in-singleindex directional var planInSidx = new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p00", "p01")); RunAssertion(epl + " where p10 in (p00, p01)", GetSingleIndexPlan(planInSidx)); // 3-stream join with in-singleindex multi-sourced var planInSingleMultiSrc = new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("i1"), SupportExprNodeFactory.MakeIdentExprNodes("p00")); RunAssertion(epl + " where p10 in (p00, p20)", GetSingleIndexPlan(planInSingleMultiSrc)); }
public void SetUp() { _regexpNodeNormal = SupportExprNodeFactory.MakeRegexpNode(false); _regexpNodeNot = SupportExprNodeFactory.MakeRegexpNode(true); }
public void TestQueryPlan2Stream() { var epl = "select * from S0 as s0 unidirectional, S1.win:keepall() "; var fullTableScan = SupportQueryPlanBuilder.Start(2) .SetIndexFullTableScan(1, "a") .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("a"))).Get(); // 2-stream unidirectional joins RunAssertion(epl, fullTableScan); var planEquals = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new IndexedTableLookupPlanSingle(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeKeyed("p00"))).Get(); RunAssertion(epl + "where p00 = p10", planEquals); RunAssertion(epl + "where p00 = p10 and p00 in (p11, p12, p13)", planEquals); var planInMultiInner = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p11") .AddIndexHashSingleNonUnique(1, "b", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get(); RunAssertion(epl + "where p00 in (p11, p12)", planInMultiInner); RunAssertion(epl + "where p00 = p11 or p00 = p12", planInMultiInner); var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner) .SetLookupPlanOuter(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get(); var eplOuterJoin = "select * from S0 as s0 unidirectional full outer join S1.win:keepall() "; RunAssertion(eplOuterJoin + "where p00 in (p11, p12)", planInMultiOuter); var planInMultiWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p11") .AddIndexHashSingleNonUnique(1, "b", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get(); RunAssertion(epl + "where 'A' in (p11, p12)", planInMultiWConst); RunAssertion(epl + "where 'A' = p11 or 'A' = p12", planInMultiWConst); var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p12") .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get(); RunAssertion(epl + "where 'A' in ('B', p12)", planInMultiWAddConst); RunAssertion(epl + "where 'A' in ('B', 'C')", fullTableScan); var planInSingle = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("p00", "p01"))).Get(); RunAssertion(epl + "where p10 in (p00, p01)", planInSingle); var planInSingleWConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "p01"))).Get(); RunAssertion(epl + "where p10 in ('A', p01)", planInSingleWConst); var planInSingleJustConst = SupportQueryPlanBuilder.Start(2) .AddIndexHashSingleNonUnique(1, "a", "p10") .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B"))).Get(); RunAssertion(epl + "where p10 in ('A', 'B')", planInSingleJustConst); }
public void SetUp() { _priorNode = SupportExprNodeFactory.MakePriorNode(); }
public void SetUp() { _container = SupportContainer.Reset(); // Set up sum view and a test child view EventType type = RegressionLinestView.CreateEventType(SupportStatementContextFactory.MakeContext(_container), null, 1); RegressionLinestViewFactory viewFactory = new RegressionLinestViewFactory(); _myView = new RegressionLinestView(viewFactory, SupportStatementContextFactory.MakeAgentInstanceContext(_container), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void SetUp() { exprNode = SupportExprNodeFactory.MakeMathNode(); }
public void SetUp() { _likeNodeNormal = SupportExprNodeFactory.MakeLikeNode(false, null); _likeNodeNot = SupportExprNodeFactory.MakeLikeNode(true, null); _likeNodeNormalEscaped = SupportExprNodeFactory.MakeLikeNode(false, "!"); }
public void SetUp() { _container = SupportContainer.Reset(); _regexpNodeNormal = SupportExprNodeFactory.MakeRegexpNode(false); _regexpNodeNot = SupportExprNodeFactory.MakeRegexpNode(true); }