Exemple #1
0
            public override CodegenExpression CodegenPremade(
                Type evaluationType,
                CodegenExpression input,
                Type inputType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                CodegenExpression timeZoneField =
                    codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);

                return(CodegenExpressionBuilder.StaticMethod(
                           typeof(StringToDateTimExWStaticFormatComputer),
                           "StringToDtxWStaticFormatParse",
                           FormatField(dateFormatString, codegenClassScope),
                           input,
                           timeZoneField));
            }
Exemple #2
0
        public CodegenExpression CodegenLong(
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var timeZoneField = codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);
            var methodNode = codegenMethodScope
                .MakeChild(typeof(DateTimeEx), typeof(ReformatToDateTimeExForge), codegenClassScope)
                .AddParam(typeof(long), "ts");

            methodNode
                .Block
                .DeclareVar<DateTimeEx>("dtx", StaticMethod(typeof(DateTimeEx), "GetInstance", timeZoneField))
                .Expression(_timeAbacus.DateTimeSetCodegen(Ref("ts"), Ref("dtx"), methodNode, codegenClassScope))
                .MethodReturn(Ref("dtx"));
            return LocalMethod(methodNode, inner);
        }
Exemple #3
0
            public CodegenExpression Codegen(
                CodegenMethodScope codegenMethodScope,
                CodegenClassScope codegenClassScope,
                CodegenExpressionRef left,
                CodegenExpressionRef right,
                Type ltype,
                Type rtype)
            {
                var returnType = typeof(decimal);

                if (ltype.IsNullable() || rtype.IsNullable() || _divisionByZeroReturnsNull)
                {
                    returnType = typeof(decimal?);
                }

                CodegenExpression math =
                    codegenClassScope.AddOrGetDefaultFieldSharable(new MathContextCodegenField(_mathContext));
                var block = codegenMethodScope
                            .MakeChild(returnType, typeof(DivideDecimalWMathContext), codegenClassScope)
                            //.AddParam(typeof(decimal?), "b1")
                            //.AddParam(typeof(decimal?), "b2")
                            .AddParam(ltype, "b1")
                            .AddParam(rtype, "b2")
                            .Block;

                var ifZero = block.IfCondition(
                    EqualsIdentity(
                        Ref("b2"),
                        Constant(0.0m)));
                {
                    if (_divisionByZeroReturnsNull)
                    {
                        ifZero.BlockReturn(ConstantNull());
                    }
                    else
                    {
                        ifZero.BlockReturn(Op(Unbox(Ref("b1"), ltype), "/", Constant(0.0m)));
                    }
                }
                var method = block.MethodReturn(
                    ExprDotMethod(math, "Apply", Op(Ref("b1"), "/", Ref("b2"))));

                return(LocalMethod(method, left, right));
            }
Exemple #4
0
        public CodegenExpression CodegenDateTime(
            CodegenExpression inner,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var timeZoneField =
                codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);
            var methodNode = codegenMethodScope
                .MakeChild(typeof(int), typeof(ReformatEvalForge), codegenClassScope)
                .AddParam(typeof(DateTime), "d");

            methodNode.Block
                .DeclareVar<DateTimeEx>("dtx", StaticMethod(typeof(DateTimeEx), "GetInstance", timeZoneField))
                .Expression(ExprDotMethod(Ref("dtx"), "Set", Ref("d")))
                .MethodReturn(_dateTimeExEval.Codegen(Ref("dtx")));
            
            return LocalMethod(methodNode, inner);
        }
