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.º 2
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;
        }