Ejemplo n.º 1
0
        public CodegenExpression MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(ViewableActivator), typeof(ViewableActivatorPatternForge), classScope);

            var childCode = _spec.Root.MakeCodegen(method, symbols, classScope);
            method.Block
                .DeclareVar<EvalRootFactoryNode>("root", LocalMethod(childCode))
                .DeclareVar<ViewableActivatorPattern>(
                    "activator",
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.VIEWABLEACTIVATORFACTORY)
                        .Add("CreatePattern"))
                .SetProperty(Ref("activator"), "RootFactoryNode", Ref("root"))
                .SetProperty(
                    Ref("activator"),
                    "EventBeanTypedEventFactory",
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.EVENTBEANTYPEDEVENTFACTORY))
                .DeclareVar<EventType>(
                    "eventType",
                    EventTypeUtility.ResolveTypeCodegen(_eventType, symbols.GetAddInitSvc(method)))
                .SetProperty(Ref("activator"), "EventType", Ref("eventType"))
                .SetProperty(Ref("activator"), "PatternContext", _patternContext.Make(method, symbols, classScope))
                .SetProperty(Ref("activator"), "HasConsumingFilter", Constant(_spec.IsConsumingFilters))
                .SetProperty(Ref("activator"), "SuppressSameEventMatches", Constant(_spec.IsSuppressSameEventMatches))
                .SetProperty(Ref("activator"), "DiscardPartialsOnMatch", Constant(_spec.IsDiscardPartialsOnMatch))
                .SetProperty(Ref("activator"), "CanIterate", Constant(_isCanIterate))
                .MethodReturn(Ref("activator"));

            return LocalMethod(method);
        }
        public override void InlineInitializeOnTriggerBase(
            CodegenExpressionRef saiff,
            CodegenMethod method,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            method.Block
                .SetProperty(
                    saiff,
                    "NamedWindow",
                    namedWindow == null
                        ? ConstantNull()
                        : NamedWindowDeployTimeResolver.MakeResolveNamedWindow(
                            namedWindow,
                            symbols.GetAddInitSvc(method)))
                .SetProperty(
                    saiff,
                    "Table",
                    table == null
                        ? ConstantNull()
                        : TableDeployTimeResolver.MakeResolveTable(table, symbols.GetAddInitSvc(method)))
                .SetProperty(saiff, "QueryPlan", queryPlanForge.Make(method, symbols, classScope))
                .SetProperty(
                    saiff,
                    "NonSelectRSPFactoryProvider",
                    nonSelectRSPProviderClassName == null
                        ? ConstantNull()
                        : NewInstanceInner(nonSelectRSPProviderClassName, symbols.GetAddInitSvc(method), Ref("statementFields")))
                .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", saiff); // add ready-callback

            InlineInitializeOnTriggerSpecific(saiff, method, symbols, classScope);
        }
Ejemplo n.º 3
0
        public CodegenMethod InitializeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(StatementAgentInstanceFactoryCreateVariable), GetType(), classScope);
            method.Block
                .DeclareVar<StatementAgentInstanceFactoryCreateVariable>(
                    "saiff",
                    NewInstance(typeof(StatementAgentInstanceFactoryCreateVariable)))
                .SetProperty(
                    Ref("saiff"), "VariableName", Constant(variableName))
                .SetProperty(
                    Ref("saiff"),
                    "ResultSetProcessorFactoryProvider",
                    NewInstanceInner(resultSetProcessorProviderClassName, symbols.GetAddInitSvc(method), Ref("statementFields")));

            if (optionalInitialValue != null) {
                method.Block
                    .SetProperty(
                        Ref("saiff"),
                        "VariableInitialValueExpr",
                        ExprNodeUtilityCodegen.CodegenEvaluator(optionalInitialValue, method, GetType(), classScope))
                    .Expression(
                        ExprDotMethodChain(symbols.GetAddInitSvc(method)).Add("AddReadyCallback", Ref("saiff")));
            }

            method.Block.MethodReturn(Ref("saiff"));
            return method;
        }
Ejemplo n.º 4
0
        public override CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(InfraOnMergeActionUpd), this.GetType(), classScope);
            if (_table == null) {
                method.Block.MethodReturn(
                    NewInstance<InfraOnMergeActionUpd>(
                        MakeFilter(method, classScope),
                        _updateHelper.MakeWCopy(method, classScope)));
            }
            else {
                method.Block
                    .DeclareVar<InfraOnMergeActionUpd>(
                        "upd",
                        NewInstance<InfraOnMergeActionUpd>(
                            MakeFilter(method, classScope),
                            _updateHelper.MakeNoCopy(method, classScope),
                            TableDeployTimeResolver.MakeResolveTable(_table, symbols.GetAddInitSvc(method))))
                    .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", Ref("upd"))
                    .MethodReturn(Ref("upd"));
            }

            return LocalMethod(method);
        }
