Exemplo n.º 1
0
        private static void CompileReclaim(
            AggGroupByDesc groupDesc,
            HintAttribute reclaimGroupAged,
            HintAttribute reclaimGroupFrequency,
            VariableCompileTimeResolver variableCompileTimeResolver,
            string optionalContextName)
        {
            var hintValueMaxAge = HintEnum.RECLAIM_GROUP_AGED.GetHintAssignedValue(reclaimGroupAged);
            if (hintValueMaxAge == null) {
                throw new ExprValidationException(
                    "Required hint value for hint '" + HintEnum.RECLAIM_GROUP_AGED + "' has not been provided");
            }

            var evaluationFunctionMaxAge = GetEvaluationFunction(
                variableCompileTimeResolver,
                hintValueMaxAge,
                optionalContextName);
            groupDesc.IsReclaimAged = true;
            groupDesc.SetReclaimEvaluationFunctionMaxAge(evaluationFunctionMaxAge);

            var hintValueFrequency = HintEnum.RECLAIM_GROUP_FREQ.GetHintAssignedValue(reclaimGroupAged);
            AggSvcGroupByReclaimAgedEvalFuncFactoryForge evaluationFunctionFrequency;
            if (reclaimGroupFrequency == null || hintValueFrequency == null) {
                evaluationFunctionFrequency = evaluationFunctionMaxAge;
            }
            else {
                evaluationFunctionFrequency = GetEvaluationFunction(
                    variableCompileTimeResolver,
                    hintValueFrequency,
                    optionalContextName);
            }

            groupDesc.SetReclaimEvaluationFunctionFrequency(evaluationFunctionFrequency);
        }
Exemplo n.º 2
0
        public VariableMetaData IsVariableOpGetName(VariableCompileTimeResolver variableCompileTimeResolver)
        {
            if (ChainSpec.Count > 0 && ChainSpec[0].IsProperty) {
                return variableCompileTimeResolver.Resolve(ChainSpec[0].Name);
            }

            return null;
        }
Exemplo n.º 3
0
        public static void AddOptionalSimpleProperty(
            ExprNode exprNode,
            IToken token,
            VariableCompileTimeResolver variableCompileTimeResolver,
            StatementSpecRaw spec)
        {
            if (token == null)
            {
                return;
            }

            ExprNode node = ASTExprHelper.ResolvePropertyOrVariableIdentifier(token.Text, variableCompileTimeResolver, spec);
            exprNode.AddChildNode(node);
        }
Exemplo n.º 4
0
 public StatementSpecMapEnv(
     ImportServiceCompileTime importService,
     VariableCompileTimeResolver variableCompileTimeResolver,
     Configuration configuration,
     ExprDeclaredCompileTimeResolver exprDeclaredCompileTimeResolver,
     ContextCompileTimeResolver contextCompileTimeResolver,
     TableCompileTimeResolver tableCompileTimeResolver,
     ScriptCompileTimeResolver scriptCompileTimeResolver,
     CompilerServices compilerServices)
 {
     ImportService = importService;
     VariableCompileTimeResolver = variableCompileTimeResolver;
     Configuration = configuration;
     ExprDeclaredCompileTimeResolver = exprDeclaredCompileTimeResolver;
     ContextCompileTimeResolver = contextCompileTimeResolver;
     TableCompileTimeResolver = tableCompileTimeResolver;
     ScriptCompileTimeResolver = scriptCompileTimeResolver;
     CompilerServices = compilerServices;
 }
Exemplo n.º 5
0
        private static AggSvcGroupByReclaimAgedEvalFuncFactoryForge GetEvaluationFunction(
            VariableCompileTimeResolver variableCompileTimeResolver,
            string hintValue,
            string optionalContextName)
        {
            var variableMetaData = variableCompileTimeResolver.Resolve(hintValue);
            if (variableMetaData != null) {
                if (!variableMetaData.Type.IsNumeric()) {
                    throw new ExprValidationException(
                        "Variable type of variable '" + variableMetaData.VariableName + "' is not numeric");
                }

                var message = VariableUtil.CheckVariableContextName(optionalContextName, variableMetaData);
                if (message != null) {
                    throw new ExprValidationException(message);
                }

                return new AggSvcGroupByReclaimAgedEvalFuncFactoryVariableForge(variableMetaData);
            }

            double valueDouble;
            try {
                valueDouble = Double.Parse(hintValue);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception) {
                throw new ExprValidationException(
                    "Failed to parse hint parameter value '" +
                    hintValue +
                    "' as a double-typed seconds value or variable name");
            }

            if (valueDouble <= 0) {
                throw new ExprValidationException(
                    "Hint parameter value '" +
                    hintValue +
                    "' is an invalid value, expecting a double-typed seconds value or variable name");
            }

            return new AggSvcGroupByReclaimAgedEvalFuncFactoryConstForge(valueDouble);
        }