Exemple #5
0
        public void ProviderCodegen(
            CodegenMethod method,
            CodegenClassScope classScope,
            AggregationClassNames classNames)
        {
            var groupByTypes = ExprNodeUtilityQuery.GetExprResultTypes(aggGroupByDesc.GroupByNodes);

            if (aggGroupByDesc.IsReclaimAged) {
                reclaimAge = aggGroupByDesc.ReclaimEvaluationFunctionMaxAge.Make(classScope);
                reclaimFreq = aggGroupByDesc.ReclaimEvaluationFunctionFrequency.Make(classScope);
            }
            else {
                reclaimAge = ConstantNull();
                reclaimFreq = ConstantNull();
            }

            var stmtFields = ResultSetProcessorCodegenNames.REF_STATEMENT_FIELDS;
            var timeAbacus = classScope.AddOrGetDefaultFieldSharable(TimeAbacusField.INSTANCE);

            method.Block
                .DeclareVar<AggregationRowFactory>(
                    "rowFactory",
                    NewInstance(classNames.RowFactoryTop, Ref("this")))
                .DeclareVar<DataInputOutputSerdeWCollation<AggregationRow>>(
                    "rowSerde",
                    NewInstance(classNames.RowSerdeTop, Ref("this")))
                .DeclareVar<AggregationServiceFactory>(
                    "svcFactory",
                    NewInstance(classNames.ServiceFactory, Ref("this")))
                .MethodReturn(
                    ExprDotMethodChain(EPStatementInitServicesConstants.REF)
                        .Get(EPStatementInitServicesConstants.AGGREGATIONSERVICEFACTORYSERVICE)
                        .Add(
                            "GroupBy",
                            Ref("svcFactory"),
                            Ref("rowFactory"),
                            aggGroupByDesc.RowStateForgeDescs.UseFlags.ToExpression(),
                            Ref("rowSerde"),
                            Constant(groupByTypes),
                            reclaimAge,
                            reclaimFreq,
                            timeAbacus));
        }
Exemple #6
0
 public CodegenExpression CodegenDateTime(
     CodegenExpression inner,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpression timeZoneField =
         codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);
     var method = codegenMethodScope
         .MakeChild(typeof(DateTimeOffset), typeof(ReformatToDateTimeOffsetForge), codegenClassScope)
         .AddParam(typeof(DateTime), "input")
         .Block
         .DeclareVar<DateTimeEx>(
             "dateTimeEx",
             StaticMethod(typeof(DateTimeEx), "GetInstance", timeZoneField))
         .ExprDotMethod(Ref("dateTimeEx"), "Set", Ref("input"))
         .MethodReturn(GetProperty(Ref("dateTimeEx"), "DateTime"));
     return LocalMethodBuild(method).Pass(inner).Call();
 }
Exemple #7
0
 public CodegenExpression CodegenConvertNonNull(
     CodegenExpression result,
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope classScope)
 {
     var eventSvcMember = classScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
     var typeMember = classScope.AddDefaultFieldUnshared(
         true,
         typeof(BeanEventType),
         Cast(
             typeof(BeanEventType),
             EventTypeUtility.ResolveTypeCodegen(type, EPStatementInitServicesConstants.REF)));
     return StaticMethod(
         typeof(ExprDotStaticMethodWrapIterableEvents),
         "UnwrapEventBeans",
         eventSvcMember,
         typeMember,
         result);
 }
Exemple #8
0
        public static CodegenExpression CodegenStartEnd(
            DTLocalLongOpsIntervalForge forge,
            CodegenExpression start,
            CodegenExpression end,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression timeZoneField =
                codegenClassScope.AddOrGetDefaultFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE);
            var methodNode = codegenMethodScope
                .MakeChild(typeof(bool?), typeof(DTLocalLongOpsIntervalEval), codegenClassScope)
                .AddParam(typeof(long), "startLong")
                .AddParam(typeof(long), "endLong");

            var block = methodNode.Block
                .DeclareVar<DateTimeEx>("dtx", StaticMethod(typeof(DateTimeEx), "GetInstance", timeZoneField))
                .DeclareVar<long>(
                    "startRemainder",
                    forge.timeAbacus.DateTimeSetCodegen(Ref("startLong"), Ref("dtx"), methodNode, codegenClassScope));
            EvaluateCalOpsDtxCodegen(
                block,
                forge.calendarForges,
                Ref("dtx"),
                methodNode,
                exprSymbol,
                codegenClassScope);
            block.DeclareVar<long>(
                    "startTime",
                    forge.timeAbacus.DateTimeGetCodegen(Ref("dtx"), Ref("startRemainder"), codegenClassScope))
                .DeclareVar<long>(
                    "endTime",
                    Op(Ref("startTime"), "+", Op(Ref("endLong"), "-", Ref("startLong"))))
                .MethodReturn(
                    forge.intervalForge.Codegen(
                        Ref("startTime"),
                        Ref("endTime"),
                        methodNode,
                        exprSymbol,
                        codegenClassScope));
            return LocalMethod(methodNode, start, end);
        }