Ejemplo n.º 5
0
        public CodegenMethod InitializeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenMethod method = parent.MakeChild(
                typeof(StatementAgentInstanceFactoryCreateNW),
                this.GetType(),
                classScope);
            method.Block
                .DeclareVar<StatementAgentInstanceFactoryCreateNW>(
                    "saiff",
                    NewInstance(typeof(StatementAgentInstanceFactoryCreateNW)));

            method.Block
                .SetProperty(Ref("saiff"), "Activator", activator.MakeCodegen(method, symbols, classScope))
                .SetProperty(Ref("saiff"), "NamedWindowName", Constant(namedWindowName))
                .SetProperty(
                    Ref("saiff"),
                    "ViewFactories",
                    ViewFactoryForgeUtil.CodegenForgesWInit(views, 0, null, method, symbols, classScope))
                .SetProperty(
                    Ref("saiff"),
                    "InsertFromNamedWindow",
                    insertFromNamedWindow == null
                        ? ConstantNull()
                        : NamedWindowDeployTimeResolver.MakeResolveNamedWindow(
                            insertFromNamedWindow,
                            symbols.GetAddInitSvc(method)))
                .SetProperty(
                    Ref("saiff"),
                    "InsertFromFilter",
                    insertFromFilter == null
                        ? ConstantNull()
                        : ExprNodeUtilityCodegen.CodegenEvaluator(
                            insertFromFilter.Forge,
                            method,
                            this.GetType(),
                            classScope))
                .SetProperty(
                    Ref("saiff"),
                    "AsEventType",
                    asEventType == null
                        ? ConstantNull()
                        : EventTypeUtility.ResolveTypeCodegen(asEventType, EPStatementInitServicesConstants.REF))
                .SetProperty(
                    Ref("saiff"),
                    "ResultSetProcessorFactoryProvider",
                    NewInstance(
                        resultSetProcessorProviderClassName,
                        symbols.GetAddInitSvc(method),
                        Ref("statementFields")))
                .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", Ref("saiff"));

            method.Block.MethodReturn(Ref("saiff"));
            return method;
        }
        public CodegenMethod InitializeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            // add aggregation row+factory+serde as inner classes
            var aggregationClassNames = new AggregationClassNames();
            var inners = AggregationServiceFactoryCompiler.MakeTable(
                AggregationCodegenRowLevelDesc.FromTopOnly(_plan.AggDesc),
                GetType(),
                classScope,
                aggregationClassNames,
                _className);
            classScope.AddInnerClasses(inners);

            var method = parent.MakeChild(typeof(StatementAgentInstanceFactoryCreateTable), GetType(), classScope);

            CodegenExpression primaryKeyGetter = MultiKeyCodegen.CodegenGetterMayMultiKey(
                _plan.InternalEventType, 
                _plan.PrimaryKeyGetters,
                _plan.PrimaryKeyTypes,
                null,
                _plan.PrimaryKeyMultikeyClasses,
                method,
                classScope);
            CodegenExpression fafTransform = MultiKeyCodegen.CodegenMultiKeyFromArrayTransform(
                _plan.PrimaryKeyMultikeyClasses,
                method,
                classScope);
            CodegenExpression intoTableTransform = MultiKeyCodegen.CodegenMultiKeyFromMultiKeyTransform(
                _plan.PrimaryKeyMultikeyClasses,
                method,
                classScope);

            var propertyForgeEval = DataInputOutputSerdeForgeExtensions.CodegenArray(
                _plan.InternalEventTypePropertySerdes,
                method,
                classScope,
                ExprDotName(symbols.GetAddInitSvc(method), EPStatementInitServicesConstants.EVENTTYPERESOLVER));
            
            method.Block
                .DeclareVar<StatementAgentInstanceFactoryCreateTable>("saiff", NewInstance(typeof(StatementAgentInstanceFactoryCreateTable)))
                .SetProperty(Ref("saiff"), "TableName", Constant(_tableName))
                .SetProperty(Ref("saiff"), "PublicEventType", EventTypeUtility.ResolveTypeCodegen(_plan.PublicEventType, symbols.GetAddInitSvc(method)))
                .SetProperty(Ref("saiff"), "EventToPublic", MakeEventToPublic(method, symbols, classScope))
                .SetProperty(Ref("saiff"), "AggregationRowFactory", NewInstanceInner(aggregationClassNames.RowFactoryTop, Ref("this")))
                .SetProperty(Ref("saiff"), "AggregationSerde", NewInstanceInner(aggregationClassNames.RowSerdeTop, Ref("this")))
                .SetProperty(Ref("saiff"), "PrimaryKeyGetter", primaryKeyGetter)
                .SetProperty(Ref("saiff"), "PrimaryKeySerde", _plan.PrimaryKeyMultikeyClasses.GetExprMKSerde(method, classScope))
                .SetProperty(Ref("saiff"), "PropertyForges", propertyForgeEval)
                .SetProperty(Ref("saiff"), "PrimaryKeyObjectArrayTransform", fafTransform)
                .SetProperty(Ref("saiff"), "PrimaryKeyIntoTableTransform", intoTableTransform)

                .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", Ref("saiff"))
                .MethodReturn(Ref("saiff"));
            return method;
        }
