public ExprAggMultiFunctionLinearAccessNodeFactoryMethod(ExprAggMultiFunctionLinearAccessNode parent, EventType collectionEventType, Type resultType, int streamNum)
 {
     _parent = parent;
     _collectionEventType = collectionEventType;
     _resultType          = resultType;
     _streamNum           = streamNum;
 }
示例#2
0
 public AggregationMethodFactoryFirstLastUnbound(ExprAggMultiFunctionLinearAccessNode parent,
     EventType collectionEventType, Type resultType, int streamNum, bool hasFilter)
 {
     _parent = parent;
     _collectionEventType = collectionEventType;
     _resultType = resultType;
     _streamNum = streamNum;
     _hasFilter = hasFilter;
 }
示例#3
0
 public ExprAggMultiFunctionLinearAccessNodeFactoryAccess(ExprAggMultiFunctionLinearAccessNode parent, AggregationAccessor accessor, Type accessorResultType, EventType containedEventType, AggregationStateKey optionalStateKey, AggregationStateFactory optionalStateFactory, AggregationAgent optionalAgent)
 {
     _parent               = parent;
     _accessor             = accessor;
     _accessorResultType   = accessorResultType;
     _containedEventType   = containedEventType;
     _optionalStateKey     = optionalStateKey;
     _optionalStateFactory = optionalStateFactory;
     _optionalAgent        = optionalAgent;
 }
        private ExprAggMultiFunctionSortedMinMaxByNodeFactory HandleNonTable(ExprValidationContext validationContext)

        {
            if (PositionalParams.Length == 0)
            {
                throw new ExprValidationException("Missing the sort criteria expression");
            }

            // validate that the streams referenced in the criteria are a single stream's
            var streams = ExprNodeUtility.GetIdentStreamNumbers(PositionalParams[0]);

            if (streams.Count > 1 || streams.IsEmpty())
            {
                throw new ExprValidationException(ErrorPrefix + " requires that any parameter expressions evaluate properties of the same stream");
            }
            int streamNum = streams.First();

            // validate that there is a remove stream, use "ever" if not
            var forceEver = false;

            if (!_ever && ExprAggMultiFunctionLinearAccessNode.GetIstreamOnly(validationContext.StreamTypeService, streamNum))
            {
                if (_sortedwin)
                {
                    throw new ExprValidationException(ErrorPrefix + " requires that a data window is declared for the stream");
                }
                forceEver = true;
            }

            // determine typing and evaluation
            _containedType = validationContext.StreamTypeService.EventTypes[streamNum];

            var componentType      = _containedType.UnderlyingType;
            var accessorResultType = componentType;
            AggregationAccessor accessor;
            TableMetadata       tableMetadata = validationContext.TableService.GetTableMetadataFromEventType(_containedType);

            if (!_sortedwin)
            {
                if (tableMetadata != null)
                {
                    accessor = new AggregationAccessorMinMaxByTable(_max, tableMetadata);
                }
                else
                {
                    accessor = new AggregationAccessorMinMaxByNonTable(_max);
                }
            }
            else
            {
                if (tableMetadata != null)
                {
                    accessor = new AggregationAccessorSortedTable(_max, componentType, tableMetadata);
                }
                else
                {
                    accessor = new AggregationAccessorSortedNonTable(_max, componentType);
                }
                accessorResultType = TypeHelper.GetArrayType(accessorResultType);
            }

            Pair <ExprNode[], bool[]> criteriaExpressions = CriteriaExpressions;

            AggregationStateTypeWStream type;

            if (_ever)
            {
                type = _max ? AggregationStateTypeWStream.MAXEVER : AggregationStateTypeWStream.MINEVER;
            }
            else
            {
                type = AggregationStateTypeWStream.SORTED;
            }
            var stateKey = new AggregationStateKeyWStream(streamNum, _containedType, type, criteriaExpressions.First);

            var stateFactoryFactory = new
                                      SortedAggregationStateFactoryFactory(validationContext.MethodResolutionService,
                                                                           ExprNodeUtility.GetEvaluators(criteriaExpressions.First),
                                                                           criteriaExpressions.Second, _ever, streamNum, this);

            return(new ExprAggMultiFunctionSortedMinMaxByNodeFactory(this, accessor, accessorResultType, _containedType, stateKey, stateFactoryFactory, AggregationAgentDefault.INSTANCE));
        }
示例#5
0
        private ExprAggMultiFunctionSortedMinMaxByNodeFactory HandleNonTable(ExprValidationContext validationContext)
        {
            var positionalParams = PositionalParams;
            if (positionalParams.Length == 0)
                throw new ExprValidationException("Missing the sort criteria expression");

            // validate that the streams referenced in the criteria are a single stream's
            var streams = ExprNodeUtility.GetIdentStreamNumbers(positionalParams[0]);
            if (streams.Count > 1 || streams.IsEmpty())
                throw new ExprValidationException(
                    GetErrorPrefix() + " requires that any parameter expressions evaluate properties of the same stream");
            var streamNum = streams.First();

            // validate that there is a remove stream, use "ever" if not
            if (!_ever && ExprAggMultiFunctionLinearAccessNode.GetIstreamOnly(validationContext.StreamTypeService,
                    streamNum))
                if (_sortedwin)
                    throw new ExprValidationException(
                        GetErrorPrefix() + " requires that a data window is declared for the stream");

            // determine typing and evaluation
            _containedType = validationContext.StreamTypeService.EventTypes[streamNum];

            var componentType = _containedType.UnderlyingType;
            var accessorResultType = componentType;
            AggregationAccessor accessor;
            var tableMetadata = validationContext.TableService.GetTableMetadataFromEventType(_containedType);
            if (!_sortedwin)
            {
                if (tableMetadata != null)
                    accessor = new AggregationAccessorMinMaxByTable(IsMax, tableMetadata);
                else
                    accessor = new AggregationAccessorMinMaxByNonTable(IsMax);
            }
            else
            {
                if (tableMetadata != null)
                    accessor = new AggregationAccessorSortedTable(IsMax, componentType, tableMetadata);
                else
                    accessor = new AggregationAccessorSortedNonTable(IsMax, componentType);
                accessorResultType = TypeHelper.GetArrayType(accessorResultType);
            }

            var criteriaExpressions = CriteriaExpressions;

            AggregationStateTypeWStream type;
            if (_ever)
                type = IsMax ? AggregationStateTypeWStream.MAXEVER : AggregationStateTypeWStream.MINEVER;
            else
                type = AggregationStateTypeWStream.SORTED;

            var optionalFilter = OptionalFilter;
            var stateKey = new AggregationStateKeyWStream(
                streamNum, _containedType, type, criteriaExpressions.First, optionalFilter);

            var optionalFilterEval = optionalFilter?.ExprEvaluator;
            var stateFactoryFactory = new
                SortedAggregationStateFactoryFactory(validationContext.EngineImportService,
                    validationContext.StatementExtensionSvcContext,
                    ExprNodeUtility.GetEvaluators(criteriaExpressions.First),
                    criteriaExpressions.Second, _ever, streamNum, this, optionalFilterEval);

            return new ExprAggMultiFunctionSortedMinMaxByNodeFactory(this, accessor, accessorResultType, _containedType,
                stateKey, stateFactoryFactory, AggregationAgentDefault.INSTANCE);
        }