Exemple #9
0
 public CodegenExpression EvaluateCodegenUninstrumented(
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var reader = classScope.AddOrGetDefaultFieldSharable(
         new AggregationTableAccessAggReaderCodegenField(_tableAccessDesc.Reader, classScope, GetType()));
     return CodegenLegoCast.CastSafeFromObjectType(
         requiredType,
         StaticMethod(
             typeof(ExprTableIdentNodeSubpropAccessor),
             "EvaluateTableWithReader",
             Constant(_streamNum),
             reader,
             Constant(_tableAccessColumn.Column),
             symbols.GetAddEPS(parent),
             symbols.GetAddIsNewData(parent),
             symbols.GetAddExprEvalCtx(parent)));
 }
 private CodegenMethod GetCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     var cache = codegenClassScope.AddOrGetDefaultFieldSharable(
         new VariantPropertyGetterCacheCodegenField(variantEventType));
     var method = codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(EventBean), "eventBean");
     method.Block
         .DeclareVar<object>(
             "value",
             StaticMethod(
                 typeof(VariantEventPropertyGetterAny),
                 "VariantGet",
                 Ref("eventBean"),
                 cache,
                 Constant(propertyName)))
         .MethodReturn(caster.Codegen(Ref("value"), typeof(object), method, codegenClassScope));
     return method;
 }
Exemple #11
0
 private CodegenMethod GetFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     var mSvc = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
     var mType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(fragmentEventType, EPStatementInitServicesConstants.REF));
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(IDictionary<string, object>), "map")
         .Block
         .DeclareVar<object>(
             "value",
             UnderlyingGetCodegen(Ref("map"), codegenMethodScope, codegenClassScope))
         .IfInstanceOf("value", typeof(EventBean[]))
         .BlockReturn(Ref("value"))
         .MethodReturn(
             StaticMethod(typeof(BaseNestableEventUtil), "GetBNFragmentArray", Ref("value"), mType, mSvc));
 }
        public override CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (OptionalInnerType == null) {
                return ConstantNull();
            }

            CodegenExpression factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            CodegenExpression eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(OptionalInnerType, EPStatementInitServicesConstants.REF));
            return StaticMethod(
                typeof(JsonFieldGetterHelperProvided),
                "HandleJsonProvidedCreateFragmentIndexed",
                ExprDotName(underlyingExpression, field.Name),
                Constant(Index),
                eventType,
                factory);
        }
Exemple #13
0
 protected internal static CodegenMethod SortWGroupKeysInternalCodegen(
     OrderByProcessorForgeImpl forge,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     var createSortProperties = CreateSortPropertiesCodegen(forge, classScope, namedMethods);
     CodegenExpression comparator = classScope.AddOrGetDefaultFieldSharable(forge.IComparer);
     Consumer<CodegenMethod> code = method => {
         method.Block.DeclareVar<IList<object>>(
                 "sortValuesMultiKeys",
                 LocalMethod(
                     createSortProperties,
                     REF_GENERATINGEVENTS,
                     Ref("groupByKeys"),
                     REF_ISNEWDATA,
                     REF_EXPREVALCONTEXT,
                     MEMBER_AGGREGATIONSVC))
             .MethodReturn(
                 StaticMethod(
                     typeof(OrderByProcessorUtil),
                     "SortGivenOutgoingAndSortKeys",
                     REF_OUTGOINGEVENTS,
                     Ref("sortValuesMultiKeys"),
                     comparator));
     };
     return namedMethods.AddMethod(
         typeof(EventBean[]),
         "SortWGroupKeysInternal",
         CodegenNamedParam.From(
             typeof(EventBean[]), REF_OUTGOINGEVENTS.Ref,
             typeof(EventBean[][]), REF_GENERATINGEVENTS.Ref,
             typeof(object[]), "groupByKeys",
             typeof(bool), REF_ISNEWDATA.Ref,
             typeof(ExprEvaluatorContext), REF_EXPREVALCONTEXT.Ref,
             typeof(AggregationService), MEMBER_AGGREGATIONSVC.Ref),
         typeof(OrderByProcessorImpl),
         classScope,
         code);
 }