Ejemplo n.º 7
0
        public CodegenMethod InitializeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            // add aggregation row+factory+serde as inner classes
            var aggregationClassNames = new AggregationClassNames();
            var inners = AggregationServiceFactoryCompiler.MakeTable(
                AggregationCodegenRowLevelDesc.FromTopOnly(plan.AggDesc),
                GetType(),
                classScope,
                aggregationClassNames,
                className);
            classScope.AddInnerClasses(inners);

            var method = parent.MakeChild(typeof(StatementAgentInstanceFactoryCreateTable), GetType(), classScope);

            var primaryKeyGetter = ConstantNull();
            if (plan.PrimaryKeyGetters != null) {
                primaryKeyGetter = EventTypeUtility.CodegenGetterMayMultiKeyWCoerce(
                    plan.InternalEventType,
                    plan.PrimaryKeyGetters,
                    plan.PrimaryKeyTypes,
                    null,
                    method,
                    GetType(),
                    classScope);
            }

            method.Block
                .DeclareVar<StatementAgentInstanceFactoryCreateTable>(
                    "saiff",
                    NewInstance(typeof(StatementAgentInstanceFactoryCreateTable)))
                .SetProperty(Ref("saiff"), "TableName", Constant(tableName))
                .SetProperty(
                    Ref("saiff"),
                    "PublicEventType",
                    EventTypeUtility.ResolveTypeCodegen(plan.PublicEventType, symbols.GetAddInitSvc(method)))
                .SetProperty(Ref("saiff"), "EventToPublic", MakeEventToPublic(method, symbols, classScope))
                .SetProperty(
                    Ref("saiff"),
                    "AggregationRowFactory",
                    NewInstance(aggregationClassNames.RowFactoryTop, Ref("this")))
                .SetProperty(
                    Ref("saiff"),
                    "AggregationSerde",
                    NewInstance(aggregationClassNames.RowSerdeTop, Ref("this")))
                .SetProperty(Ref("saiff"), "PrimaryKeyGetter", primaryKeyGetter)
                .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", Ref("saiff"))
                .MethodReturn(Ref("saiff"));
            return method;
        }
Ejemplo n.º 8
0
        public CodegenExpression MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (spec.NamedWindowConsumerId == -1) {
                throw new IllegalStateException("Unassigned named window consumer id");
            }

            var method = parent.MakeChild(typeof(ViewableActivatorNamedWindow), GetType(), classScope);

            CodegenExpression filter;
            if (filterEvaluator == null) {
                filter = ConstantNull();
            }
            else {
                filter = ExprNodeUtilityCodegen.CodegenEvaluator(filterEvaluator.Forge, method, GetType(), classScope);
            }

            method.Block
                .DeclareVar<ViewableActivatorNamedWindow>(
                    "activator",
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.VIEWABLEACTIVATORFACTORY)
                        .Add("CreateNamedWindow"))
                .SetProperty(
                    Ref("activator"),
                    "NamedWindow",
                    NamedWindowDeployTimeResolver.MakeResolveNamedWindow(namedWindow, symbols.GetAddInitSvc(method)))
                .SetProperty(Ref("activator"), "NamedWindowConsumerId", Constant(spec.NamedWindowConsumerId))
                .SetProperty(Ref("activator"), "FilterEvaluator", filter)
                .SetProperty(
                    Ref("activator"),
                    "FilterQueryGraph",
                    filterQueryGraph == null ? ConstantNull() : filterQueryGraph.Make(method, symbols, classScope))
                .SetProperty(Ref("activator"), "Subquery", Constant(subquery))
                .SetProperty(
                    Ref("activator"),
                    "OptPropertyEvaluator",
                    optPropertyEvaluator == null
                        ? ConstantNull()
                        : optPropertyEvaluator.Make(method, symbols, classScope))
                .ExprDotMethod(
                    symbols.GetAddInitSvc(method),
                    "AddReadyCallback",
                    Ref("activator")) // add ready-callback
                .MethodReturn(Ref("activator"));
            return LocalMethod(method);
        }
 public override CodegenMethod MakeCodegen(
     CodegenClassScope classScope,
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols)
 {
     var method = parent.MakeChild(
         typeof(ContextControllerCategoryFactory),
         typeof(ContextControllerCategoryFactoryForge),
         classScope);
     method.Block
         .DeclareVar<ContextControllerCategoryFactory>(
             "factory",
             ExprDotMethodChain(symbols.GetAddInitSvc(method))
                 .Get(EPStatementInitServicesConstants.CONTEXTSERVICEFACTORY)
                 .Add("CategoryFactory"))
         .SetProperty(
             Ref("factory"),
             "ContextName",
             Constant(Context.ContextName))
         .SetProperty(
             Ref("factory"),
             "CategorySpec",
             detail.MakeCodegen(method, symbols, classScope))
         .MethodReturn(Ref("factory"));
     
     return method;
 }
