Пример #1
0
        public void TestMinMaxScalarWithLambda()
        {
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("extractNum", typeof(MyService).FullName, "ExtractNum");

            String[] fields      = Collections.Array("val0", "val1", "val2", "val3");
            String   eplFragment = "select " +
                                   "Strvals.min(v => extractNum(v)) as val0, " +
                                   "Strvals.max(v => extractNum(v)) as val1, " +
                                   "Strvals.min(v => v) as val2, " +
                                   "Strvals.max(v => v) as val3 " +
                                   "from SupportCollection";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(int?),
                typeof(int?),
                typeof(string),
                typeof(string)
            });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E2,E1,E5,E4"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 1, 5, "E1", "E5" });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 1, 1, "E1", "E1" });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null, null, null });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString(""));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null, null, null });
        }
Пример #2
0
        public static IArgument Single(CharSource source, ref char chr, Dictionary <string, IFunction> funcs)
        {
            switch (chr)
            {
            case '"':
                return(Literals.String(source, ref chr));

            case '{':
                return(Collections.Dictionary(source, ref chr, funcs));

            case '[':
                return(Collections.Array(source, ref chr, funcs));

            case '(':
                return(Evaluatable.Function(source, ref chr, funcs));

            case '<':
                return(Evaluatable.Executable(source, ref chr, funcs));

            case '/':
                return(Literals.TypeName(source, ref chr));

            case '!':
                return(new ResultArgument(source, ref chr));

            default:
                return(Literals.Default(source, ref chr));
            }
        }
Пример #3
0
        public void Run(RegressionEnvironment env)
        {
            var fields = Collections.Array("RuntimeURI", "Timestamp", "InputCount", "InputCountDelta", "ScheduleDepth");
            SendTimer(env, 1000);

            var text = "@Name('s0') select * from " + typeof(RuntimeMetric).FullName;
            env.CompileDeploy(text).AddListener("s0");

            env.SendEventBean(new SupportBean());

            SendTimer(env, 10999);
            Assert.IsFalse(env.Listener("s0").IsInvoked);

            env.CompileDeploy("select * from pattern[timer:interval(5 sec)]");

            SendTimer(env, 11000);
            var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(
                theEvent,
                fields,
                new object[] {"default", 11000L, 1L, 1L, 1L});

            env.SendEventBean(new SupportBean());
            env.SendEventBean(new SupportBean());

            SendTimer(env, 20000);
            SendTimer(env, 21000);
            theEvent = env.Listener("s0").AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(
                theEvent,
                fields,
                new object[] {"default", 21000L, 4L, 3L, 0L});

            var cpuGoal = 10.0d; // milliseconds of execution time

#if !NETCORE
            var before = PerformanceMetricsHelper.GetCurrentMetricResult();
            MyMetricFunctions.TakeMillis(cpuGoal);
            var after = PerformanceMetricsHelper.GetCurrentMetricResult();
            Assert.IsTrue((after.UserTime - before.UserTime).TotalMilliseconds > cpuGoal);
#endif

            env.UndeployAll();
        }
Пример #4
0
            public void Run(RegressionEnvironment env)
            {
                var startTime =
                    "2002-05-30T09:01:02.003";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                var fields = Collections.Array(
                    "valmoh",
                    "valmoy",
                    "valdom",
                    "valdow",
                    "valdoy",
                    "valhod",
                    "valmos",
                    "valsom",
                    "valwye",
                    "valyea",
                    "val0",
                    "val1",
                    "val2",
                    "val3");

                var eplFragment = "@Name('s0') select " +
                                  "current_timestamp.getMinuteOfHour() as valmoh," +
                                  "current_timestamp.getMonthOfYear() as valmoy," +
                                  "current_timestamp.getDayOfMonth() as valdom," +
                                  "current_timestamp.getDayOfWeek() as valdow," +
                                  "current_timestamp.getDayOfYear() as valdoy," +
                                  "current_timestamp.getHourOfDay() as valhod," +
                                  "current_timestamp.getMillisOfSecond()  as valmos," +
                                  "current_timestamp.getSecondOfMinute() as valsom," +
                                  "current_timestamp.getWeekyear() as valwye," +
                                  "current_timestamp.getYear() as valyea," +
                                  "DateTimeEx.getHourOfDay() as val0," +
                                  "DateTimeOffset.getHourOfDay() as val1," +
                                  "DateTime.getHourOfDay() as val2," +
                                  "LongDate.getHourOfDay() as val3" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                foreach (var field in fields) {
                    Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType(field));
                }

                env.SendEventBean(SupportDateTime.Make(startTime));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        1,    // valmoh
                        5,    // valmoy
                        30,   // valdom
                        4,    // valdow
                        150,  // valdoy
                        9,    // valhod
                        3,    // valmos
                        2,    // valsom
                        22,   // valwye
                        2002, // valyea
                        9,    // val0
                        9,    // val1
                        9,    // val2    
                        9     // val3
                    });

                env.UndeployAll();
            }