Exemple #14
0
 public override CodegenExpression Codegen(
     EnumForgeCodegenParams args,
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpression math =
         codegenClassScope.AddOrGetDefaultFieldSharable(new MathContextCodegenField(_optionalMathContext));
     var method = codegenMethodScope
         .MakeChild(typeof(decimal?), typeof(EnumAverageScalarForge), codegenClassScope)
         .AddParam(EnumForgeCodegenNames.PARAMS)
         .Block
         .DeclareVar<EnumAverageDecimalEventsForgeEval.AggregatorAvgDecimal>(
             "agg",
             NewInstance(typeof(EnumAverageDecimalEventsForgeEval.AggregatorAvgDecimal), math))
         .ForEach(typeof(object), "num", EnumForgeCodegenNames.REF_ENUMCOLL)
         .IfRefNull("num")
         .BlockContinue()
         .Expression(ExprDotMethod(Ref("agg"), "Enter", Ref("num")))
         .BlockEnd()
         .MethodReturn(ExprDotName(Ref("agg"), "Value"));
     return LocalMethod(method, args.Expressions);
 }
Exemple #15
0
 public AggregatorMinMax(
         AggregationForgeFactoryMinMax factory,
         int col,
         CodegenCtor rowCtor,
         CodegenMemberCol membersColumnized,
         CodegenClassScope classScope,
         Type optionalDistinctValueType,
         DataInputOutputSerdeForge optionalDistinctSerde,
         bool hasFilter,
         ExprNode optionalFilter)
     : base(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, optionalDistinctSerde, hasFilter, optionalFilter)
 {
     this._factory = factory;
     _refSet = membersColumnized.AddMember(col, typeof(SortedRefCountedSet<object>), "refSet");
     _serde = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(
             CodegenSharableSerdeClassTyped.CodegenSharableSerdeName.SORTEDREFCOUNTEDSET,
             factory.ResultType,
             factory.Serde,
             classScope));
     rowCtor.Block.AssignRef(_refSet, NewInstance(typeof(SortedRefCountedSet<object>)));
 }
Exemple #16
0
 private CodegenMethod GetAvroFragmentCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     var factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
     var eventType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(_fragmentEventType, EPStatementInitServicesConstants.REF));
     return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<object>(
             "value",
             UnderlyingGetCodegen(CodegenExpressionBuilder.Ref("record"), codegenMethodScope, codegenClassScope))
         .MethodReturn(
             CodegenExpressionBuilder.ExprDotMethod(
                 factory,
                 "AdapterForTypedAvro",
                 CodegenExpressionBuilder.Ref("value"),
                 eventType));
 }
Exemple #17
0
        public override CodegenExpression UnderlyingExistsCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope parent,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression memberCache = codegenClassScope.AddOrGetDefaultFieldSharable(SharableCode);
            var method = parent.MakeChild(typeof(bool), typeof(DynamicPropertyGetterByMethodOrPropertyBase), codegenClassScope)
                         .AddParam(typeof(object), "@object");

            method.Block
            .DeclareVar <DynamicPropertyDescriptorByMethod>("desc", GetPopulateCacheCodegen(memberCache, Ref("@object"), method, codegenClassScope))
            .IfCondition(EqualsNull(ExprDotName(Ref("desc"), "Method")))
            .BlockReturn(ConstantFalse())
            .MethodReturn(
                StaticMethod(
                    typeof(DynamicMappedPropertyGetterByMethodOrProperty),
                    "DynamicMappedPropertyExists",
                    Ref("desc"),
                    Ref("@object"),
                    Constant(_parameters[0])));
            return(LocalMethod(method, underlyingExpression));
        }
