コード例 #1
0
 /// <summary>Ctor. </summary>
 /// <param name="statementResultService">for awareness of listeners and subscribers handles output results</param>
 /// <param name="syntheticProcessor">is the processor generating synthetic events according to the select clause</param>
 /// <param name="bindProcessor">for generating natural object column results</param>
 public SelectExprResultProcessor(StatementResultService statementResultService,
                                  SelectExprProcessor syntheticProcessor,
                                  BindProcessor bindProcessor)
 {
     _statementResultService = statementResultService;
     _syntheticProcessor     = syntheticProcessor;
     _bindProcessor          = bindProcessor;
 }
コード例 #2
0
 public SelectExprProcessorWDeliveryCallback(EventType eventType,
                                             BindProcessor bindProcessor,
                                             SelectExprProcessorDeliveryCallback selectExprProcessorCallback)
 {
     _eventType     = eventType;
     _bindProcessor = bindProcessor;
     _selectExprProcessorCallback = selectExprProcessorCallback;
 }
コード例 #3
0
        /// <summary>
        /// Returns the processor to use for a given select-clause.
        /// </summary>
        /// <param name="assignedTypeNumberStack">The assigned type number stack.</param>
        /// <param name="selectionList">the list of select clause elements/items, which are expected to have been validated</param>
        /// <param name="isUsingWildcard">true if the wildcard (*) occurs in the select clause</param>
        /// <param name="insertIntoDesc">contains column names for the optional insert-into clause (if supplied)</param>
        /// <param name="optionalInsertIntoEventType">Type of the optional insert into event.</param>
        /// <param name="forClauseSpec">For clause spec.</param>
        /// <param name="typeService">serves stream type information</param>
        /// <param name="eventAdapterService">for generating wrapper instances for events</param>
        /// <param name="statementResultService">handles listeners/subscriptions awareness to reduce output result generation</param>
        /// <param name="valueAddEventService">service that handles update events and variant events</param>
        /// <param name="selectExprEventTypeRegistry">registry for event type to statements</param>
        /// <param name="engineImportService"></param>
        /// <param name="exprEvaluatorContext">context for expression evalauation</param>
        /// <param name="variableService">The variable service.</param>
        /// <param name="scriptingService">The scripting service.</param>
        /// <param name="tableService">The table service.</param>
        /// <param name="timeProvider">The time provider.</param>
        /// <param name="engineURI">The engine URI.</param>
        /// <param name="statementId">The statement identifier.</param>
        /// <param name="statementName">Name of the statement.</param>
        /// <param name="annotations">The annotations.</param>
        /// <param name="contextDescriptor">The context descriptor.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="selectExprProcessorCallback">The select expr processor callback.</param>
        /// <param name="namedWindowMgmtService">The named window service.</param>
        /// <param name="intoTableClause">The into table clause.</param>
        /// <param name="groupByRollupInfo"></param>
        /// <param name="statementExtensionSvcContext"></param>
        /// <returns>
        /// select-clause expression processor
        /// </returns>
        /// <exception cref="ExprValidationException">Expected any of the  + Arrays.ToString(ForClauseKeyword.Values()).ToLowerCase() +  for-clause keywords after reserved keyword 'for'
        /// or
        /// The for-clause with the  + ForClauseKeyword.GROUPED_DELIVERY.Name +  keyword requires one or more grouping expressions
        /// or
        /// The for-clause with the  + ForClauseKeyword.DISCRETE_DELIVERY.Name +  keyword does not allow grouping expressions
        /// or
        /// The for-clause with delivery keywords may only occur once in a statement
        /// or
        /// Expected any of the  + Arrays.ToString(ForClauseKeyword.Values()).ToLowerCase() +  for-clause keywords after reserved keyword 'for'</exception>
        /// <throws>ExprValidationException to indicate the select expression cannot be validated</throws>
        public static SelectExprProcessor GetProcessor(
            ICollection <int> assignedTypeNumberStack,
            SelectClauseElementCompiled[] selectionList,
            bool isUsingWildcard,
            InsertIntoDesc insertIntoDesc,
            EventType optionalInsertIntoEventType,
            ForClauseSpec forClauseSpec,
            StreamTypeService typeService,
            EventAdapterService eventAdapterService,
            StatementResultService statementResultService,
            ValueAddEventService valueAddEventService,
            SelectExprEventTypeRegistry selectExprEventTypeRegistry,
            EngineImportService engineImportService,
            ExprEvaluatorContext exprEvaluatorContext,
            VariableService variableService,
            ScriptingService scriptingService,
            TableService tableService,
            TimeProvider timeProvider,
            string engineURI,
            int statementId,
            string statementName,
            Attribute[] annotations,
            ContextDescriptor contextDescriptor,
            ConfigurationInformation configuration,
            SelectExprProcessorDeliveryCallback selectExprProcessorCallback,
            NamedWindowMgmtService namedWindowMgmtService,
            IntoTableSpec intoTableClause,
            GroupByRollupInfo groupByRollupInfo,
            StatementExtensionSvcContext statementExtensionSvcContext)
        {
            if (selectExprProcessorCallback != null)
            {
                var bindProcessor = new BindProcessor(selectionList, typeService.EventTypes, typeService.StreamNames, tableService);
                IDictionary <string, object> properties = new LinkedHashMap <string, object>();
                for (var i = 0; i < bindProcessor.ColumnNamesAssigned.Length; i++)
                {
                    properties.Put(bindProcessor.ColumnNamesAssigned[i], bindProcessor.ExpressionTypes[i]);
                }
                var eventType = eventAdapterService.CreateAnonymousObjectArrayType("Output_" + statementName, properties);
                return(new SelectExprProcessorWDeliveryCallback(eventType, bindProcessor, selectExprProcessorCallback));
            }

            var synthetic = GetProcessorInternal(
                assignedTypeNumberStack, selectionList, isUsingWildcard, insertIntoDesc, optionalInsertIntoEventType,
                typeService, eventAdapterService, valueAddEventService, selectExprEventTypeRegistry,
                engineImportService, statementId, statementName, annotations, configuration, namedWindowMgmtService, tableService,
                groupByRollupInfo);

            // Handle table as an optional service
            if (statementResultService != null)
            {
                // Handle for-clause delivery contract checking
                ExprNode[] groupedDeliveryExpr = null;
                var        forDelivery         = false;
                if (forClauseSpec != null)
                {
                    foreach (var item in forClauseSpec.Clauses)
                    {
                        if (item.Keyword == null)
                        {
                            throw new ExprValidationException("Expected any of the " + EnumHelper.GetValues <ForClauseKeyword>().Render().ToLower() + " for-clause keywords after reserved keyword 'for'");
                        }
                        try
                        {
                            ForClauseKeyword keyword = EnumHelper.Parse <ForClauseKeyword>(item.Keyword);
                            if ((keyword == ForClauseKeyword.GROUPED_DELIVERY) && (item.Expressions.IsEmpty()))
                            {
                                throw new ExprValidationException(
                                          "The for-clause with the " + ForClauseKeyword.GROUPED_DELIVERY.GetName() +
                                          " keyword requires one or more grouping expressions");
                            }
                            if ((keyword == ForClauseKeyword.DISCRETE_DELIVERY) && (!item.Expressions.IsEmpty()))
                            {
                                throw new ExprValidationException(
                                          "The for-clause with the " + ForClauseKeyword.DISCRETE_DELIVERY.GetName() +
                                          " keyword does not allow grouping expressions");
                            }
                            if (forDelivery)
                            {
                                throw new ExprValidationException(
                                          "The for-clause with delivery keywords may only occur once in a statement");
                            }
                        }
                        catch (ExprValidationException)
                        {
                            throw;
                        }
                        catch (EPException)
                        {
                            throw;
                        }
                        catch (Exception ex)
                        {
                            throw new ExprValidationException("Expected any of the " + EnumHelper.GetValues <ForClauseKeyword>().Render().ToLower() + " for-clause keywords after reserved keyword 'for'", ex);
                        }

                        StreamTypeService type = new StreamTypeServiceImpl(synthetic.ResultEventType, null, false, engineURI);
                        groupedDeliveryExpr = new ExprNode[item.Expressions.Count];
                        var validationContext = new ExprValidationContext(type, engineImportService, statementExtensionSvcContext, null, timeProvider, variableService, tableService, exprEvaluatorContext, eventAdapterService, statementName, statementId, annotations, null, scriptingService, false, false, true, false, intoTableClause == null ? null : intoTableClause.Name, false);  // no context descriptor available
                        for (var i = 0; i < item.Expressions.Count; i++)
                        {
                            groupedDeliveryExpr[i] = ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.FORCLAUSE, item.Expressions[i], validationContext);
                        }
                        forDelivery = true;
                    }
                }

                var bindProcessor = new BindProcessor(selectionList, typeService.EventTypes, typeService.StreamNames, tableService);
                statementResultService.SetSelectClause(bindProcessor.ExpressionTypes, bindProcessor.ColumnNamesAssigned, forDelivery, ExprNodeUtility.GetEvaluators(groupedDeliveryExpr), exprEvaluatorContext);
                return(new SelectExprResultProcessor(statementResultService, synthetic, bindProcessor));
            }

            return(synthetic);
        }