public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var filters = new[] { "A!=1 and A!=2 and (B=1 or C=1)", }; foreach (var filter in filters) { var epl = "@Name('s0') select * from SupportBean_IntAlphabetic(" + filter + ")"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); if (SupportFilterOptimizableHelper.HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean_IntAlphabetic", new[] { new[] {new FilterItem("A", FilterOperator.NOT_IN_LIST_OF_VALUES), new FilterItem("B", FilterOperator.EQUAL)}, new[] {new FilterItem("A", FilterOperator.NOT_IN_LIST_OF_VALUES), new FilterItem("C", FilterOperator.EQUAL)}, }); } SendAssertEvents( env, new object[] {IntEvent(3, 1, 0), IntEvent(3, 0, 1), IntEvent(0, 1, 0)}, new object[] {IntEvent(2, 0, 0), IntEvent(1, 0, 0), IntEvent(3, 0, 0)} ); env.UndeployAll(); } }
public void Run(RegressionEnvironment env) { var text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; env.CompileDeploy(text).UndeployAll(); env.CompileDeploy(text).UndeployAll(); text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int, col3 long);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; env.CompileDeploy(text).UndeployAll(); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); // test on-merge var moduleString = "@Name('S0') create window MyWindow#unique(IntPrimitive) as SupportBean;\n" + "@Name('S1') on MyWindow insert into SecondStream select *;\n" + "@Name('S2') on SecondStream merge MyWindow when matched then insert into ThirdStream select * then delete\n"; var compiled = env.Compile(moduleString); env.Deploy(compiled).UndeployAll().Deploy(compiled).UndeployAll(); // test table var moduleTableOne = "create table MyTable(c0 string, c1 string)"; env.CompileDeploy(moduleTableOne).UndeployAll(); var moduleTableTwo = "create table MyTable(c0 string, c1 string, c2 string)"; env.CompileDeploy(moduleTableTwo).UndeployAll(); }
public void Run(RegressionEnvironment env) { var epl = "@Hint('MAX_FILTER_WIDTH=0') @name('s0') select * from SupportBean_IntAlphabetic((B=1 or C=1) and (D=1 or E=1))"; env.CompileDeployAddListenerMile(epl, "s0", 0); SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), ".boolean_expression", FilterOperator.BOOLEAN_EXPRESSION); env.UndeployAll(); }
private static void TryNotInKeywordPattern( RegressionEnvironment env, string field, SupportInKeywordBean prototype, AtomicLong milestone) { var epl = "@Name('s0') select * from pattern[every a=SupportInKeywordBean -> SupportBean(IntPrimitive not in (a." + field + "))]"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); AssertInKeywordReceivedPattern(env, SerializableObjectCopier.CopyMayFail(env.Container, prototype), 0, true); AssertInKeywordReceivedPattern(env, SerializableObjectCopier.CopyMayFail(env.Container, prototype), 3, true); AssertInKeywordReceivedPattern(env, SerializableObjectCopier.CopyMayFail(env.Container, prototype), 1, false); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean", new[] { new[] { new FilterItem("IntPrimitive", FilterOperator.NOT_IN_LIST_OF_VALUES) }, }); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); // test 'or' rewrite var filtersAB = new[] { "select * from SupportBean(TheString = 'a' or IntPrimitive = 1)", "select * from SupportBean(TheString = 'a' or 1 = IntPrimitive)", "select * from SupportBean('a' = TheString or 1 = IntPrimitive)", "select * from SupportBean('a' = TheString or IntPrimitive = 1)", }; foreach (var filter in filtersAB) { env.CompileDeployAddListenerMile("@Name('s0')" + filter, "s0", milestone.GetAndIncrement()); if (SupportFilterOptimizableHelper.HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean", new[] { new[] {new FilterItem("IntPrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("TheString", FilterOperator.EQUAL)}, }); } env.SendEventBean(new SupportBean("a", 0)); env.Listener("s0").AssertOneGetNewAndReset(); env.SendEventBean(new SupportBean("b", 1)); env.Listener("s0").AssertOneGetNewAndReset(); env.SendEventBean(new SupportBean("c", 0)); Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); } }
public void Run(RegressionEnvironment env) { var epl = "@Name('out') expression myindex {pointregionquadtree(0, 0, 100, 100)}" + "select p.Id as c0 from pattern [every p=SupportSpatialPoint -> every SupportSpatialAABB(point(p.Px, p.Py, filterindex:myindex).inside(rectangle(X, Y, Width, Height)))]"; env.CompileDeploy(epl).AddListener("out"); env.Milestone(0); SendPoint(env, "P0", 10, 10); SendPoint(env, "P1", 60, 60); SendPoint(env, "P2", 60, 10); SendPoint(env, "P3", 10, 60); SendPoint(env, "P4", 10, 10); Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "P0,P4", "P2", "P3", "P1", "P1"); env.Milestone(1); Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "P0,P4", "P2", "P3", "P1", "P1"); env.UndeployAll(); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var filters = new[] { "A like 'a%' and (B='b' or C='c')", }; foreach (var filter in filters) { var epl = "@Name('s0') select * from SupportBean_StringAlphabetic(" + filter + ")"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); if (SupportFilterOptimizableHelper.HasFilterIndexPlanBasic(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean_StringAlphabetic", new[] { new[] {new FilterItem("B", FilterOperator.EQUAL), FilterItem.BoolExprFilterItem}, new[] {new FilterItem("C", FilterOperator.EQUAL), FilterItem.BoolExprFilterItem}, }); } SendAssertEvents( env, new object[] {StringEvent("a1", "b", null), StringEvent("a1", null, "c")}, new object[] {StringEvent("x", "b", null), StringEvent("a1", null, null), StringEvent("a1", null, "x")} ); env.UndeployAll(); } }
public void Run(RegressionEnvironment env) { var eplNoIndex = "@Name('s0') select * from SupportSpatialAABB(point(0, 0).inside(rectangle(X, Y, Width, Height)))"; env.CompileDeploy(eplNoIndex); SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportSpatialAABB", new[] { new[] { FilterItem.BoolExprFilterItem } }); env.UndeployAll(); var eplIndexed = "@Name('s0') expression myindex {pointregionquadtree(0, 0, 100, 100)}" + "select * from SupportSpatialAABB(point(0, 0, filterindex:myindex).inside(rectangle(X, Y, Width, Height)))"; env.CompileDeploy(eplIndexed); SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportSpatialAABB", new[] { new[] { new FilterItem( "X,Y,Width,Height/myindex/pointregionquadtree/0.0d,0.0d,100.0d,100.0d,4,20", FilterOperator.ADVANCED_INDEX) } }); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var filtersAB = new[] { "(TheString = 'a' and IntPrimitive = 1) or (TheString = 'b' and IntPrimitive = 2)", "(IntPrimitive = 1 and TheString = 'a') or (IntPrimitive = 2 and TheString = 'b')", "(TheString = 'b' and IntPrimitive = 2) or (TheString = 'a' and IntPrimitive = 1)", }; foreach (var filter in filtersAB) { var epl = "@Name('s0') select * from SupportBean(" + filter + ")"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); if (SupportFilterOptimizableHelper.HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean", new[] { new[] {new FilterItem("TheString", FilterOperator.EQUAL), new FilterItem("IntPrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("TheString", FilterOperator.EQUAL), new FilterItem("IntPrimitive", FilterOperator.EQUAL)}, }); } SendAssertEvents( env, new[] {MakeEvent("a", 1), MakeEvent("b", 2)}, new[] {MakeEvent("x", 0), MakeEvent("a", 0), MakeEvent("a", 2), MakeEvent("b", 1)} ); env.UndeployAll(); } }
private static void TryInArrayContextProvided( RegressionEnvironment env, AtomicLong milestone) { var epl = "create context MyContext initiated by SupportInKeywordBean as mie terminated after 24 hours;\n" + "@Name('s1') context MyContext select * from SupportBean#keepall where IntPrimitive in (context.mie.Ints);\n" + "@Name('s2') context MyContext select * from SupportBean(IntPrimitive in (context.mie.Ints));\n"; env.CompileDeploy(epl).AddListener("s1").AddListener("s2"); env.SendEventBean(new SupportInKeywordBean(new[] {1, 2})); env.SendEventBean(new SupportBean("E1", 1)); Assert.IsTrue(env.Listener("s1").IsInvokedAndReset() && env.Listener("s2").IsInvokedAndReset()); env.SendEventBean(new SupportBean("E2", 2)); Assert.IsTrue(env.Listener("s1").IsInvokedAndReset() && env.Listener("s2").IsInvokedAndReset()); env.SendEventBean(new SupportBean("E3", 3)); Assert.IsFalse(env.Listener("s1").IsInvokedAndReset() || env.Listener("s2").IsInvokedAndReset()); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s2"), "SupportBean", new[] { new[] { new FilterItem("IntPrimitive", FilterOperator.IN_LIST_OF_VALUES) }, }); } env.UndeployAll(); }
private static void RunAssertionInWVariable( RegressionEnvironment env, string epl) { env.CompileDeploy("@Name('s0') " + epl).AddListener("s0"); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "IntPrimitive", FilterOperator.IN_LIST_OF_VALUES); } TryAssertionWSubsFrom9To12(env); env.UndeployAll(); }
private static void RunAssertionInWSubs( RegressionEnvironment env, string epl) { CompileDeployWSubstitution(env, epl, CollectionUtil.BuildMap("p0", 10, "p1", 11)); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "IntPrimitive", FilterOperator.IN_LIST_OF_VALUES); } TryAssertionWSubsFrom9To12(env); env.UndeployAll(); }
private static void AssertSameFilterEntry( RegressionEnvironment env, string eventTypeName) { IDictionary<string, FilterItem> filters = SupportFilterServiceHelper.GetFilterSvcAllStmtForTypeSingleFilter(env.Runtime, eventTypeName); FilterItem s0 = filters.Get("s0"); FilterItem s1 = filters.Get("s1"); Assert.AreEqual(FilterOperator.REBOOL, s0.Op); Assert.IsNotNull(s0.Index); Assert.AreSame(s0.Index, s1.Index); Assert.AreSame(s0.OptionalValue, s1.OptionalValue); }
private static void TryAssertionEqualsWDeployTimeConst( RegressionEnvironment env, string epl) { if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "TheString", FilterOperator.EQUAL); } env.SendEventBean(new SupportBean("abc", 0)); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.SendEventBean(new SupportBean("x", 0)); Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); }
private static void TryAssertionRelOpWDeployTimeConst( RegressionEnvironment env, string epl) { if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "IntPrimitive", FilterOperator.GREATER); } env.SendEventBean(new SupportBean("E1", 10)); Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked()); env.SendEventBean(new SupportBean("E2", 11)); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); }
private static void SendBeanAAssert( RegressionEnvironment env, string id, int intPrimitiveExpected, int numFiltersRemaining) { env.SendEventBean(new SupportBean_A(id)); var fields = new[] {"c0"}; EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {intPrimitiveExpected}); Assert.AreEqual( numFiltersRemaining, SupportFilterServiceHelper.GetFilterSvcCount(env.Statement("s0"), "SupportBean_A")); }
private static void RunAssertionEqualsWSubsWCoercion( RegressionEnvironment env, string epl) { CompileDeployWSubstitution(env, epl, CollectionUtil.BuildMap("p0", 100)); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "LongPrimitive", FilterOperator.EQUAL); } var sb = new SupportBean(); sb.LongPrimitive = 100; env.SendEventBean(sb); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); }
private static void AssertFilterDeploySingle( RegressionEnvironment env, RegressionPath path, string epl, string expression, FilterOperator op, AtomicLong milestone) { env.CompileDeploy("@Name('s0')" + epl, path).AddListener("s0").MilestoneInc(milestone); var statementSPI = (EPStatementSPI) env.Statement("s0"); if (HasFilterIndexPlanBasicOrMore(env)) { var param = SupportFilterServiceHelper.GetFilterSvcSingle(statementSPI); Assert.AreEqual(op, param.Op, "failed for '" + epl + "'"); Assert.AreEqual(expression, param.Name); } env.UndeployModuleContaining("s0"); }
public void Run(RegressionEnvironment env) { string epl = "@Name('var') create constant variable string MYVAR = '.*abc.*';\n" + "@Name('s0') select * from SupportBean(TheString regexp MYVAR);\n" + "" + "@Name('ctx') create context MyContext start SupportBean_S0 as s0;\n" + "@Name('s1') context MyContext select * from SupportBean(TheString regexp context.s0.P00);\n" + "" + "@Name('s2') select * from pattern[s0=SupportBean_S0 -> every SupportBean(TheString regexp s0.P00)];\n" + "" + "@Name('s3') select * from SupportBean(TheString regexp '.*' || 'abc' || '.*');\n"; env.CompileDeploy(epl); EPDeployment deployment = env.Deployment.GetDeployment(env.DeploymentId("s0")); ISet<string> statementNames = new LinkedHashSet<string>(); foreach (EPStatement stmt in deployment.Statements) { if (stmt.Name.StartsWith("s")) { stmt.AddListener(env.ListenerNew()); statementNames.Add(stmt.Name); } } env.Milestone(0); env.SendEventBean(new SupportBean_S0(1, ".*abc.*")); SendSBAssert(env, "xabsx", statementNames, false); SendSBAssert(env, "xabcx", statementNames, true); if (HasFilterIndexPlanAdvanced(env)) { IDictionary<string, FilterItem> filters = SupportFilterServiceHelper.GetFilterSvcAllStmtForTypeSingleFilter(env.Runtime, "SupportBean"); FilterItem s0 = filters.Get("s0"); foreach (string name in statementNames) { FilterItem sn = filters.Get(name); Assert.AreEqual(FilterOperator.REBOOL, sn.Op); Assert.IsNotNull(s0.OptionalValue); Assert.IsNotNull(s0.Index); Assert.AreSame(s0.Index, sn.Index); Assert.AreSame(s0.OptionalValue, sn.OptionalValue); } } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { SupportFilterPlanHook.Reset(); string hook = "@Hook(HookType=HookType.INTERNAL_FILTERSPEC, Hook='" + typeof(SupportFilterPlanHook).FullName + "')"; string epl = hook + "@Name('s0') select * from SupportBean(TheString regexp '.*a.*')"; env.CompileDeploy(epl).AddListener("s0"); if (HasFilterIndexPlanAdvanced(env)) { FilterSpecParamForge forge = SupportFilterPlanHook.AssertPlanSingleTripletAndReset("SupportBean"); Assert.AreEqual(FilterOperator.REBOOL, forge.FilterOperator); Assert.AreEqual(".TheString regexp ?", forge.Lookupable.Expression); Assert.AreEqual(typeof(string), forge.Lookupable.ReturnType); AssertFilterSvcSingle(env.Statement("s0"), ".TheString regexp ?", REBOOL); } epl = "@Name('s1') select * from SupportBean(TheString regexp '.*a.*')"; env.CompileDeploy(epl).AddListener("s1"); epl = "@Name('s2') select * from SupportBean(TheString regexp '.*b.*')"; env.CompileDeploy(epl).AddListener("s2"); env.Milestone(0); if (HasFilterIndexPlanAdvanced(env)) { IDictionary<string, FilterItem> filters = SupportFilterServiceHelper.GetFilterSvcAllStmtForTypeSingleFilter(env.Runtime, "SupportBean"); FilterItem s0 = filters.Get("s0"); FilterItem s1 = filters.Get("s1"); FilterItem s2 = filters.Get("s2"); Assert.AreEqual(FilterOperator.REBOOL, s0.Op); Assert.IsNotNull(s0.OptionalValue); Assert.IsNotNull(s0.Index); Assert.AreSame(s0.Index, s1.Index); Assert.AreSame(s0.OptionalValue, s1.OptionalValue); Assert.AreSame(s0.Index, s2.Index); Assert.AreNotSame(s0.OptionalValue, s2.OptionalValue); } SendSBAssert(env, "garden", true, true, false); SendSBAssert(env, "house", false, false, false); SendSBAssert(env, "grub", false, false, true); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var filtersAB = new[] { "TheString = 'a' or IntPrimitive=1 or LongPrimitive=10 or DoublePrimitive=100 or BoolPrimitive=true or " + "IntBoxed=2 or LongBoxed=20 or DoubleBoxed=200", "LongBoxed=20 or TheString = 'a' or BoolPrimitive=true or IntBoxed=2 or LongPrimitive=10 or DoublePrimitive=100 or " + "IntPrimitive=1 or DoubleBoxed=200", }; foreach (var filter in filtersAB) { var epl = "@Name('s0') select * from SupportBean(" + filter + ")"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); if (SupportFilterOptimizableHelper.HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportBean", new[] { new[] {new FilterItem("TheString", FilterOperator.EQUAL)}, new[] {new FilterItem("IntPrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("LongPrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("DoublePrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("BoolPrimitive", FilterOperator.EQUAL)}, new[] {new FilterItem("IntBoxed", FilterOperator.EQUAL)}, new[] {new FilterItem("LongBoxed", FilterOperator.EQUAL)}, new[] {new FilterItem("DoubleBoxed", FilterOperator.EQUAL)}, }); } SendAssertEvents( env, new[] { MakeEvent("a", 1, 10, 100, true, 2, 20, 200), MakeEvent("a", 0, 0, 0, true, 0, 0, 0), MakeEvent("a", 0, 0, 0, true, 0, 20, 0), MakeEvent("x", 0, 0, 100, false, 0, 0, 0), MakeEvent("x", 1, 0, 0, false, 0, 0, 200), MakeEvent("x", 0, 0, 0, false, 0, 0, 200), }, new[] {MakeEvent("x", 0, 0, 0, false, 0, 0, 0)} ); env.UndeployAll(); } }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); // test 'or' rewrite var filtersAB = new[] { "TheString = 'a' or TheString = 'b'", "TheString = 'a' or 'b' = TheString", "'a' = TheString or 'b' = TheString", "'a' = TheString or TheString = 'b'", }; foreach (var filter in filtersAB) { var eplX = "@Name('s0') select * from SupportBean(" + filter + ")"; env.CompileDeployAddListenerMile(eplX, "s0", milestone.GetAndIncrement()); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcSingle(env.Statement("s0"), "TheString", FilterOperator.IN_LIST_OF_VALUES); } env.SendEventBean(new SupportBean("a", 0)); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.SendEventBean(new SupportBean("b", 0)); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.SendEventBean(new SupportBean("c", 0)); Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); } var epl = "@Name('s0') select * from SupportBean(IntPrimitive = 1 and (TheString='a' or TheString='b'))"; env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement()); if (HasFilterIndexPlanBasicOrMore(env)) { SupportFilterServiceHelper.AssertFilterSvcTwo( env.Statement("s0"), "IntPrimitive", FilterOperator.EQUAL, "TheString", FilterOperator.IN_LIST_OF_VALUES); } env.UndeployAll(); }
private static void TryOperator( RegressionEnvironment env, RegressionPath path, string @operator, object[][] testdata) { env.CompileDeploy( "@Name('s0') select TheString as c0,IntPrimitive as c1 from SupportBean(" + @operator + ")", path); env.AddListener("s0"); // initiate env.SendEventBean(new SupportBean_S0(10, "S01")); for (var i = 0; i < testdata.Length; i++) { var bean = new SupportBean(); var testValue = testdata[i][0]; if (testValue is int?) { bean.IntBoxed = (int?) testValue; } else if (testValue is SupportEnum) { bean.EnumValue = (SupportEnum) testValue; } else { bean.ShortBoxed = testValue.AsInt16(); } var expected = (bool) testdata[i][1]; env.SendEventBean(bean); Assert.AreEqual(expected, env.Listener("s0").GetAndClearIsInvoked(), "Failed at " + i); } // assert type of expression var item = SupportFilterServiceHelper.GetFilterSvcSingle(env.Statement("s0")); Assert.IsTrue(item.Op != FilterOperator.BOOLEAN_EXPRESSION); env.UndeployModuleContaining("s0"); }
public void Run(RegressionEnvironment env) { var epl = "@Name('out') expression myindex {mxcifquadtree(0, 0, 100, 100)}" + "select p.Id as c0 from pattern [every p=SupportSpatialEventRectangle -> every SupportSpatialAABB(rectangle(p.X, p.Y, p.Width, p.Height, filterindex:myindex).intersects(rectangle(X, Y, Width, Height)))]"; env.CompileDeploy(epl).AddListener("out"); env.Milestone(0); SendEventRectangle(env, "R0", 10, 10, 1, 1); SendEventRectangle(env, "R1", 60, 60, 1, 1); SendEventRectangle(env, "R2", 60, 10, 1, 1); SendEventRectangle(env, "R3", 10, 60, 1, 1); SendEventRectangle(env, "R4", 10, 10, 1, 1); Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "R0,R4", "R2", "R3", "R1", "R1"); env.Milestone(1); Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "R0,R4", "R2", "R3", "R1", "R1"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var eplNoIndex = "@Name('s0') select * from SupportSpatialEventRectangle(rectangle(0, 0, 1, 1).intersects(rectangle(X, Y, Width, Height)))"; env.CompileDeploy(eplNoIndex); SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportSpatialEventRectangle", new[] {new[] {FilterItem.BoolExprFilterItem}}); env.UndeployAll(); var eplIndexed = "@Name('s0') expression myindex {mxcifquadtree(0, 0, 100, 100)}" + "select * from SupportSpatialEventRectangle(rectangle(10, 20, 5, 6, filterindex:myindex).intersects(rectangle(X, Y, Width, Height)))"; env.CompileDeploy(eplIndexed).AddListener("s0"); SupportFilterServiceHelper.AssertFilterSvcByTypeMulti( env.Statement("s0"), "SupportSpatialEventRectangle", new[] { new[] { new FilterItem( "X,Y,Width,Height/myindex/mxcifquadtree/0.0d,0.0d,100.0d,100.0d,4,20", FilterOperator.ADVANCED_INDEX) } }); SendAssertEventRectangle(env, env.Listener("s0"), 10, 20, 0, 0, true); SendAssertEventRectangle(env, env.Listener("s0"), 9, 19, 0.9999, 0.9999, false); env.Milestone(0); SendAssertEventRectangle(env, env.Listener("s0"), 9, 19, 1, 1, true); SendAssertEventRectangle(env, env.Listener("s0"), 15, 26, 0, 0, true); SendAssertEventRectangle(env, env.Listener("s0"), 15.001, 26.001, 0, 0, false); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { // Comment-in to see CRC32 code. for (var i = 0; i < 10; i++) { var key = "E" + i; var code = SupportHashCodeFuncGranularCRC32.ComputeCRC32(key) % 4; var hashCode = i.GetHashCode() % 4; //System.out.println(key + " code " + code + " hashCode " + hashCode); } var path = new RegressionPath(); var ctx = "HashSegmentedContext"; var milestone = new AtomicLong(); // test CRC32 Hash var eplCtx = "@Name('context') create context " + ctx + " as " + "coalesce consistent_hash_crc32(TheString) from SupportBean " + "granularity 4 " + "preallocate"; env.CompileDeploy(eplCtx, path); var eplStmt = "@Name('s0') context " + ctx + " " + "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString"; env.CompileDeploy(eplStmt, path).AddListener("s0"); Assert.AreEqual(4, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 4, null, null, null); TryAssertionHash(env, milestone, "s0", ctx); // equivalent to: SupportHashCodeFuncGranularCRC32(4) Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); path.Clear(); // test same with SODA env.EplToModelCompileDeploy(eplCtx, path); env.CompileDeploy(eplStmt, path).AddListener("s0"); TryAssertionHash(env, milestone, "s0", ctx); path.Clear(); // test with Java-hashCode String hash env.CompileDeploy( "@Name('context') create context " + ctx + " " + "coalesce hash_code(TheString) from SupportBean " + "granularity 6 " + "preallocate", path); env.CompileDeploy( "@Name('s0') context " + ctx + " " + "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString", path); env.AddListener("s0"); Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 6, null, null, null); TryAssertionHash(env, milestone, "s0", ctx); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); path.Clear(); // test no pre-allocate env.CompileDeploy( "@Name('context') create context " + ctx + " " + "coalesce hash_code(TheString) from SupportBean " + "granularity 16", path); env.CompileDeploy( "@Name('s0') context " + ctx + " " + "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString", path); env.AddListener("s0"); Assert.AreEqual(1, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 0, null, null, null); TryAssertionHash(env, milestone, "s0", ctx); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var ctx = "CategorizedContext"; var fields = new [] { "c0", "c1", "c2" }; var epl = "@Name('context') create context " + ctx + " " + "group IntPrimitive < 10 as cat1, " + "group IntPrimitive between 10 and 20 as cat2, " + "group IntPrimitive > 20 as cat3 " + "from SupportBean;\n"; epl += "@Name('s0') context CategorizedContext " + "select context.name as c0, context.label as c1, sum(IntPrimitive) as c2 from SupportBean;\n"; env.CompileDeploy(epl).AddListener("s0"); Assert.AreEqual(3, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 3, null, null, null); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("E1", 5)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat1", 5}); EPAssertionUtil.AssertPropsPerRow( env.Statement("s0").GetEnumerator(), env.Statement("s0").GetSafeEnumerator(), fields, new[] { new object[] {ctx, "cat1", 5}, new object[] {ctx, "cat2", null}, new object[] {ctx, "cat3", null} }); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("E2", 4)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat1", 9}); env.SendEventBean(new SupportBean("E3", 11)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat2", 11}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("E4", 25)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat3", 25}); env.SendEventBean(new SupportBean("E5", 25)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat3", 50}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("E6", 3)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {ctx, "cat1", 12}); EPAssertionUtil.AssertPropsPerRow( env.Statement("s0").GetEnumerator(), env.Statement("s0").GetSafeEnumerator(), fields, new[] { new object[] {ctx, "cat1", 12}, new object[] {ctx, "cat2", 11}, new object[] {ctx, "cat3", 50} }); Assert.AreEqual(1, SupportContextMgmtHelper.GetContextCount(env)); Assert.AreEqual(3, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); env.UndeployModuleContaining("s0"); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env)); }