Exemple #18
0
        public override CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (FragmentType == null) {
                return ConstantNull();
            }

            CodegenExpression factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            CodegenExpression eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(FragmentType, EPStatementInitServicesConstants.REF));
            return StaticMethod(
                typeof(JsonFieldGetterHelperSchema),
                "HandleJsonCreateFragmentArray",
                underlyingExpression,
                Constant(Field.PropertyName),
                eventType,
                factory);
        }
 public AggregatorMinMaxEver(
     AggregationForgeFactoryMinMax factory,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope,
     Type optionalDistinctValueType,
     DataInputOutputSerdeForge optionalDistinctSerde,
     bool hasFilter,
     ExprNode optionalFilter,
     DataInputOutputSerdeForge serde)
     : base(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, optionalDistinctSerde, hasFilter, optionalFilter)
 {
     _factory = factory;
     _currentMinMax = membersColumnized.AddMember(col, typeof(IComparable), "currentMinMax");
     _serde = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(
             CodegenSharableSerdeClassTyped.CodegenSharableSerdeName.VALUE_NULLABLE,
             factory.ResultType,
             serde,
             classScope));
 }
Exemple #20
0
        public static CodegenExpression Codegen(
            EnumAverageDecimalEventsForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = forge.InnerExpression.EvaluationType;

            CodegenExpression math =
                codegenClassScope.AddOrGetDefaultFieldSharable(new MathContextCodegenField(forge.optionalMathContext));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(
                    typeof(decimal?),
                    typeof(EnumAverageDecimalEventsForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block;
            block.DeclareVar<AggregatorAvgDecimal>(
                "agg",
                NewInstance<AggregatorAvgDecimal>(math));
            var forEach = block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("next"))
                .DeclareVar(
                    innerType,
                    "num",
                    forge.InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (innerType.CanBeNull()) {
                forEach.IfRefNull("num").BlockContinue();
            }

            forEach.Expression(ExprDotMethod(Ref("agg"), "Enter", Ref("num")))
                .BlockEnd();
            block.MethodReturn(ExprDotName(Ref("agg"), "Value"));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
        public CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            if (eventType == null) {
                return ConstantNull();
            }

            var mSvc = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var mType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(BeanEventType),
                Cast(
                    typeof(BeanEventType),
                    EventTypeUtility.ResolveTypeCodegen(eventType, EPStatementInitServicesConstants.REF)));
            return StaticMethod(
                typeof(BaseNestableEventUtil),
                "GetBNFragmentPono",
                UnderlyingGetCodegen(underlyingExpression, codegenMethodScope, codegenClassScope),
                mType,
                mSvc);
        }
Exemple #22
0
 public AggregatorNth(
     AggregationForgeFactoryNth factory,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope,
     Type optionalDistinctValueType,
     DataInputOutputSerdeForge optionalDistinctSerde,
     bool hasFilter,
     ExprNode optionalFilter)
     : base(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, optionalDistinctSerde, hasFilter, optionalFilter)
 {
     this._factory = factory;
     _circularBuffer = membersColumnized.AddMember(col, typeof(object[]), "buf");
     _currentBufferElementPointer = membersColumnized.AddMember(col, typeof(int), "cbep");
     _numDataPoints = membersColumnized.AddMember(col, typeof(long), "cnt");
     _serdeValue = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(
             CodegenSharableSerdeClassTyped.CodegenSharableSerdeName.VALUE_NULLABLE,
             factory.ChildType,
             factory.Serde,
             classScope));
 }
