public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            _parentEventType = parentEventType;

            var validatedNodes = ViewFactorySupport.Validate(_viewFactoryContext.ViewName, parentEventType, _viewFactoryContext.StatementContext, _viewParameters, true);

            _viewParameterArr = new Object[validatedNodes.Length];
            var evaluatorContextStmt = new ExprEvaluatorContextStatement(_viewFactoryContext.StatementContext, false);

            for (var i = 0; i < validatedNodes.Length; i++)
            {
                try {
                    _viewParameterArr[i] = ViewFactorySupport.EvaluateAssertNoProperties(_viewFactoryContext.ViewName, validatedNodes[i], i, evaluatorContextStmt);
                }
                catch (Exception) {
                    // expected
                }
            }

            _viewParameterExp = ViewFactorySupport.Validate(_viewFactoryContext.ViewName, parentEventType, _viewFactoryContext.StatementContext, _viewParameters, true);

            // initialize
            try {
                _eventBeanFactory = EventAdapterServiceHelper.GetFactoryForType(parentEventType, statementContext.EventAdapterService);
                _virtualDataWindowFactory.Initialize(new VirtualDataWindowFactoryContext(parentEventType, _viewParameterArr, _viewParameterExp, _eventBeanFactory, _namedWindowName, _viewFactoryContext, _customConfiguration));
            }
            catch (Exception ex) {
                throw new ViewParameterException("Validation exception initializing virtual data window '" + _namedWindowName + "': " + ex.Message, ex);
            }
        }
        public void Attach(
            EventType parentEventType,
            StatementContext statementContext,
            ViewFactory optionalParentFactory,
            IList <ViewFactory> parentViewFactories)
        {
            var validated = ViewFactorySupport.Validate(
                ViewName, parentEventType, statementContext, _viewParameters, true);

            if (_viewParameters.Count != 2)
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            if (!validated[0].ExprEvaluator.ReturnType.IsNumeric())
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            _timestampExpression     = validated[0];
            _timestampExpressionEval = _timestampExpression.ExprEvaluator;
            ViewFactorySupport.AssertReturnsNonConstant(ViewName, validated[0], 0);

            _timeDeltaComputationFactory = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDeltaFactory(
                ViewName, statementContext, _viewParameters[1], ViewParamMessage, 1);
            _eventType = parentEventType;
        }
Пример #3
0
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            var validated = ViewFactorySupport.Validate(
                ViewName, viewFactoryContext.StatementContext, expressionParameters);
            var errorMessage = ViewName +
                               " view requires a numeric or time period parameter as a time interval size, and an integer parameter as a maximal number-of-events, and an optional list of control keywords as a string parameter (please see the documentation)";

            if ((validated.Length != 2) && (validated.Length != 3))
            {
                throw new ViewParameterException(errorMessage);
            }

            timeDeltaComputationFactory = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDeltaFactory(
                ViewName, viewFactoryContext.StatementContext, expressionParameters[0], errorMessage, 0);

            _sizeEvaluator = ViewFactorySupport.ValidateSizeParam(
                ViewName, viewFactoryContext.StatementContext, validated[1], 1);

            if (validated.Length > 2)
            {
                var keywords = ViewFactorySupport.Evaluate(
                    validated[2].ExprEvaluator, 2, ViewName, viewFactoryContext.StatementContext);
                ProcessKeywords(keywords, errorMessage);
            }
        }
Пример #4
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            String windowName = ViewName;

            ExprNode[] validated = ViewFactorySupport.Validate(windowName, parentEventType, statementContext, _viewParameters, true);
            if (_viewParameters.Count < 2 || _viewParameters.Count > 3)
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            // validate first parameter: timestamp expression
            if (!validated[0].ExprEvaluator.ReturnType.IsNumeric())
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            TimestampExpression     = validated[0];
            TimestampExpressionEval = TimestampExpression.ExprEvaluator;
            ViewFactorySupport.AssertReturnsNonConstant(windowName, validated[0], 0);

            TimeDeltaComputation = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDelta(ViewName, statementContext, _viewParameters[1], ViewParamMessage, 1);

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

            this._eventType = parentEventType;
        }
Пример #5
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            _criteriaExpressions = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, ViewParameters, false);

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

            _eventType = parentEventType;
        }
Пример #6
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            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 = ViewFactorySupport.Validate(NAME + " window", parentEventType, statementContext, _viewParameters, true);

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

            var exprEvaluatorContext = new ExprEvaluatorContextStatement(statementContext, false);
            var sortSize             = ViewFactorySupport.EvaluateAssertNoProperties(NAME + " window", validated[0], 0, exprEvaluatorContext);

            if ((sortSize == null) || (!sortSize.IsNumber()))
            {
                throw new ViewParameterException(message);
            }
            SortWindowSize = sortSize.AsInt();

            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];
                }
            }
            SortCriteriaEvaluators = ExprNodeUtility.GetEvaluators(sortCriteriaExpressions);

            if (statementContext.ConfigSnapshot != null)
            {
                IsUseCollatorSort = statementContext.ConfigSnapshot.EngineDefaults.LanguageConfig.IsSortUsingCollator;
            }
        }