Exemplo n.º 6
0
        public static ExprNode ResolvePropertyOrVariableIdentifier(
            string identifier,
            VariableCompileTimeResolver variableCompileTimeResolver,
            StatementSpecRaw spec)
        {
            VariableMetaData metaData = variableCompileTimeResolver.Resolve(identifier);
            if (metaData != null)
            {
                ExprVariableNodeImpl exprNode = new ExprVariableNodeImpl(metaData, null);
                spec.ReferencedVariables.Add(metaData.VariableName);
                string message = VariableUtil.CheckVariableContextName(spec.OptionalContextName, metaData);
                if (message != null)
                {
                    throw ASTWalkException.From(message);
                }

                return exprNode;
            }

            return new ExprIdentNodeImpl(identifier);
        }
Exemplo n.º 7
0
        public static void ValidateAlreadyExistsTableOrVariable(
            string name,
            VariableCompileTimeResolver variableCompileTimeResolver,
            TableCompileTimeResolver tableCompileTimeResolver,
            EventTypeCompileTimeResolver eventTypeCompileTimeResolver)
        {
            var existingTable = tableCompileTimeResolver.Resolve(name);
            if (existingTable != null) {
                throw new ExprValidationException("A table by name '" + name + "' has already been declared");
            }

            var existingVariable = variableCompileTimeResolver.Resolve(name);
            if (existingVariable != null) {
                throw new ExprValidationException("A variable by name '" + name + "' has already been declared");
            }

            var existingEventType = eventTypeCompileTimeResolver.GetTypeByName(name);
            if (existingEventType != null) {
                throw new ExprValidationException("An event type by name '" + name + "' has already been declared");
            }
        }
Exemplo n.º 8
0
        public static ExprTimePeriod TimePeriodGetExprAllParams(
            EsperEPL2GrammarParser.TimePeriodContext ctx,
            IDictionary<ITree, ExprNode> astExprNodeMap,
            VariableCompileTimeResolver variableCompileTimeResolver,
            StatementSpecRaw spec,
            Configuration config,
            TimeAbacus timeAbacus)
        {
            ExprNode[] nodes = new ExprNode[9];
            for (int i = 0; i < ctx.ChildCount; i++)
            {
                IParseTree unitRoot = ctx.GetChild(i);

                ExprNode valueExpr;
                if (ASTUtil.IsTerminatedOfType(unitRoot.GetChild(0), EsperEPL2GrammarLexer.IDENT))
                {
                    string ident = unitRoot.GetChild(0).GetText();
                    valueExpr = ASTExprHelper.ResolvePropertyOrVariableIdentifier(ident, variableCompileTimeResolver, spec);
                }
                else
                {
                    AtomicReference<ExprNode> @ref = new AtomicReference<ExprNode>();
                    ExprAction action = (exprNode, astExprNodeMapX, node) => {
                        astExprNodeMapX.Remove(node);
                        @ref.Set(exprNode);
                    };
                    ASTExprHelper.RecursiveFindRemoveChildExprNode(unitRoot.GetChild(0), astExprNodeMap, action);
                    valueExpr = @ref.Get();
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_microsecondPart)
                {
                    nodes[8] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_millisecondPart)
                {
                    nodes[7] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_secondPart)
                {
                    nodes[6] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_minutePart)
                {
                    nodes[5] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_hourPart)
                {
                    nodes[4] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_dayPart)
                {
                    nodes[3] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_weekPart)
                {
                    nodes[2] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_monthPart)
                {
                    nodes[1] = valueExpr;
                }

                if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_yearPart)
                {
                    nodes[0] = valueExpr;
                }
            }

            ExprTimePeriod timeNode = new ExprTimePeriodImpl(
                nodes[0] != null, nodes[1] != null,
                nodes[2] != null, nodes[3] != null,
                nodes[4] != null, nodes[5] != null,
                nodes[6] != null, nodes[7] != null,
                nodes[8] != null, timeAbacus);

            foreach (ExprNode node in nodes)
            {
                if (node != null)
                {
                    timeNode.AddChildNode(node);
                }
            }

            return timeNode;
        }