Exemple #23
0
 public AggregatorMinMaxEver(
     AggregationFactoryMethodMinMax factory,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope,
     Type optionalDistinctValueType,
     bool hasFilter,
     ExprNode optionalFilter)
     : base(
         factory,
         col,
         rowCtor,
         membersColumnized,
         classScope,
         optionalDistinctValueType,
         hasFilter,
         optionalFilter)
 {
     this.factory = factory;
     currentMinMax = membersColumnized.AddMember(col, typeof(IComparable), "currentMinMax");
     serde = classScope.AddOrGetDefaultFieldSharable(new CodegenSharableSerdeClassTyped(VALUE_NULLABLE, factory.ResultType));
 }
Exemple #24
0
        private CodegenMethod GetFragmentCodegen(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var msvc = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var mtype = codegenClassScope.AddDefaultFieldUnshared<BeanEventType>(
                false,
                Cast(
                    typeof(BeanEventType),
                    EventTypeUtility.ResolveTypeCodegen(_fragmentEventType, EPStatementInitServicesConstants.REF)));

            var block = codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
                .AddParam(TargetType, "underlying")
                .Block
                .DeclareVar(
                    BeanPropType,
                    "@object",
                    UnderlyingGetCodegen(Ref("underlying"), codegenMethodScope, codegenClassScope))
                .IfRefNullReturnNull("@object");

            if (_isArray) {
                return block.MethodReturn(
                    StaticMethod(
                        typeof(BaseNativePropertyGetter),
                        "ToFragmentArray",
                        Cast(typeof(object[]), Ref("@object")),
                        mtype,
                        msvc));
            }

            if (_isIterable) {
                return block.MethodReturn(
                    StaticMethod(typeof(BaseNativePropertyGetter), "ToFragmentIterable", Ref("@object"), mtype, msvc));
            }

            return block.MethodReturn(ExprDotMethod(msvc, "AdapterForTypedObject", Ref("@object"), mtype));
        }
        public override CodegenExpression EvaluateGetCollEventsCodegen(
            CodegenMethodScope parent,
            ExprSubselectEvalMatchSymbol symbols,
            CodegenClassScope classScope)
        {
            var aggService = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                new CodegenFieldNameSubqueryAgg(subselect.SubselectNumber),
                typeof(AggregationResultFuture));

            var method = parent.MakeChild(typeof(FlexCollection), this.GetType(), classScope);
            var evalCtx = symbols.GetAddExprEvalCtx(method);
            var eventBeanSvc =
                classScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var typeMember = classScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(
                    subselect.subselectMultirowType,
                    EPStatementInitServicesConstants.REF));

            method.Block
                .DeclareVar<int>("cpid", ExprDotName(evalCtx, "AgentInstanceId"))
                .DeclareVar<AggregationService>("aggregationService", ExprDotMethod(aggService, "GetContextPartitionAggregationService", Ref("cpid")))
                .DeclareVar<ICollection<object>>("groupKeys", ExprDotMethod(aggService, "GetGroupKeys", evalCtx))
                .IfCondition(ExprDotMethod(Ref("groupKeys"), "IsEmpty"))
                .BlockReturn(ConstantNull())
                .DeclareVar<ICollection<EventBean>>("events", NewInstance<ArrayDeque<EventBean>>(ExprDotName(Ref("groupKeys"), "Count")))
                .ForEach(typeof(object), "groupKey", Ref("groupKeys"))
                .ExprDotMethod(aggService, "SetCurrentAccess", Ref("groupKey"), Ref("cpid"), ConstantNull())
                .DeclareVar<IDictionary<string, object>>("row", LocalMethod(subselect.EvaluateRowCodegen(method, classScope), ConstantNull(), ConstantTrue(), symbols.GetAddExprEvalCtx(method)))
                .DeclareVar<EventBean>("@event", ExprDotMethod(eventBeanSvc, "AdapterForTypedMap", Ref("row"), typeMember))
                .ExprDotMethod(Ref("events"), "Add", Ref("@event"))
                .BlockEnd()
                .MethodReturn(FlexWrap(Ref("events")));
            return LocalMethod(method);
        }