Ejemplo n.º 10
0
        private static CodegenExpression MakeCopyMethods(
            IDictionary <EventTypeSPI, EventBeanCopyMethodForge> copyMethods,
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (copyMethods.IsEmpty())
            {
                return(EnumValue(typeof(EmptyDictionary <EventTypeSPI, EventBeanCopyMethod>), "Instance"));
            }

            var method = parent.MakeChild(
                typeof(IDictionary <EventTypeSPI, EventBeanCopyMethod>),
                typeof(VariableReadWritePackageForge),
                classScope);

            method.Block.DeclareVar <IDictionary <EventTypeSPI, EventBeanCopyMethod> >(
                "methods",
                NewInstance <Dictionary <EventTypeSPI, EventBeanCopyMethod> >(Constant(copyMethods.Count)));
            foreach (var entry in copyMethods)
            {
                var type       = EventTypeUtility.ResolveTypeCodegen(entry.Key, symbols.GetAddInitSvc(method));
                var copyMethod = entry.Value.MakeCopyMethodClassScoped(classScope);
                method.Block.ExprDotMethod(Ref("methods"), "Put", type, copyMethod);
            }

            method.Block.MethodReturn(Ref("methods"));
            return(LocalMethod(method));
        }
Ejemplo n.º 11
0
        private static CodegenExpression MakeReadersForGlobalVars(
            VariableMetaData[] variables,
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(VariableReader[]), typeof(VariableReadWritePackageForge), classScope);

            method.Block.DeclareVar <VariableReader[]>("readers", NewArrayByLength(typeof(VariableReader), Constant(variables.Length)));
            for (var i = 0; i < variables.Length; i++)
            {
                if (variables[i].OptionalContextName == null)
                {
                    var resolve = StaticMethod(
                        typeof(VariableDeployTimeResolver),
                        "ResolveVariableReader",
                        Constant(variables[i].VariableName),
                        Constant(variables[i].VariableVisibility),
                        Constant(variables[i].VariableModuleName),
                        ConstantNull(),
                        symbols.GetAddInitSvc(method));
                    method.Block.AssignArrayElement("readers", Constant(i), resolve);
                }
            }

            method.Block.MethodReturn(Ref("readers"));
            return(LocalMethod(method));
        }
Ejemplo n.º 12
0
        public CodegenExpression MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (scheduleCallbackId == -1) {
                throw new IllegalStateException("Unassigned schedule callback id");
            }

            var method = parent.MakeChild(
                typeof(TimerScheduleObserverFactory),
                typeof(TimerIntervalObserverForge),
                classScope);

            method.Block
                .DeclareVar<TimerScheduleObserverFactory>(
                    "factory",
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.PATTERNFACTORYSERVICE)
                        .Add("ObserverTimerSchedule"))
                .SetProperty(Ref("factory"), "ScheduleCallbackId", Constant(scheduleCallbackId))
                .SetProperty(Ref("factory"), "IsAllConstant", Constant(allConstantResult))
                .SetProperty(Ref("factory"), "ScheduleComputer", scheduleComputer.Make(method, classScope))
                .SetProperty(
                    Ref("factory"),
                    "OptionalConvertor",
                    convertor == null ? null : convertor.MakeAnonymous(method, classScope))
                .MethodReturn(Ref("factory"));
            return LocalMethod(method);
        }
Ejemplo n.º 13
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var builder = new SAIFFInitializeBuilder(
                OP_PACKAGE_NAME + ".select.SelectFactory",
                GetType(),
                "select",
                parent,
                symbols,
                classScope);

            return builder
                .EventtypesMayNull(
                    "EventTypes",
                    eventTypes)
                .Constant(
                    "IsSubmitEventBean",
                    submitEventBean)
                .Constant(
                    "IsIterate",
                    iterate)
                .Constant(
                    "OriginatingStreamToViewableStream",
                    originatingStreamToViewableStream)
                .Expression(
                    "FactoryProvider",
                    NewInstance(
                        classNameAIFactoryProvider,
                        symbols.GetAddInitSvc(builder.Method()),
                        NewInstance(classNameFieldsFactoryProvider)
                        ))
                .Build();
        }