Exemplo n.º 9
0
        public static AggregationServiceForgeDesc GetService(
            IList<ExprAggregateNode> selectAggregateExprNodes,
            IDictionary<ExprNode, string> selectClauseNamedNodes,
            IList<ExprDeclaredNode> declaredExpressions,
            ExprNode[] groupByNodes,
            MultiKeyClassRef groupByMultiKey,
            IList<ExprAggregateNode> havingAggregateExprNodes,
            IList<ExprAggregateNode> orderByAggregateExprNodes,
            IList<ExprAggregateNodeGroupKey> groupKeyExpressions,
            bool hasGroupByClause,
            Attribute[] annotations,
            VariableCompileTimeResolver variableCompileTimeResolver,
            bool isDisallowNoReclaim,
            ExprNode whereClause,
            ExprNode havingClause,
            EventType[] typesPerStream,
            AggregationGroupByRollupDescForge groupByRollupDesc,
            string optionalContextName,
            IntoTableSpec intoTableSpec,
            TableCompileTimeResolver tableCompileTimeResolver,
            bool isUnidirectional,
            bool isFireAndForget,
            bool isOnSelect,
            ImportServiceCompileTime importService,
            StatementRawInfo raw,
            SerdeCompileTimeResolver serdeResolver)
        {
            // No aggregates used, we do not need this service
            if (selectAggregateExprNodes.IsEmpty() && havingAggregateExprNodes.IsEmpty()) {
                if (intoTableSpec != null) {
                    throw new ExprValidationException("Into-table requires at least one aggregation function");
                }

                return new AggregationServiceForgeDesc(
                    AggregationServiceNullFactory.INSTANCE,
                    EmptyList<AggregationServiceAggExpressionDesc>.Instance,
                    EmptyList<ExprAggregateNodeGroupKey>.Instance,
                    EmptyList<StmtClassForgeableFactory>.Instance);
            }

            // Validate the absence of "prev" function in where-clause:
            // Since the "previous" function does not post remove stream results, disallow when used with aggregations.
            if (whereClause != null || havingClause != null) {
                var visitor = new ExprNodePreviousVisitorWParent();
                whereClause?.Accept(visitor);

                havingClause?.Accept(visitor);

                if (visitor.Previous != null && !visitor.Previous.IsEmpty()) {
                    string funcname = visitor.Previous[0]
                        .Second.PreviousType.ToString()
                        .ToLowerInvariant();
                    throw new ExprValidationException(
                        "The '" +
                        funcname +
                        "' function may not occur in the where-clause or having-clause of a statement with aggregations as 'previous' does not provide remove stream data; Use the 'first','last','window' or 'count' aggregation functions instead");
                }
            }

            // Compile a map of aggregation nodes and equivalent-to aggregation nodes.
            // Equivalent-to functions are for example "select sum(a*b), 5*sum(a*b)".
            // Reducing the total number of aggregation functions.
            var aggregations = new List<AggregationServiceAggExpressionDesc>();
            var intoTableNonRollup = groupByRollupDesc == null && intoTableSpec != null;
            foreach (var selectAggNode in selectAggregateExprNodes) {
                AddEquivalent(selectAggNode, aggregations, intoTableNonRollup);
            }

            foreach (var havingAggNode in havingAggregateExprNodes) {
                AddEquivalent(havingAggNode, aggregations, intoTableNonRollup);
            }

            foreach (var orderByAggNode in orderByAggregateExprNodes) {
                AddEquivalent(orderByAggNode, aggregations, intoTableNonRollup);
            }

            // Construct a list of evaluation node for the aggregation functions (regular agg).
            // For example "sum(2 * 3)" would make the sum an evaluation node.
            IList<ExprForge[]> methodAggForgesList = new List<ExprForge[]>();
            foreach (var aggregation in aggregations) {
                var aggregateNode = aggregation.AggregationNode;
                if (!aggregateNode.Factory.IsAccessAggregation) {
                    var forges = aggregateNode.Factory.GetMethodAggregationForge(
                        typesPerStream.Length > 1,
                        typesPerStream);
                    methodAggForgesList.Add(forges);
                }
            }

            // determine local group-by, report when hook provided
            var localGroupDesc = AnalyzeLocalGroupBy(aggregations, groupByNodes, groupByRollupDesc, intoTableSpec);

            // determine binding
            if (intoTableSpec != null) {
                // obtain metadata
                var metadata = tableCompileTimeResolver.Resolve(intoTableSpec.Name);
                if (metadata == null) {
                    throw new ExprValidationException(
                        "Invalid into-table clause: Failed to find table by name '" + intoTableSpec.Name + "'");
                }

                EPLValidationUtil.ValidateContextName(
                    true,
                    intoTableSpec.Name,
                    metadata.OptionalContextName,
                    optionalContextName,
                    false);

                // validate group keys
                var groupByTypes = ExprNodeUtilityQuery.GetExprResultTypes(groupByNodes);
                var keyTypes = metadata.IsKeyed ? metadata.KeyTypes : new Type[0];
                ExprTableNodeUtil.ValidateExpressions(
                    intoTableSpec.Name,
                    groupByTypes,
                    "group-by",
                    groupByNodes,
                    keyTypes,
                    "group-by");

                // determine how this binds to existing aggregations, assign column numbers
                var bindingMatchResult = MatchBindingsAssignColumnNumbers(
                    intoTableSpec,
                    metadata,
                    aggregations,
                    selectClauseNamedNodes,
                    methodAggForgesList,
                    declaredExpressions,
                    importService,
                    raw.StatementName);

                // return factory
                AggregationServiceFactoryForge serviceForgeX = new AggregationServiceFactoryForgeTable(
                    metadata,
                    bindingMatchResult.MethodPairs,
                    bindingMatchResult.TargetStates,
                    bindingMatchResult.Agents,
                    groupByRollupDesc);
                return new AggregationServiceForgeDesc(serviceForgeX, aggregations, groupKeyExpressions, EmptyList<StmtClassForgeableFactory>.Instance);
            }

            // Assign a column number to each aggregation node. The regular aggregation goes first followed by access-aggregation.
            var columnNumber = 0;
            foreach (var entry in aggregations) {
                if (!entry.Factory.IsAccessAggregation) {
                    entry.SetColumnNum(columnNumber++);
                }
            }

            foreach (var entry in aggregations) {
                if (entry.Factory.IsAccessAggregation) {
                    entry.SetColumnNum(columnNumber++);
                }
            }

            // determine method aggregation factories and evaluators(non-access)
            var methodAggForges = methodAggForgesList.ToArray();
            var methodAggFactories = new AggregationForgeFactory[methodAggForges.Length];
            var count = 0;
            foreach (var aggregation in aggregations) {
                var aggregateNode = aggregation.AggregationNode;
                if (!aggregateNode.Factory.IsAccessAggregation) {
                    methodAggFactories[count] = aggregateNode.Factory;
                    count++;
                }
            }

            // handle access aggregations
            var multiFunctionAggPlan = AggregationMultiFunctionAnalysisHelper.AnalyzeAccessAggregations(
                aggregations,
                importService,
                isFireAndForget,
                raw.StatementName,
                groupByNodes);
            var accessorPairsForge = multiFunctionAggPlan.AccessorPairsForge;
            var accessFactories = multiFunctionAggPlan.StateFactoryForges;
            var hasAccessAgg = accessorPairsForge.Length > 0;
            var hasMethodAgg = methodAggFactories.Length > 0;

            AggregationServiceFactoryForge serviceForge;
            var useFlags = new AggregationUseFlags(isUnidirectional, isFireAndForget, isOnSelect);
            var additionalForgeables = new List<StmtClassForgeableFactory>();

            // analyze local group by
            AggregationLocalGroupByPlanForge localGroupByPlan = null;
            if (localGroupDesc != null) {
                AggregationLocalGroupByPlanDesc plan = AggregationGroupByLocalGroupByAnalyzer.Analyze(
                    methodAggForges,
                    methodAggFactories,
                    accessFactories,
                    localGroupDesc,
                    groupByNodes,
                    groupByMultiKey,
                    accessorPairsForge,
                    raw,
                    serdeResolver);
                localGroupByPlan = plan.Forge;
                additionalForgeables.AddAll(plan.AdditionalForgeables);

                try {
                    var hook = (AggregationLocalLevelHook) ImportUtil.GetAnnotationHook(
                        annotations,
                        HookType.INTERNAL_AGGLOCALLEVEL,
                        typeof(AggregationLocalLevelHook),
                        importService);
                    hook?.Planned(localGroupDesc, localGroupByPlan);
                }
                catch (ExprValidationException) {
                    throw new EPException("Failed to obtain hook for " + HookType.INTERNAL_AGGLOCALLEVEL);
                }
            }

            // Handle without a group-by clause: we group all into the same pot
            var rowStateDesc = new AggregationRowStateForgeDesc(
                hasMethodAgg ? methodAggFactories : null,
                hasMethodAgg ? methodAggForges : null,
                hasAccessAgg ? accessFactories : null,
                hasAccessAgg ? accessorPairsForge : null,
                useFlags);
            if (!hasGroupByClause) {
                if (localGroupByPlan != null) {
                    serviceForge = new AggSvcLocalGroupByForge(false, localGroupByPlan, useFlags);
                }
                else {
                    serviceForge = new AggregationServiceGroupAllForge(rowStateDesc);
                }
            }
            else {
                var groupDesc = new AggGroupByDesc(
                    rowStateDesc,
                    isUnidirectional,
                    isFireAndForget,
                    isOnSelect,
                    groupByNodes,
                    groupByMultiKey);
                var hasNoReclaim = HintEnum.DISABLE_RECLAIM_GROUP.GetHint(annotations) != null;
                var reclaimGroupAged = HintEnum.RECLAIM_GROUP_AGED.GetHint(annotations);
                var reclaimGroupFrequency = HintEnum.RECLAIM_GROUP_AGED.GetHint(annotations);
                if (localGroupByPlan != null) {
                    serviceForge = new AggSvcLocalGroupByForge(true, localGroupByPlan, useFlags);
                }
                else {
                    if (!isDisallowNoReclaim && hasNoReclaim) {
                        if (groupByRollupDesc != null) {
                            throw GetRollupReclaimEx();
                        }

                        serviceForge = new AggregationServiceGroupByForge(groupDesc, importService.TimeAbacus);
                    }
                    else if (!isDisallowNoReclaim && reclaimGroupAged != null) {
                        if (groupByRollupDesc != null) {
                            throw GetRollupReclaimEx();
                        }

                        CompileReclaim(
                            groupDesc,
                            reclaimGroupAged,
                            reclaimGroupFrequency,
                            variableCompileTimeResolver,
                            optionalContextName);
                        serviceForge = new AggregationServiceGroupByForge(groupDesc, importService.TimeAbacus);
                    }
                    else if (groupByRollupDesc != null) {
                        serviceForge = new AggSvcGroupByRollupForge(rowStateDesc, groupByRollupDesc, groupByNodes);
                    }
                    else {
                        groupDesc.IsRefcounted = true;
                        serviceForge = new AggregationServiceGroupByForge(groupDesc, importService.TimeAbacus);
                    }
                }
            }

            return new AggregationServiceForgeDesc(serviceForge, aggregations, groupKeyExpressions, additionalForgeables);
        }