Exemple #26
0
 protected internal static void SortRollupCodegen(
     OrderByProcessorForgeImpl forge,
     CodegenMethod method,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     var createSortPropertiesWRollup = CreateSortPropertiesWRollupCodegen(forge, classScope, namedMethods);
     CodegenExpression comparator = classScope.AddOrGetDefaultFieldSharable(forge.IComparer);
     method.Block.DeclareVar<IList<object>>(
             "sortValuesMultiKeys",
             LocalMethod(
                 createSortPropertiesWRollup,
                 REF_ORDERCURRENTGENERATORS,
                 REF_ISNEWDATA,
                 MEMBER_AGENTINSTANCECONTEXT,
                 MEMBER_AGGREGATIONSVC))
         .MethodReturn(
             StaticMethod(
                 typeof(OrderByProcessorUtil),
                 "SortGivenOutgoingAndSortKeys",
                 REF_OUTGOINGEVENTS,
                 Ref("sortValuesMultiKeys"),
                 comparator));
 }
Exemple #27
0
        public CodegenExpression Make(
            CodegenBlock codegenBlock,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var init = codegenClassScope.NamespaceScope.InitMethod;

            var factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(_eventType, EPStatementInitServicesConstants.REF));

            var makeUndLambda = new CodegenExpressionLambda(codegenBlock)
                .WithParam<object[]>("properties")
                .WithBody(block => MakeUnderlyingCodegen(block, codegenClassScope));

            var manufacturer = NewInstance<ProxyAvroEventBeanManufacturer>(
                    eventType, factory, makeUndLambda);

            //var makeUndMethod = CodegenMethod.MakeMethod(typeof(GenericRecord), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("MakeUnderlying", makeUndMethod);
            //MakeUnderlyingCodegen(makeUndMethod, codegenClassScope);

            //var makeMethod = CodegenMethod
            //    .MakeMethod(typeof(EventBean), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("Make", makeMethod);
            //makeMethod.Block
            //    .DeclareVar<GenericRecord>("und", LocalMethod(makeUndMethod, Ref("properties")))
            //    .MethodReturn(ExprDotMethod(factory, "AdapterForTypedAvro", Ref("und"), beanType));

            return codegenClassScope.AddDefaultFieldUnshared(
                true, typeof(EventBeanManufacturer), manufacturer);
        }