Ejemplo n.º 14
0
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(PropertyEvaluatorNested), GetType(), classScope);
     method.Block
         .DeclareVar<PropertyEvaluatorNested>("pe", NewInstance(typeof(PropertyEvaluatorNested)))
         .SetProperty(
             Ref("pe"),
             "ResultEventType",
             EventTypeUtility.ResolveTypeCodegen(
                 fragmentEventTypes[fragmentEventTypes.Length - 1].FragmentType,
                 symbols.GetAddInitSvc(method)))
         .SetProperty(Ref("pe"), "ExpressionTexts", Constant(expressionTexts))
         .SetProperty(
             Ref("pe"),
             "WhereClauses",
             PropertyEvaluatorAccumulativeForge.MakeWhere(whereClauses, method, symbols, classScope))
         .SetProperty(
             Ref("pe"),
             "ContainedEventEvals",
             PropertyEvaluatorAccumulativeForge.MakeContained(containedEventEvals, method, symbols, classScope))
         .SetProperty(Ref("pe"), "FragmentEventTypeIsIndexed", Constant(fragmentEventTypesIsIndexed))
         .MethodReturn(Ref("pe"));
     return LocalMethod(method);
 }
Ejemplo n.º 15
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (scheduleCallbackId == -1) {
                throw new IllegalStateException("Unassigned schedule");
            }

            var method = parent.MakeChild(typeof(OutputConditionFactory), GetType(), classScope);
            method.Block.DeclareVar<ExprEvaluator[]>(
                "evals",
                NewArrayByLength(typeof(ExprEvaluator), Constant(scheduleSpecEvaluators.Length)));
            for (var i = 0; i < scheduleSpecEvaluators.Length; i++) {
                method.Block.AssignArrayElement(
                    "evals",
                    Constant(i),
                    ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(
                        scheduleSpecEvaluators[i],
                        method,
                        GetType(),
                        classScope));
            }

            method.Block.MethodReturn(
                ExprDotMethodChain(symbols.GetAddInitSvc(method))
                    .Get(EPStatementInitServicesConstants.RESULTSETPROCESSORHELPERFACTORY)
                    .Add(
                        "MakeOutputConditionCrontab",
                        Ref("evals"),
                        Constant(isStartConditionOnCreation),
                        Constant(scheduleCallbackId)));
            return LocalMethod(method);
        }
Ejemplo n.º 16
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (scheduleCallbackId == -1) {
                throw new IllegalStateException("Unassigned callback id");
            }

            CodegenMethod method = parent.MakeChild(typeof(OutputConditionFactory), this.GetType(), classScope);
            method.Block
                .DeclareVar<TimePeriodCompute>(
                    "delta",
                    timePeriod.TimePeriodComputeForge.MakeEvaluator(method, classScope))
                .MethodReturn(
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.RESULTSETPROCESSORHELPERFACTORY)
                        .Add(
                            "MakeOutputConditionTime",
                            Constant(timePeriod.HasVariable),
                            Ref("delta"),
                            Constant(isStartConditionOnCreation),
                            Constant(scheduleCallbackId)));
            return LocalMethod(method);
        }
Ejemplo n.º 17
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenMethod method = parent.MakeChild(Implementation(), this.GetType(), classScope);

            method.Block
                .DeclareVar(Implementation(), "impl", NewInstance(Implementation()))
                .SetProperty(
                    Ref("impl"),
                    "StreamTypes",
                    EventTypeUtility.ResolveTypeArrayCodegen(streamTypes, symbols.GetAddInitSvc(method)))
                .SetProperty(Ref("impl"), "OuterJoins", Constant(outerJoins));

            if (postJoinEvaluator != null) {
                method.Block.SetProperty(
                    Ref("impl"),
                    "PostJoinFilterEvaluator",
                    ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(
                        postJoinEvaluator.Forge,
                        method,
                        this.GetType(),
                        classScope));
            }

            PopulateInline(Ref("impl"), method, symbols, classScope);

            method.Block.MethodReturn(Ref("impl"));

            return LocalMethod(method);
        }