Exemplo n.º 10
0
        public ModuleCompileTimeServices(
            IContainer container,
            CompilerServices compilerServices,
            Configuration configuration,
            ContextCompileTimeRegistry contextCompileTimeRegistry,
            ContextCompileTimeResolver contextCompileTimeResolver,
            BeanEventTypeStemService beanEventTypeStemService,
            BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
            ClassProvidedCompileTimeRegistry classProvidedCompileTimeRegistry,
            ClassProvidedCompileTimeResolver classProvidedCompileTimeResolver,
            DatabaseConfigServiceCompileTime databaseConfigServiceCompileTime,
            ImportServiceCompileTime importService,
            ExprDeclaredCompileTimeRegistry exprDeclaredCompileTimeRegistry,
            ExprDeclaredCompileTimeResolver exprDeclaredCompileTimeResolver,
            EventTypeAvroHandler eventTypeAvroHandler,
            EventTypeCompileTimeRegistry eventTypeCompileTimeRegistry,
            EventTypeCompileTimeResolver eventTypeCompileTimeResolver,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            bool fireAndForget,
            IndexCompileTimeRegistry indexCompileTimeRegistry,
            ModuleDependenciesCompileTime moduleDependencies,
            ModuleAccessModifierService moduleVisibilityRules,
            NamedWindowCompileTimeResolver namedWindowCompileTimeResolver,
            NamedWindowCompileTimeRegistry namedWindowCompileTimeRegistry,
            ParentClassLoader parentClassLoader,
            PatternObjectResolutionService patternObjectResolutionService,
            ScriptCompileTimeRegistry scriptCompileTimeRegistry,
            ScriptCompileTimeResolver scriptCompileTimeResolver,
            ScriptCompiler scriptCompiler,
            SerdeEventTypeCompileTimeRegistry serdeEventTypeRegistry,
            SerdeCompileTimeResolver serdeResolver, 
            TableCompileTimeRegistry tableCompileTimeRegistry,
            TableCompileTimeResolver tableCompileTimeResolver,
            VariableCompileTimeRegistry variableCompileTimeRegistry,
            VariableCompileTimeResolver variableCompileTimeResolver,
            ViewResolutionService viewResolutionService,
            XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
        {
            var generation = Interlocked.Increment(ref _generation);
            
            Namespace = $"generation_{generation}";

            Container = container;
            CompilerServices = compilerServices;
            Configuration = configuration;
            ContextCompileTimeRegistry = contextCompileTimeRegistry;
            ContextCompileTimeResolver = contextCompileTimeResolver;
            BeanEventTypeStemService = beanEventTypeStemService;
            BeanEventTypeFactoryPrivate = beanEventTypeFactoryPrivate;
            DatabaseConfigServiceCompileTime = databaseConfigServiceCompileTime;
            ImportServiceCompileTime = importService;
            ExprDeclaredCompileTimeRegistry = exprDeclaredCompileTimeRegistry;
            ExprDeclaredCompileTimeResolver = exprDeclaredCompileTimeResolver;
            EventTypeAvroHandler = eventTypeAvroHandler;
            EventTypeCompileTimeRegistry = eventTypeCompileTimeRegistry;
            EventTypeCompileTimeResolver = eventTypeCompileTimeResolver;
            EventTypeRepositoryPreconfigured = eventTypeRepositoryPreconfigured;
            IndexCompileTimeRegistry = indexCompileTimeRegistry;
            ModuleDependencies = moduleDependencies;
            ModuleVisibilityRules = moduleVisibilityRules;
            NamedWindowCompileTimeResolver = namedWindowCompileTimeResolver;
            NamedWindowCompileTimeRegistry = namedWindowCompileTimeRegistry;
            ParentClassLoader = parentClassLoader;
            PatternObjectResolutionService = patternObjectResolutionService;
            ScriptCompileTimeRegistry = scriptCompileTimeRegistry;
            ScriptCompileTimeResolver = scriptCompileTimeResolver;
            ScriptCompiler = scriptCompiler;
            TableCompileTimeRegistry = tableCompileTimeRegistry;
            TableCompileTimeResolver = tableCompileTimeResolver;
            VariableCompileTimeRegistry = variableCompileTimeRegistry;
            VariableCompileTimeResolver = variableCompileTimeResolver;
            ViewResolutionService = viewResolutionService;
            XmlFragmentEventTypeFactory = xmlFragmentEventTypeFactory;

            #region ESPER_8.5.1
            ClassProvidedCompileTimeRegistry = classProvidedCompileTimeRegistry;
            ClassProvidedCompileTimeResolver = classProvidedCompileTimeResolver;
            SerdeEventTypeRegistry = serdeEventTypeRegistry;
            SerdeResolver = serdeResolver;
            IsFireAndForget = fireAndForget;
            #endregion
        }
Exemplo n.º 11
0
 public ExprNodeVariableVisitor(VariableCompileTimeResolver variableCompileTimeResolver)
 {
     this.variableCompileTimeResolver = variableCompileTimeResolver;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="rowLimitSpec">specification for row limit, or null if no row limit is defined</param>
        /// <param name="variableCompileTimeResolver">for retrieving variable state for use with row limiting</param>
        /// <param name="optionalContextName">context name</param>
        /// <throws>ExprValidationException exception</throws>
        public RowLimitProcessorFactoryForge(
            RowLimitSpec rowLimitSpec,
            VariableCompileTimeResolver variableCompileTimeResolver,
            string optionalContextName)
        {
            if (rowLimitSpec.NumRowsVariable != null) {
                numRowsVariableMetaData = variableCompileTimeResolver.Resolve(rowLimitSpec.NumRowsVariable);
                if (numRowsVariableMetaData == null) {
                    throw new ExprValidationException(
                        "Limit clause variable by name '" + rowLimitSpec.NumRowsVariable + "' has not been declared");
                }

                string message = VariableUtil.CheckVariableContextName(optionalContextName, numRowsVariableMetaData);
                if (message != null) {
                    throw new ExprValidationException(message);
                }

                if (!TypeHelper.IsNumeric(numRowsVariableMetaData.Type)) {
                    throw new ExprValidationException("Limit clause requires a variable of numeric type");
                }
            }
            else {
                numRowsVariableMetaData = null;
                currentRowLimit = rowLimitSpec.NumRows.GetValueOrDefault(Int32.MaxValue);
                if (currentRowLimit < 0) {
                    currentRowLimit = Int32.MaxValue;
                }
            }

            if (rowLimitSpec.OptionalOffsetVariable != null) {
                offsetVariableMetaData = variableCompileTimeResolver.Resolve(rowLimitSpec.OptionalOffsetVariable);
                if (offsetVariableMetaData == null) {
                    throw new ExprValidationException(
                        "Limit clause variable by name '" +
                        rowLimitSpec.OptionalOffsetVariable +
                        "' has not been declared");
                }

                string message = VariableUtil.CheckVariableContextName(optionalContextName, offsetVariableMetaData);
                if (message != null) {
                    throw new ExprValidationException(message);
                }

                if (!TypeHelper.IsNumeric(offsetVariableMetaData.Type)) {
                    throw new ExprValidationException("Limit clause requires a variable of numeric type");
                }
            }
            else {
                offsetVariableMetaData = null;
                if (rowLimitSpec.OptionalOffset != null) {
                    if (rowLimitSpec.OptionalOffset.Value <= 0) {
                        throw new ExprValidationException("Limit clause requires a positive offset");
                    }

                    currentOffset = rowLimitSpec.OptionalOffset.Value;
                }
                else {
                    currentOffset = 0;
                }
            }
        }
        public static OrderByProcessorFactoryForge GetProcessor(
            IList<SelectClauseExprCompiledSpec> selectionList,
            IList<OrderByItem> orderByList,
            RowLimitSpec rowLimitSpec,
            VariableCompileTimeResolver variableCompileTimeResolver,
            bool isSortUsingCollator,
            string optionalContextName,
            OrderByElementForge[][] orderByRollup)
        {
            // Get the order by expression nodes
            IList<ExprNode> orderByNodes = new List<ExprNode>();
            foreach (var element in orderByList) {
                orderByNodes.Add(element.ExprNode);
            }

            // No order-by clause
            if (orderByList.IsEmpty()) {
                Log.Debug(".getProcessor Using no OrderByProcessor");
                if (rowLimitSpec != null) {
                    var rowLimitProcessorFactory = new RowLimitProcessorFactoryForge(
                        rowLimitSpec,
                        variableCompileTimeResolver,
                        optionalContextName);
                    return new OrderByProcessorRowLimitOnlyForge(rowLimitProcessorFactory);
                }

                return null;
            }

            // Determine aggregate functions used in select, if any
            IList<ExprAggregateNode> selectAggNodes = new List<ExprAggregateNode>();
            foreach (var element in selectionList) {
                ExprAggregateNodeUtil.GetAggregatesBottomUp(element.SelectExpression, selectAggNodes);
            }

            // Get all the aggregate functions occuring in the order-by clause
            IList<ExprAggregateNode> orderAggNodes = new List<ExprAggregateNode>();
            foreach (var orderByNode in orderByNodes) {
                ExprAggregateNodeUtil.GetAggregatesBottomUp(orderByNode, orderAggNodes);
            }

            ValidateOrderByAggregates(selectAggNodes, orderAggNodes);

            // Tell the order-by processor whether to compute group-by
            // keys if they are not present
            var needsGroupByKeys = !selectionList.IsEmpty() && !orderAggNodes.IsEmpty();

            Log.Debug(".getProcessor Using OrderByProcessorImpl");
            var elements = ToElementArray(orderByList);
            var comparator = GetComparator(elements, isSortUsingCollator);
            var orderByProcessorForge = new OrderByProcessorForgeImpl(
                elements,
                needsGroupByKeys,
                orderByRollup,
                comparator);
            if (rowLimitSpec == null) {
                return orderByProcessorForge;
            }

            {
                var rowLimitProcessorFactory = new RowLimitProcessorFactoryForge(
                    rowLimitSpec,
                    variableCompileTimeResolver,
                    optionalContextName);
                return new OrderByProcessorOrderedLimitForge(orderByProcessorForge, rowLimitProcessorFactory);
            }
        }
Exemplo n.º 14
0
 public ModuleCompileTimeServices(
     IContainer container,
     CompilerServices compilerServices,
     Configuration configuration,
     ContextCompileTimeRegistry contextCompileTimeRegistry,
     ContextCompileTimeResolver contextCompileTimeResolver,
     BeanEventTypeStemService beanEventTypeStemService,
     BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
     DatabaseConfigServiceCompileTime databaseConfigServiceCompileTime,
     ImportServiceCompileTime importService,
     ExprDeclaredCompileTimeRegistry exprDeclaredCompileTimeRegistry,
     ExprDeclaredCompileTimeResolver exprDeclaredCompileTimeResolver,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventTypeCompileTimeRegistry eventTypeCompileTimeRegistry,
     EventTypeCompileTimeResolver eventTypeCompileTimeResolver,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     IndexCompileTimeRegistry indexCompileTimeRegistry,
     ModuleDependenciesCompileTime moduleDependencies,
     ModuleAccessModifierService moduleVisibilityRules,
     NamedWindowCompileTimeResolver namedWindowCompileTimeResolver,
     NamedWindowCompileTimeRegistry namedWindowCompileTimeRegistry,
     PatternObjectResolutionService patternObjectResolutionService,
     ScriptCompileTimeRegistry scriptCompileTimeRegistry,
     ScriptCompileTimeResolver scriptCompileTimeResolver,
     ScriptServiceCompileTime scriptServiceCompileTime,
     TableCompileTimeRegistry tableCompileTimeRegistry,
     TableCompileTimeResolver tableCompileTimeResolver,
     VariableCompileTimeRegistry variableCompileTimeRegistry,
     VariableCompileTimeResolver variableCompileTimeResolver,
     ViewResolutionService viewResolutionService,
     XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
 {
     Container = container;
     CompilerServices = compilerServices;
     Configuration = configuration;
     ContextCompileTimeRegistry = contextCompileTimeRegistry;
     ContextCompileTimeResolver = contextCompileTimeResolver;
     BeanEventTypeStemService = beanEventTypeStemService;
     BeanEventTypeFactoryPrivate = beanEventTypeFactoryPrivate;
     DatabaseConfigServiceCompileTime = databaseConfigServiceCompileTime;
     ImportServiceCompileTime = importService;
     ExprDeclaredCompileTimeRegistry = exprDeclaredCompileTimeRegistry;
     ExprDeclaredCompileTimeResolver = exprDeclaredCompileTimeResolver;
     EventTypeAvroHandler = eventTypeAvroHandler;
     EventTypeCompileTimeRegistry = eventTypeCompileTimeRegistry;
     EventTypeCompileTimeResolver = eventTypeCompileTimeResolver;
     EventTypeRepositoryPreconfigured = eventTypeRepositoryPreconfigured;
     IndexCompileTimeRegistry = indexCompileTimeRegistry;
     ModuleDependencies = moduleDependencies;
     ModuleVisibilityRules = moduleVisibilityRules;
     NamedWindowCompileTimeResolver = namedWindowCompileTimeResolver;
     NamedWindowCompileTimeRegistry = namedWindowCompileTimeRegistry;
     PatternObjectResolutionService = patternObjectResolutionService;
     ScriptServiceCompileTime = scriptServiceCompileTime;
     ScriptCompileTimeRegistry = scriptCompileTimeRegistry;
     ScriptCompileTimeResolver = scriptCompileTimeResolver;
     TableCompileTimeRegistry = tableCompileTimeRegistry;
     TableCompileTimeResolver = tableCompileTimeResolver;
     VariableCompileTimeRegistry = variableCompileTimeRegistry;
     VariableCompileTimeResolver = variableCompileTimeResolver;
     ViewResolutionService = viewResolutionService;
     XmlFragmentEventTypeFactory = xmlFragmentEventTypeFactory;
 }