Пример #7
0
        public void Attach(
            EventType parentEventType,
            StatementContext statementContext,
            ViewFactory optionalParentFactory,
            IList <ViewFactory> parentViewFactories)
        {
            _eventType = parentEventType;
            const string 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 = ViewFactorySupport.Validate(
                NAME + " window", parentEventType, statementContext, _viewParameters, true);

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

            ViewFactorySupport.ValidateNoProperties(ViewName, validated[0], 0);
            _sizeEvaluator = ViewFactorySupport.ValidateSizeParam(ViewName, statementContext, 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];
                }
            }
            _sortCriteriaEvaluators = ExprNodeUtility.GetEvaluators(_sortCriteriaExpressions);

            if (statementContext.ConfigSnapshot != null)
            {
                _useCollatorSort = statementContext.ConfigSnapshot.EngineDefaults.Language.IsSortUsingCollator;
            }
        }
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            ExprNode[] validated = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, _viewParameters, true);
            if (validated.Length < 1)
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            if (!validated[0].ExprEvaluator.ReturnType.IsNumeric())
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            _fieldExpression = validated[0];

            _additionalProps = StatViewAdditionalProps.Make(validated, 1, parentEventType);
            _eventType       = UnivariateStatisticsView.CreateEventType(statementContext, _additionalProps, _streamNumber);
        }
Пример #9
0
        public void Attach(
            EventType parentEventType, 
            StatementContext statementContext, 
            ViewFactory optionalParentFactory, 
            IList<ViewFactory> parentViewFactories)
        {
            ExprNode[] validated = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, _viewParameters, true);

            if (_viewParameters.Count != 1)
            {
                throw new ViewParameterException(GetViewParamMessage());
            }
            if (validated[0].ExprEvaluator.ReturnType.GetBoxedType() != typeof(long?))
            {
                throw new ViewParameterException(GetViewParamMessage());
            }
            _timestampExpression = validated[0];
            _eventType = parentEventType;
            _timestampExpressionEvaluator = _timestampExpression.ExprEvaluator;
        }
Пример #10
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            _eventType = parentEventType;
            const string 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
            ExprNode[] validated = ViewFactorySupport.Validate(NAME, parentEventType, statementContext, _viewParameters, true);

            // find size-parameter index
            int indexNumericSize = -1;

            for (int 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 (int i = 0; i < indexNumericSize; i++)
            {
                ViewFactorySupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }
            for (int i = indexNumericSize + 1; i < validated.Length; i++)
            {
                ViewFactorySupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }

            // get sort size
            ViewFactorySupport.ValidateNoProperties(ViewName, validated[indexNumericSize], indexNumericSize);
            _sizeEvaluator = ViewFactorySupport.ValidateSizeParam(ViewName, statementContext, validated[indexNumericSize], indexNumericSize);

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

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

            int count = 0;

            for (int 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++;
            }

            _uniqueEvals = ExprNodeUtility.GetEvaluators(_uniqueCriteriaExpressions);
            _sortEvals   = ExprNodeUtility.GetEvaluators(_sortCriteriaExpressions);

            if (statementContext.ConfigSnapshot != null)
            {
                _useCollatorSort = statementContext.ConfigSnapshot.EngineDefaults.Language.IsSortUsingCollator;
            }
        }
Пример #11
0
 public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
 {
     ExprNode[] validated = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, _viewParameters, true);
     _additionalProps = StatViewAdditionalProps.Make(validated, 0, parentEventType);
     _eventType       = SizeView.CreateEventType(statementContext, _additionalProps, _streamNumber);
 }
Пример #12
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            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 = ViewFactorySupport.Validate(NAME, parentEventType, statementContext, _viewParameters, true);

            // find size-parameter index
            var indexNumericSize = -1;

            for (var i = 0; i < validated.Length; i++)
            {
                if (validated[i] is ExprConstantNode)
                {
                    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++)
            {
                ViewFactorySupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }
            for (var i = indexNumericSize + 1; i < validated.Length; i++)
            {
                ViewFactorySupport.AssertReturnsNonConstant(NAME, validated[i], i);
            }

            // get sort size
            var exprEvaluatorContext = new ExprEvaluatorContextStatement(statementContext, false);
            var sortSize             = ViewFactorySupport.EvaluateAssertNoProperties(NAME, validated[indexNumericSize], indexNumericSize, exprEvaluatorContext);

            if ((sortSize == null) || (!sortSize.IsNumber()))
            {
                throw new ViewParameterException(message);
            }
            SortWindowSize = sortSize.AsInt();

            // compile unique expressions
            uniqueCriteriaExpressions = new ExprNode[indexNumericSize];
            Array.Copy(validated, 0, uniqueCriteriaExpressions, 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++;
            }

            UniqueEvals = ExprNodeUtility.GetEvaluators(uniqueCriteriaExpressions);
            SortEvals   = ExprNodeUtility.GetEvaluators(sortCriteriaExpressions);

            if (statementContext.ConfigSnapshot != null)
            {
                IsUseCollatorSort = statementContext.ConfigSnapshot.EngineDefaults.LanguageConfig.IsSortUsingCollator;
            }
        }