コード例 #1
0
 public override void SetViewParameters(
     IList<ExprNode> parameters,
     ViewForgeEnv viewForgeEnv,
     int streamNumber)
 {
     ViewForgeSupport.ValidateNoParameters(ViewName, parameters);
 }
コード例 #2
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            var validated = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);
            if (validated.Length < 1) {
                throw new ViewParameterException(ViewParamMessage);
            }

            if (!validated[0].Forge.EvaluationType.IsNumeric()) {
                throw new ViewParameterException(ViewParamMessage);
            }

            fieldExpression = validated[0];

            additionalProps = StatViewAdditionalPropsForge.Make(validated, 1, parentEventType, streamNumber, viewForgeEnv);
            eventType = UnivariateStatisticsView.CreateEventType(additionalProps, viewForgeEnv, streamNumber);
        }
コード例 #3
0
 public override void SetViewParameters(
     IList<ExprNode> parameters,
     ViewForgeEnv viewForgeEnv,
     int streamNumber)
 {
     sizeForge = ViewForgeSupport.ValidateSizeSingleParam(ViewName, parameters, viewForgeEnv, streamNumber);
 }
コード例 #4
0
        public void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            var validated = ViewForgeSupport.Validate(
                "Trend spotter view",
                parentEventType,
                viewParameters,
                false,
                viewForgeEnv,
                streamNumber);
            var message = "Trend spotter view accepts a single integer or double value";
            if (validated.Length != 1) {
                throw new ViewParameterException(message);
            }

            var resultType = validated[0].Forge.EvaluationType;
            if (resultType != typeof(int?) &&
                resultType != typeof(int) &&
                resultType != typeof(double?) &&
                resultType != typeof(double)) {
                throw new ViewParameterException(message);
            }

            parameter = validated[0];

            var eventTypeMap = new LinkedHashMap<string, object>();
            eventTypeMap.Put("trendcount", typeof(long?));

            EventType = DerivedViewTypeUtil.NewType("trendview", eventTypeMap, viewForgeEnv, streamNumber);
        }
コード例 #5
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            var validated = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);

            if (validated.Length < 2) {
                throw new ViewParameterException(ViewParamMessage);
            }

            if (!validated[0].Forge.EvaluationType.IsNumeric() || !validated[1].Forge.EvaluationType.IsNumeric()) {
                throw new ViewParameterException(ViewParamMessage);
            }

            fieldNameX = validated[0];
            fieldNameWeight = validated[1];
            additionalProps = StatViewAdditionalPropsForge.Make(validated, 2, parentEventType, streamNumber, viewForgeEnv);
            eventType = WeightedAverageView.CreateEventType(additionalProps, viewForgeEnv, streamNumber);
        }
コード例 #6
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            ExprNode[] validated = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);

            if (validated.Length < 2) {
                throw new ViewParameterException(ViewParamMessage);
            }

            if ((!TypeHelper.IsNumeric(validated[0].Forge.EvaluationType)) ||
                (!TypeHelper.IsNumeric(validated[1].Forge.EvaluationType))) {
                throw new ViewParameterException(ViewParamMessage);
            }

            expressionX = validated[0];
            expressionY = validated[1];

            additionalProps = StatViewAdditionalPropsForge.Make(validated, 2, parentEventType, streamNumber, viewForgeEnv);
            eventType = RegressionLinestView.CreateEventType(additionalProps, viewForgeEnv, streamNumber);
        }
コード例 #7
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            var validated = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);
            if (viewParameters.Count != 2) {
                throw new ViewParameterException(ViewParamMessage);
            }

            if (!validated[0].Forge.EvaluationType.IsNumeric()) {
                throw new ViewParameterException(ViewParamMessage);
            }

            timestampExpression = validated[0];
            ViewForgeSupport.AssertReturnsNonConstant(ViewName, validated[0], 0);

            timePeriodComputeForge = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDeltaFactory(
                ViewName,
                viewParameters[1],
                ViewParamMessage,
                1,
                viewForgeEnv,
                streamNumber);
            eventType = parentEventType;
        }