Ejemplo n.º 18
0
 protected override void MakeInlineSpecificSetter(
     CodegenExpressionRef queryMethod,
     CodegenMethod method,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     method.Block.SetProperty(
         queryMethod,
         "OptionalWhereClause",
         whereClause == null
             ? ConstantNull()
             : ExprNodeUtilityCodegen.CodegenEvaluator(whereClause.Forge, method, this.GetType(), classScope));
     if (processor is FireAndForgetProcessorNamedWindowForge) {
         method.Block.SetProperty(
             queryMethod,
             "UpdateHelperNamedWindow",
             updateHelper.MakeWCopy(method, classScope));
     }
     else {
         FireAndForgetProcessorTableForge table = (FireAndForgetProcessorTableForge) processor;
         method.Block
             .SetProperty(queryMethod, "UpdateHelperTable", updateHelper.MakeNoCopy(method, classScope))
             .SetProperty(
                 queryMethod,
                 "Table",
                 TableDeployTimeResolver.MakeResolveTable(table.Table, symbols.GetAddInitSvc(method)));
     }
 }
        internal static CodegenExpression MakeAggregationService(
            int subqueryNumber,
            AggregationServiceForgeDesc aggregationServiceForgeDesc,
            CodegenClassScope classScope,
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols)
        {
            if (aggregationServiceForgeDesc == null)
            {
                return(ConstantNull());
            }

            AggregationClassNames aggregationClassNames =
                new AggregationClassNames(CodegenNamespaceScopeNames.ClassPostfixAggregationForSubquery(subqueryNumber));
            AggregationServiceFactoryMakeResult aggResult = AggregationServiceFactoryCompiler.MakeInnerClassesAndInit(
                false,
                aggregationServiceForgeDesc.AggregationServiceFactoryForge,
                parent,
                classScope,
                classScope.OutermostClassName,
                aggregationClassNames);

            classScope.AddInnerClasses(aggResult.InnerClasses);
            return(LocalMethod(aggResult.InitMethod, symbols.GetAddInitSvc(parent)));
        }
Ejemplo n.º 20
0
        public static CodegenExpression CodegenForgesWInit(
            IList<ViewFactoryForge> forges,
            int streamNum,
            int? subqueryNum,
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(ViewFactory[]), typeof(ViewFactoryForgeUtil), classScope);
            method.Block
                .DeclareVar<ViewFactory[]>(
                    "factories",
                    NewArrayByLength(typeof(ViewFactory), Constant(forges.Count)));

            var grouped = !forges.IsEmpty() && forges[0] is GroupByViewFactoryForge;
            method.Block.DeclareVar<ViewFactoryContext>("ctx", NewInstance(typeof(ViewFactoryContext)))
                .SetProperty(Ref("ctx"), "StreamNum", Constant(streamNum))
                .SetProperty(Ref("ctx"), "SubqueryNumber", Constant(subqueryNum))
                .SetProperty(Ref("ctx"), "IsGrouped", Constant(grouped));
            for (var i = 0; i < forges.Count; i++) {
                var @ref = "factory_" + i;
                method.Block.DeclareVar<ViewFactory>(@ref, forges[i].Make(method, symbols, classScope))
                    .ExprDotMethod(Ref(@ref), "Init", Ref("ctx"), symbols.GetAddInitSvc(method))
                    .AssignArrayElement(Ref("factories"), Constant(i), Ref(@ref));
            }

            method.Block.MethodReturn(Ref("factories"));
            return LocalMethod(method);
        }
Ejemplo n.º 21
0
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(InternalEventRouterDesc), GetType(), classScope);
     var eventTypeExpr = EventTypeUtility.ResolveTypeCodegen(eventType, symbols.GetAddInitSvc(method));
     var optionalWhereClauseExpr = optionalWhereClause == null
         ? ConstantNull()
         : ExprNodeUtilityCodegen.CodegenEvaluator(
             optionalWhereClause.Forge,
             method,
             GetType(),
             classScope);
     var assignmentsExpr = ExprNodeUtilityCodegen.CodegenEvaluators(assignments, method, GetType(), classScope);
     var writersExpr = MakeWriters(writers, method, symbols, classScope);
     
     method.Block
         .DeclareVar<InternalEventRouterDesc>("ire", NewInstance(typeof(InternalEventRouterDesc)))
         .SetProperty(Ref("ire"), "Wideners", MakeWideners(wideners, method, classScope))
         .SetProperty(Ref("ire"), "EventType", eventTypeExpr)
         .SetProperty(Ref("ire"), "OptionalWhereClauseEval", optionalWhereClauseExpr)
         .SetProperty(Ref("ire"), "Properties", Constant(properties))
         .SetProperty(Ref("ire"), "Assignments", assignmentsExpr)
         .SetProperty(Ref("ire"), "Writers", writersExpr)
         .MethodReturn(Ref("ire"));
     return LocalMethod(method);
 }
Ejemplo n.º 22
0
        public CodegenExpression MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            if (scheduleCallbackId == -1) {
                throw new IllegalStateException("Unassigned schedule callback id");
            }

            var method = parent.MakeChild(typeof(TimerWithinGuardFactory), GetType(), classScope);
            var patternDelta = PatternDeltaComputeUtil.MakePatternDeltaLambda(
                timeExpr,
                convertor,
                timeAbacus,
                method,
                classScope);

            method.Block
                .DeclareVar<TimerWithinGuardFactory>(
                    "factory",
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.PATTERNFACTORYSERVICE)
                        .Add("GuardTimerWithin"))
                .SetProperty(Ref("factory"), "ScheduleCallbackId", Constant(scheduleCallbackId))
                .SetProperty(Ref("factory"), "DeltaCompute", patternDelta)
                .MethodReturn(Ref("factory"));
            return LocalMethod(method);
        }
