Beispiel #1
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);
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
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;
            }
        }