コード例 #8
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            var windowName = ViewName;
            var validated = ViewForgeSupport.Validate(
                windowName,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);
            if (viewParameters.Count < 2 || viewParameters.Count > 3) {
                throw new ViewParameterException(ViewParamMessage);
            }

            // validate first parameter: timestamp expression
            if (!validated[0].Forge.EvaluationType.IsNumeric()) {
                throw new ViewParameterException(ViewParamMessage);
            }

            timestampExpression = validated[0];
            ViewForgeSupport.AssertReturnsNonConstant(windowName, validated[0], 0);

            timePeriodComputeForge = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDeltaFactory(
                ViewName,
                viewParameters[1],
                ViewParamMessage,
                1,
                viewForgeEnv,
                streamNumber);

            // validate optional parameters
            if (validated.Length == 3) {
                var constant = ViewForgeSupport.ValidateAndEvaluate(
                    windowName,
                    validated[2],
                    viewForgeEnv,
                    streamNumber);
                if (!constant.IsNumber() || constant.IsFloatingPointNumber()) {
                    throw new ViewParameterException(
                        "Externally-timed batch view requires a Long-typed reference point in msec as a third parameter");
                }

                optionalReferencePoint = constant.AsInt64();
            }

            eventType = parentEventType;
        }
コード例 #9
0
ファイル: SizeViewForge.cs プロジェクト: lanicon/nesper
 public override void Attach(
     EventType parentEventType,
     int streamNumber,
     ViewForgeEnv viewForgeEnv)
 {
     var validated = ViewForgeSupport.Validate(
         ViewName,
         parentEventType,
         viewParameters,
         true,
         viewForgeEnv,
         streamNumber);
     additionalProps = StatViewAdditionalPropsForge.Make(validated, 0, parentEventType, streamNumber, viewForgeEnv);
     eventType = SizeView.CreateEventType(viewForgeEnv, additionalProps, streamNumber);
 }
コード例 #10
0
        public void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            EventType = parentEventType;

            _validatedParameterExpressions = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                _parameters,
                true,
                viewForgeEnv,
                streamNumber);
            _parameterValues = new object[_validatedParameterExpressions.Length];
            for (var i = 0; i < _validatedParameterExpressions.Length; i++) {
                try {
                    _parameterValues[i] = ViewForgeSupport.EvaluateAssertNoProperties(
                        ViewName,
                        _validatedParameterExpressions[i],
                        i);
                }
                catch (Exception) {
                    // expected
                }
            }

            // initialize
            try {
                _forge.Initialize(
                    new VirtualDataWindowForgeContext(
                        parentEventType,
                        _parameterValues,
                        _validatedParameterExpressions,
                        _namedWindowName,
                        viewForgeEnv,
                        _customConfigs));
            }
            //catch (EPException) {
            //    throw;
            //}
            catch (Exception ex) {
                throw new ViewParameterException(
                    "Validation exception initializing virtual data window '" + _namedWindowName + "': " + ex.Message,
                    ex);
            }
        }
コード例 #11
0
        public override void SetViewParameters(
            IList<ExprNode> parameters,
            ViewForgeEnv viewForgeEnv,
            int streamNumber)
        {
            if (parameters.Count != 1 && parameters.Count != 2) {
                var errorMessage =
                    ViewName + " view requires a single expression as a parameter, or an expression and boolean flag";
                throw new ViewParameterException(errorMessage);
            }

            ExpiryExpression = parameters[0];

            if (parameters.Count > 1) {
                var result = ViewForgeSupport.EvaluateAssertNoProperties(ViewName, parameters[1], 1);
                includeTriggeringEvent = (bool) result;
            }
        }