Ejemplo n.º 23
0
 public CodegenMethod InitializeCodegen(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(TypeOfSubclass(), GetType(), classScope);
     method.Block
         .DeclareVar(TypeOfSubclass(), "saiff", NewInstance(TypeOfSubclass()))
         .SetProperty(Ref("saiff"), "Activator", activator.MakeCodegen(method, symbols, classScope))
         .SetProperty(
             Ref("saiff"),
             "ResultEventType",
             EventTypeUtility.ResolveTypeCodegen(resultEventType, symbols.GetAddInitSvc(method)))
         .SetProperty(
             Ref("saiff"),
             "Subselects",
             SubSelectFactoryForge.CodegenInitMap(subselects, GetType(), method, symbols, classScope))
         .SetProperty(
             Ref("saiff"),
             "TableAccesses",
             ExprTableEvalStrategyUtil.CodegenInitMap(tableAccesses, GetType(), method, symbols, classScope));
     InlineInitializeOnTriggerBase(Ref("saiff"), method, symbols, classScope);
     method.Block.MethodReturn(Ref("saiff"));
     return method;
 }
Ejemplo n.º 24
0
 public CodegenExpression MakeProvider(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     CodegenMethod method = parent.MakeChild(typeof(AggregationServiceFactoryTable), this.GetType(), classScope);
     method.Block
         .DeclareVar<AggregationServiceFactoryTable>(
             "factory",
             NewInstance(typeof(AggregationServiceFactoryTable)))
         .SetProperty(
             Ref("factory"),
             "Table",
             TableDeployTimeResolver.MakeResolveTable(metadata, symbols.GetAddInitSvc(method)))
         .SetProperty(
             Ref("factory"),
             "MethodPairs",
             TableColumnMethodPairForge.MakeArray(methodPairs, method, symbols, classScope))
         .SetProperty(Ref("factory"), "AccessColumnsZeroOffset", Constant(accessColumnsZeroOffset))
         .SetProperty(
             Ref("factory"),
             "AccessAgents",
             AggregationAgentUtil.MakeArray(accessAgents, method, symbols, classScope))
         .SetProperty(
             Ref("factory"),
             "GroupByRollupDesc",
             groupByRollupDesc == null ? ConstantNull() : groupByRollupDesc.Codegen(method, classScope))
         .MethodReturn(Ref("factory"));
     return LocalMethod(method);
 }
Ejemplo n.º 25
0
 public CodegenExpression MakeCodegen(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(ViewableActivatorTable), GetType(), classScope);
     method.Block
         .DeclareVar<ViewableActivatorTable>("va", NewInstance(typeof(ViewableActivatorTable)))
         .SetProperty(
             Ref("va"),
             "Table",
             TableDeployTimeResolver.MakeResolveTable(table, symbols.GetAddInitSvc(method)))
         .SetProperty(
             Ref("va"),
             "FilterEval",
             optionalFilterExpression == null
                 ? ConstantNull()
                 : ExprNodeUtilityCodegen.CodegenEvaluator(
                     optionalFilterExpression.Forge,
                     method,
                     GetType(),
                     classScope))
         .MethodReturn(Ref("va"));
     return LocalMethod(method);
 }
Ejemplo n.º 26
0
 public CodegenMethod InitializeCodegen(
     CodegenClassScope classScope,
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols)
 {
     var method = parent.MakeChild(typeof(StatementAgentInstanceFactoryCreateContext), GetType(), classScope);
     method.Block
         .DeclareVar<StatementAgentInstanceFactoryCreateContext>(
             "saiff",
             NewInstance(typeof(StatementAgentInstanceFactoryCreateContext)))
         .SetProperty(Ref("saiff"), "ContextName", Constant(contextName))
         .SetProperty(
             Ref("saiff"),
             "StatementEventType",
             EventTypeUtility.ResolveTypeCodegen(statementEventType, symbols.GetAddInitSvc(method)))
         .ExprDotMethod(symbols.GetAddInitSvc(method), "AddReadyCallback", Ref("saiff"))
         .MethodReturn(Ref("saiff"));
     return method;
 }
Ejemplo n.º 27
0
 public CodegenMethod InitializeCodegen(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(StatementAgentInstanceFactoryCreateDataflow), GetType(), classScope);
     method.Block
         .DeclareVar<StatementAgentInstanceFactoryCreateDataflow>(
             "saiff",
             NewInstance(typeof(StatementAgentInstanceFactoryCreateDataflow)))
         .SetProperty(
             Ref("saiff"),
             "EventType",
             EventTypeUtility.ResolveTypeCodegen(eventType, symbols.GetAddInitSvc(method)))
         .SetProperty(Ref("saiff"), "Dataflow", dataflowForge.Make(method, symbols, classScope))
         .Expression(ExprDotMethodChain(symbols.GetAddInitSvc(method)).Add("AddReadyCallback", Ref("saiff")))
         .MethodReturn(Ref("saiff"));
     return method;
 }