Exemple #28
0
 private CodegenExpressionInstanceField GetSerde(CodegenClassScope classScope)
 {
     return classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeEventTyped(LINKEDMAPEVENTSANDINT, forge.EventType));
 }
        public static CodegenExpression Codegen(
            ExprDotNodeForgeVariable forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope classScope)
        {
            var variableReader =
                classScope.AddOrGetDefaultFieldSharable(new VariableReaderCodegenFieldSharable(forge.Variable));

            Type variableType;
            var metaData = forge.Variable;
            if (metaData.EventType != null) {
                variableType = typeof(EventBean);
            }
            else {
                variableType = metaData.Type;
            }

            var methodNode = codegenMethodScope.MakeChild(
                forge.EvaluationType,
                typeof(ExprDotNodeForgeVariableEval),
                classScope);

            var typeInformation = ConstantNull();
            if (classScope.IsInstrumented) {
                typeInformation = classScope.AddOrGetDefaultFieldSharable(
                    new EPTypeCodegenSharable(new ClassEPType(variableType), classScope));
            }

            var block = methodNode.Block
                .DeclareVar(variableType, "result", Cast(variableType, ExprDotName(variableReader, "Value")))
                .Apply(
                    InstrumentationCode.Instblock(
                        classScope,
                        "qExprDotChain",
                        typeInformation,
                        Ref("result"),
                        Constant(forge.ChainForge.Length)));
            
            var chain = ExprDotNodeUtility.EvaluateChainCodegen(
                methodNode,
                exprSymbol,
                classScope,
                Ref("result"),
                variableType,
                forge.ChainForge,
                forge.ResultWrapLambda);

            if (forge.EvaluationType != typeof(void)) {
                block.DeclareVar(forge.EvaluationType, "returned", chain)
                    .Apply(InstrumentationCode.Instblock(classScope, "aExprDotChain"))
                    .MethodReturn(Ref("returned"));
            }
            else {
                block
                    .Expression(chain)
                    .Apply(InstrumentationCode.Instblock(classScope, "aExprDotChain"));
            }

            return LocalMethod(methodNode);
        }
        public void InstanceCodegen(
            CodegenInstanceAux instance,
            CodegenClassScope classScope,
            CodegenCtor factoryCtor,
            IList<CodegenTypedParam> factoryMembers)
        {
            instance.Properties.AddProperty(
                typeof(SelectExprProcessor),
                "SelectExprProcessor",
                GetType(),
                classScope,
                propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_SELECTEXPRPROCESSOR));
            instance.Properties.AddProperty(
                typeof(AggregationService),
                "AggregationService",
                GetType(),
                classScope,
                propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_AGGREGATIONSVC));
            instance.Methods.AddMethod(
                typeof(ExprEvaluatorContext),
                "GetAgentInstanceContext",
                EmptyList<CodegenNamedParam>.Instance,
                GetType(),
                classScope,
                node => node.Block.ReturnMethodOrBlock(MEMBER_AGENTINSTANCECONTEXT));
            instance.Properties.AddProperty(
                typeof(bool),
                "HasHavingClause",
                GetType(),
                classScope,
                propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(OptionalHavingNode != null)));
            instance.Properties.AddProperty(
                typeof(bool),
                "IsSelectRStream",
                typeof(ResultSetProcessorRowForAll),
                classScope,
                propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(IsSelectRStream)));
            ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance);
            GenerateGroupKeySingle = ResultSetProcessorGroupedUtil.GenerateGroupKeySingleCodegen(GroupKeyNodeExpressions, multiKeyClassRef, classScope, instance);
            GenerateGroupKeyArrayView = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayViewCodegen(GenerateGroupKeySingle, classScope, instance);
            GenerateGroupKeyArrayJoin = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayJoinCodegen(GenerateGroupKeySingle, classScope, instance);

            ResultSetProcessorRowPerGroupImpl.GenerateOutputBatchedNoSortWMapCodegen(this, classScope, instance);
            ResultSetProcessorRowPerGroupImpl.GenerateOutputBatchedArrFromEnumeratorCodegen(this, classScope, instance);
            ResultSetProcessorRowPerGroupImpl.RemovedAggregationGroupKeyCodegen(classScope, instance);

            if (unboundedProcessor) {
                var factory = classScope.AddOrGetDefaultFieldSharable(ResultSetProcessorHelperFactoryField.INSTANCE);
                instance.AddMember(NAME_GROUPREPS, typeof(ResultSetProcessorRowPerGroupUnboundHelper));
                CodegenExpression groupKeySerde = MultiKeyClassRef.GetExprMKSerde(classScope.NamespaceScope.InitMethod, classScope);

                var eventType = classScope.AddDefaultFieldUnshared(
                    true,
                    typeof(EventType),
                    EventTypeUtility.ResolveTypeCodegen(typesPerStream[0], EPStatementInitServicesConstants.REF));

                instance.ServiceCtor.Block
                    .AssignRef(
                        NAME_GROUPREPS,
                        ExprDotMethod(
                            factory,
                            "MakeRSRowPerGroupUnboundGroupRep",
                            Constant(groupKeyTypes),
                            groupKeySerde,
                            eventType,
                            MEMBER_AGENTINSTANCECONTEXT))
                    .ExprDotMethod(MEMBER_AGGREGATIONSVC, "SetRemovedCallback", Member(NAME_GROUPREPS));
            }
            else {
                instance.ServiceCtor.Block
                    .ExprDotMethod(MEMBER_AGGREGATIONSVC, "SetRemovedCallback", Ref("this"));
            }
        }