Esempio n. 1
0
        private ExprAggMultiFunctionSortedMinMaxByNodeFactory HandleIntoTable(
            ExprValidationContext validationContext)
        {
            int streamNum;
            var positionalParams = PositionalParams;
            if (positionalParams.Length == 0 ||
                positionalParams.Length == 1 && positionalParams[0] is ExprWildcard)
            {
                ExprAggMultiFunctionUtil.ValidateWildcardStreamNumbers(validationContext.StreamTypeService,
                    AggregationFunctionName);
                streamNum = 0;
            }
            else if (positionalParams.Length == 1 && positionalParams[0] is ExprStreamUnderlyingNode)
            {
                streamNum = ExprAggMultiFunctionUtil.ValidateStreamWildcardGetStreamNum(positionalParams[0]);
            }
            else if (positionalParams.Length > 0)
            {
                throw new ExprValidationException("When specifying into-table a sort expression cannot be provided");
            }
            else
            {
                streamNum = 0;
            }

            var containedType = validationContext.StreamTypeService.EventTypes[streamNum];
            var componentType = containedType.UnderlyingType;
            var accessorResultType = componentType;
            AggregationAccessor accessor;
            if (!_sortedwin)
            {
                accessor = new AggregationAccessorMinMaxByNonTable(IsMax);
            }
            else
            {
                accessor = new AggregationAccessorSortedNonTable(IsMax, componentType);
                accessorResultType = TypeHelper.GetArrayType(accessorResultType);
            }

            var agent = ExprAggAggregationAgentFactory.Make(streamNum, OptionalFilter);
            return new ExprAggMultiFunctionSortedMinMaxByNodeFactory(this, accessor, accessorResultType, containedType,
                null, null, agent);
        }
        private LinearAggregationFactoryDesc HandleIntoTable(
            ExprNode[] childNodes,
            AggregationStateType stateType,
            ExprValidationContext validationContext)
        {
            var message = "For into-table use 'window(*)' or ''window(stream.*)' instead";
            if (stateType != AggregationStateType.WINDOW) throw new ExprValidationException(message);
            if (childNodes.Length == 0 || childNodes.Length > 1) throw new ExprValidationException(message);
            if (validationContext.StreamTypeService.StreamNames.Length == 0)
                throw new ExprValidationException(GetErrorPrefix(stateType) +
                                                  " requires that at least one stream is provided");
            int streamNum;
            if (childNodes[0] is ExprWildcard)
            {
                if (validationContext.StreamTypeService.StreamNames.Length != 1)
                    throw new ExprValidationException(GetErrorPrefix(stateType) +
                                                      " with wildcard requires a single stream");
                streamNum = 0;
            }
            else if (childNodes[0] is ExprStreamUnderlyingNode)
            {
                var und = (ExprStreamUnderlyingNode) childNodes[0];
                streamNum = und.StreamId;
            }
            else
            {
                throw new ExprValidationException(message);
            }

            var containedType = validationContext.StreamTypeService.EventTypes[streamNum];
            var componentType = containedType.UnderlyingType;
            var accessor = new AggregationAccessorWindowNoEval(componentType);
            var agent = ExprAggAggregationAgentFactory.Make(streamNum, OptionalFilter);
            var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess(this, accessor,
                TypeHelper.GetArrayType(componentType), containedType, null, null, agent);
            return new LinearAggregationFactoryDesc(factory, factory.ContainedEventType, null);
        }