Ejemplo n.º 28
0
        public CodegenExpression MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(ContextControllerDetailHashItem), GetType(), classScope);
            method.Block.DeclareVar<EventType>(
                "eventType",
                EventTypeUtility.ResolveTypeCodegen(
                    FilterSpecCompiled.FilterForEventType,
                    symbols.GetAddInitSvc(method)));

            var symbolsWithType = new SAIFFInitializeSymbolWEventType();
            var methodLookupableMake = parent.MakeChildWithScope(
                    typeof(ExprFilterSpecLookupable),
                    GetType(),
                    symbolsWithType,
                    classScope)
                .AddParam(typeof(EventType), "eventType")
                .AddParam(typeof(EPStatementInitServices), SAIFFInitializeSymbol.REF_STMTINITSVC.Ref);
            var methodLookupable = Lookupable.MakeCodegen(methodLookupableMake, symbolsWithType, classScope);
            methodLookupableMake.Block.MethodReturn(LocalMethod(methodLookupable));

            method.Block
                .DeclareVar<ContextControllerDetailHashItem>(
                    "item",
                    NewInstance(typeof(ContextControllerDetailHashItem)))
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    LocalMethod(methodLookupableMake, Ref("eventType"), symbols.GetAddInitSvc(method)))
                .SetProperty(
                    Ref("item"),
                    "FilterSpecActivatable",
                    LocalMethod(FilterSpecCompiled.MakeCodegen(method, symbols, classScope)))
                .SetProperty(Ref("item"), "Lookupable", Ref("lookupable"))
                .Expression(
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.FILTERSHAREDLOOKUPABLEREGISTERY)
                        .Add("RegisterLookupable", Ref("eventType"), Ref("lookupable")))
                .MethodReturn(Ref("item"));

            return LocalMethod(method);
        }
Ejemplo n.º 29
0
 public void MakeMethod(
     CodegenMethod method,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var select = Ref("select");
     method.Block
         .DeclareVar<FAFQueryMethodSelect>(select.Ref, NewInstance(typeof(FAFQueryMethodSelect)))
         .SetProperty(
             select,
             "Annotations",
             LocalMethod(
                 AnnotationUtil.MakeAnnotations(typeof(Attribute[]), _desc.Annotations, method, classScope)))
         .SetProperty(
             select,
             "Processors",
             FireAndForgetProcessorForgeExtensions.MakeArray(_desc.Processors, method, symbols, classScope))
         .DeclareVar(
             _classNameResultSetProcessor,
             "rsp",
             NewInstance(_classNameResultSetProcessor, symbols.GetAddInitSvc(method), Ref("statementFields")))
         .SetProperty(select, "ResultSetProcessorFactoryProvider", Ref("rsp"))
         .SetProperty(select, "QueryGraph", _desc.QueryGraph.Make(method, symbols, classScope))
         .SetProperty(
             select,
             "WhereClause",
             _desc.WhereClause == null
                 ? ConstantNull()
                 : ExprNodeUtilityCodegen.CodegenEvaluator(
                     _desc.WhereClause.Forge,
                     method,
                     GetType(),
                     classScope))
         .SetProperty(
             select,
             "JoinSetComposerPrototype",
             _desc.Joins == null ? ConstantNull() : _desc.Joins.Make(method, symbols, classScope))
         .SetProperty(
             select,
             "ConsumerFilters",
             ExprNodeUtilityCodegen.CodegenEvaluators(_desc.ConsumerFilters, method, GetType(), classScope))
         .SetProperty(select, "ContextName", Constant(_desc.ContextName))
         .SetProperty(
             select,
             "TableAccesses",
             ExprTableEvalStrategyUtil.CodegenInitMap(
                 _desc.TableAccessForges,
                 GetType(),
                 method,
                 symbols,
                 classScope))
         .SetProperty(select, "HasTableAccess", Constant(_desc.HasTableAccess))
         .SetProperty(select, "IsDistinct", Constant(_desc.IsDistinct))
         .MethodReturn(select);
 }
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(ContainedEventEvalExprNode), GetType(), classScope);
     method.Block
         .DeclareVar<ExprEvaluator>(
             "eval",
             ExprNodeUtilityCodegen.CodegenEvaluator(evaluator, method, GetType(), classScope))
         .DeclareVar<EventType>(
             "type",
             EventTypeUtility.ResolveTypeCodegen(eventType, symbols.GetAddInitSvc(method)))
         .MethodReturn(
             NewInstance<ContainedEventEvalExprNode>(
                 Ref("eval"),
                 Ref("type"),
                 symbols.GetAddInitSvc(method)));
     return LocalMethod(method);
 }