コード例 #12
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            eventType = parentEventType;
            var message =
                NAME + " window requires a numeric size parameter and a list of expressions providing sort keys";
            if (viewParameters.Count < 2) {
                throw new ViewParameterException(message);
            }

            var validated = ViewForgeSupport.Validate(
                NAME + " window",
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);
            for (var i = 1; i < validated.Length; i++) {
                ViewForgeSupport.AssertReturnsNonConstant(NAME + " window", validated[i], i);
            }

            ViewForgeSupport.ValidateNoProperties(ViewName, validated[0], 0);
            sizeForge = ViewForgeSupport.ValidateSizeParam(ViewName, validated[0], 0);

            sortCriteriaExpressions = new ExprNode[validated.Length - 1];
            isDescendingValues = new bool[sortCriteriaExpressions.Length];

            for (var i = 1; i < validated.Length; i++) {
                if (validated[i] is ExprOrderedExpr) {
                    isDescendingValues[i - 1] = ((ExprOrderedExpr) validated[i]).IsDescending;
                    sortCriteriaExpressions[i - 1] = validated[i].ChildNodes[0];
                }
                else {
                    sortCriteriaExpressions[i - 1] = validated[i];
                }
            }

            sortSerdes = viewForgeEnv.SerdeResolver.SerdeForDataWindowSortCriteria(
                ExprNodeUtilityQuery.GetExprResultTypes(sortCriteriaExpressions),
                viewForgeEnv.StatementRawInfo);
        }
コード例 #13
0
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            _criteriaExpressions = ViewForgeSupport.Validate(
                ViewName,
                parentEventType,
                _viewParameters,
                false,
                viewForgeEnv,
                streamNumber);

            if (_criteriaExpressions.Length == 0) {
                var errorMessage =
                    ViewName + " view requires a one or more expressions providing unique values as parameters";
                throw new ViewParameterException(errorMessage);
            }

            this.eventType = parentEventType;
        }
コード例 #14
0
ファイル: RankWindowViewForge.cs プロジェクト: lanicon/nesper
        public override void Attach(
            EventType parentEventType,
            int streamNumber,
            ViewForgeEnv viewForgeEnv)
        {
            eventType = parentEventType;
            var message =
                NAME +
                " view requires a list of expressions providing unique keys, a numeric size parameter and a list of expressions providing sort keys";
            if (viewParameters.Count < 3) {
                throw new ViewParameterException(message);
            }

            // validate
            var validated = ViewForgeSupport.Validate(
                NAME,
                parentEventType,
                viewParameters,
                true,
                viewForgeEnv,
                streamNumber);

            // find size-parameter index
            var indexNumericSize = -1;
            for (var i = 0; i < validated.Length; i++) {
                if (validated[i] is ExprConstantNode || validated[i] is ExprContextPropertyNode) {
                    indexNumericSize = i;
                    break;
                }
            }

            if (indexNumericSize == -1) {
                throw new ViewParameterException("Failed to find constant value for the numeric size parameter");
            }

            if (indexNumericSize == 0) {
                throw new ViewParameterException(
                    "Failed to find unique value expressions that are expected to occur before the numeric size parameter");
            }

            if (indexNumericSize == validated.Length - 1) {
                throw new ViewParameterException(
                    "Failed to find sort key expressions after the numeric size parameter");
            }

            // validate non-constant for unique-keys and sort-keys
            for (var i = 0; i < indexNumericSize; i++) {
                ViewForgeSupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }

            for (var i = indexNumericSize + 1; i < validated.Length; i++) {
                ViewForgeSupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }

            // get sort size
            ViewForgeSupport.ValidateNoProperties(ViewName, validated[indexNumericSize], indexNumericSize);
            sizeForge = ViewForgeSupport.ValidateSizeParam(ViewName, validated[indexNumericSize], indexNumericSize);

            // compile unique expressions
            criteriaExpressions = new ExprNode[indexNumericSize];
            Array.Copy(validated, 0, criteriaExpressions, 0, indexNumericSize);

            // compile sort expressions
            sortCriteriaExpressions = new ExprNode[validated.Length - indexNumericSize - 1];
            isDescendingValues = new bool[sortCriteriaExpressions.Length];

            var count = 0;
            for (var i = indexNumericSize + 1; i < validated.Length; i++) {
                if (validated[i] is ExprOrderedExpr) {
                    isDescendingValues[count] = ((ExprOrderedExpr) validated[i]).IsDescending;
                    sortCriteriaExpressions[count] = validated[i].ChildNodes[0];
                }
                else {
                    sortCriteriaExpressions[count] = validated[i];
                }

                count++;
            }

            sortSerdes = viewForgeEnv.SerdeResolver.SerdeForDataWindowSortCriteria(
                ExprNodeUtilityQuery.GetExprResultTypes(sortCriteriaExpressions),
                viewForgeEnv.StatementRawInfo);
        }