예제 #1
0
 public AggregatorMinMax(
     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;
     refSet = membersColumnized.AddMember(col, typeof(SortedRefCountedSet<object>), "refSet");
     serde = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(SORTEDREFCOUNTEDSET, factory.ResultType));
     rowCtor.Block.AssignRef(refSet, NewInstance(typeof(SortedRefCountedSet<object>)));
 }
예제 #2
0
        public AggregatorMethodWDistinctWFilterBase(
            AggregationForgeFactory factory,
            int col,
            CodegenCtor rowCtor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            Type optionalDistinctValueType,
            bool hasFilter,
            ExprNode optionalFilter)
        {
            this.optionalDistinctValueType = optionalDistinctValueType;
            this.optionalFilter = optionalFilter;
            this.hasFilter = hasFilter;

            if (optionalDistinctValueType != null) {
                distinct = membersColumnized.AddMember(col, typeof(RefCountedSet<object>), "distinctSet");
                rowCtor.Block.AssignRef(distinct, NewInstance(typeof(RefCountedSet<object>)));
                distinctSerde = classScope.AddOrGetDefaultFieldSharable(
                    new CodegenSharableSerdeClassTyped(REFCOUNTEDSET, optionalDistinctValueType));
            }
            else {
                distinct = null;
                distinctSerde = null;
            }
        }
예제 #3
0
        private void MakeBlock(
            string getterMethod,
            int column,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            if (_accessorField == null) {
                var injectionStrategy =
                    (InjectionStrategyClassNewInstance) _mode.InjectionStrategyAggregationAccessorFactory;
                _accessorField = classScope.AddDefaultFieldUnshared(
                    true,
                    typeof(AggregationMultiFunctionAccessor),
                    ExprDotMethod(
                        injectionStrategy.GetInitializationExpression(classScope),
                        "NewAccessor",
                        ConstantNull()));
            }

            method.Block.MethodReturn(
                ExprDotMethod(
                    _accessorField,
                    getterMethod,
                    MemberCol("state", column),
                    REF_EPS,
                    REF_ISNEWDATA,
                    REF_EXPREVALCONTEXT));
        }
예제 #4
0
 public AggregatorNth(
     AggregationFactoryMethodNth 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;
     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(VALUE_NULLABLE, factory.childType));
 }
예제 #5
0
 public AggregatorLastEver(
     AggregationForgeFactory factory,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope,
     Type optionalDistinctValueType,
     DataInputOutputSerdeForge optionalDistinctSerde,
     bool hasFilter,
     ExprNode optionalFilter,
     Type childType,
     DataInputOutputSerdeForge serde)
     : base(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, optionalDistinctSerde, hasFilter, optionalFilter)
 {
     _childType = childType.GetBoxedType();
     // NOTE: we had originally set the value of the member to childType which seems correct an
     //   appropriate.  However, the code is not doing proper type checking and cast conversion
     //   elsewhere which makes assignment problematic.  Revisit this problem when we have more
     //   time.
     _lastValue = membersColumnized.AddMember(col, typeof(object), "lastValue");
     this._serde = classScope.AddOrGetDefaultFieldSharable(
         new CodegenSharableSerdeClassTyped(
             CodegenSharableSerdeClassTyped.CodegenSharableSerdeName.VALUE_NULLABLE,
             childType,
             serde,
             classScope));
 }
        public AggregatorAccessSortedMinMaxByEver(
            AggregationStateMinMaxByEverForge forge,
            int col,
            CodegenCtor ctor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            ExprNode optionalFilter)
            : base(optionalFilter)
        {
            this._forge             = forge;
            _currentMinMaxBean      = membersColumnized.AddMember(col, typeof(EventBean), "currentMinMaxBean");
            _currentMinMaxBeanSerde = classScope.AddOrGetDefaultFieldSharable(
                new CodegenSharableSerdeEventTyped(
                    CodegenSharableSerdeEventTyped.CodegenSharableSerdeName.NULLABLEEVENTMAYCOLLATE,
                    forge.Spec.StreamEventType));
            _currentMinMax = membersColumnized.AddMember(col, typeof(object), "currentMinMax");
            if (forge.Spec.Criteria.Length == 1)
            {
                _currentMinMaxSerde = classScope.AddOrGetDefaultFieldSharable(
                    new CodegenSharableSerdeClassTyped(VALUE_NULLABLE, forge.Spec.CriteriaTypes[0], forge.Spec.CriteriaSerdes[0], classScope));
            }
            else
            {
                _currentMinMaxSerde = classScope.AddOrGetDefaultFieldSharable(
                    new CodegenSharableSerdeClassArrayTyped(OBJECTARRAYMAYNULLNULL, forge.Spec.CriteriaTypes, forge.Spec.CriteriaSerdes, classScope));
            }

            _comparator = classScope.AddOrGetDefaultFieldSharable(
                new CodegenFieldSharableComparator(
                    COMPARATOROBJECTARRAYNONHASHABLE,
                    forge.Spec.CriteriaTypes,
                    forge.Spec.IsSortUsingCollator,
                    forge.Spec.SortDescending));
        }
예제 #7
0
        public CodegenMethod ProcessCodegen(
            CodegenExpression resultEventTypeOuter,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor
            CodegenExpressionInstanceField mType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(resultEventType, EPStatementInitServicesConstants.REF));
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                this.GetType(),
                codegenClassScope);
            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block.DeclareVar<IDictionary<string, object>>(
                "tuple", NewInstance(typeof(HashMap<string, object>)));
            for (int i = 0; i < streamNames.Length; i++) {
                methodNode.Block.Expression(
                    ExprDotMethod(Ref("tuple"), "Put", Constant(streamNames[i]), ArrayAtIndex(refEPS, Constant(i))));
            }

            methodNode.Block.MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedMap", Ref("tuple"), mType));
            return methodNode;
        }
예제 #8
0
 public static CodegenExpression ReadNullable(
     CodegenExpressionInstanceField serde,
     CodegenExpressionRef input,
     CodegenExpressionRef unitKey,
     CodegenClassScope classScope)
 {
     return ExprDotMethod(serde, "Read", input, unitKey);
 }
예제 #9
0
        public override void GetValueCodegen(
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            method.Block
                .IfCondition(EqualsIdentity(cnt, Constant(0)))
                .BlockReturn(ConstantNull());

            // Optional match context comes into play for floating point numerics
            CodegenExpressionInstanceField mathContext = null;
            if (_factoryMethodAvg.OptionalMathContext != null) {
                mathContext = classScope.AddOrGetDefaultFieldSharable(
                    new MathContextCodegenField(_factoryMethodAvg.OptionalMathContext));
            }

            var sumTypeBoxed = sumType.GetBoxedType();
            if (sumTypeBoxed == typeof(decimal?)) {
                if (mathContext == null) {
                    method.Block.MethodReturn(Op(sum, "/", cnt));
                }
                else {
                    method.Block.MethodReturn(
                        StaticMethod(
                            typeof(MathContextExtensions),
                            "GetValueDivide",
                            mathContext,
                            sum,
                            cnt));
                }
            }
            else if (sumTypeBoxed == typeof(double?)) {
                if (mathContext == null) {
                    method.Block.MethodReturn(Op(sum, "/", cnt));
                }
                else {
                    method.Block.MethodReturn(
                        StaticMethod(
                            typeof(MathContextExtensions),
                            "GetValueDivide",
                            mathContext,
                            sum,
                            cnt));
                }
            }
            else if (mathContext == null) {
                method.Block.MethodReturn(Op(sum, "/", Cast<double>(cnt)));
            }
            else {
                method.Block.MethodReturn(
                    StaticMethod(
                        typeof(MathContextExtensions),
                        "GetValueDivide",
                        mathContext,
                        sum,
                        Cast<double>(cnt)));
            }
        }
예제 #10
0
 public static CodegenExpression WriteNullable(
     CodegenExpression value,
     CodegenExpressionInstanceField serde,
     CodegenExpressionRef output,
     CodegenExpressionRef unitKey,
     CodegenExpressionRef writer,
     CodegenClassScope classScope)
 {
     return ExprDotMethod(serde, "Write", value, output, unitKey, writer);
 }
예제 #11
0
        public AggregatorAccessSortedImpl(
            bool join,
            AggregationStateSortedForge forge,
            int col,
            CodegenCtor ctor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            ExprNode optionalFilter)
            : base(optionalFilter)
        {
            this.forge = forge;
            sorted     = membersColumnized.AddMember(col, typeof(IOrderedDictionary <object, object>), "sorted");
            size       = membersColumnized.AddMember(col, typeof(int), "size");
            var types = ExprNodeUtilityQuery.GetExprResultTypes(forge.Spec.Criteria);

            comparator = classScope.AddOrGetDefaultFieldSharable(
                new CodegenFieldSharableComparator(
                    COMPARATORHASHABLEMULTIKEYS,
                    types,
                    forge.Spec.IsSortUsingCollator,
                    forge.Spec.SortDescending));
            ctor.Block.AssignRef(sorted, NewInstance <OrderedListDictionary <object, object> >(comparator));

            sortedSerde = classScope.AddOrGetDefaultFieldSharable(
                new ProxyCodegenFieldSharable()
            {
                ProcType = () => { return(typeof(DIOSerdeTreeMapEventsMayDeque)); },

                ProcInitCtorScoped = () => {
                    var type = EventTypeUtility
                               .ResolveTypeCodegen(forge.Spec.StreamEventType, EPStatementInitServicesConstants.REF);
                    var criteriaSerdes = DataInputOutputSerdeForgeExtensions
                                         .CodegenArray(forge.Spec.CriteriaSerdes, classScope.NamespaceScope.InitMethod, classScope, null);
                    return(ExprDotMethodChain(EPStatementInitServicesConstants.REF)
                           .Get(EPStatementInitServicesConstants.EVENTTYPERESOLVER)
                           .Add(EventTypeResolverConstants.GETEVENTSERDEFACTORY)
                           .Add("TreeMapEventsMayDeque", criteriaSerdes, type));
                },
            });

            if (join)
            {
                joinRefs = membersColumnized.AddMember(col, typeof(RefCountedSetAtomicInteger <object>), "refs");
                ctor.Block.AssignRef(joinRefs, NewInstance(typeof(RefCountedSetAtomicInteger <object>)));
                joinRefsSerde = classScope.AddOrGetDefaultFieldSharable(
                    new CodegenSharableSerdeEventTyped(
                        REFCOUNTEDSETATOMICINTEGER, forge.Spec.StreamEventType));
            }
            else
            {
                joinRefs      = null;
                joinRefsSerde = null;
            }
        }
예제 #12
0
        public AggregatorAccessSortedImpl(
            bool join,
            AggregationStateSortedForge forge,
            int col,
            CodegenCtor ctor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            ExprNode optionalFilter)
            : base(optionalFilter)

        {
            this.forge = forge;
            sorted = membersColumnized.AddMember(col, typeof(OrderedDictionary<object,object>), "sorted");
            size = membersColumnized.AddMember(col, typeof(int), "size");
            var types = ExprNodeUtilityQuery.GetExprResultTypes(forge.Spec.Criteria);
            comparator = classScope.AddOrGetDefaultFieldSharable(
                new CodegenFieldSharableComparator(
                    COMPARATORHASHABLEMULTIKEYS,
                    types,
                    forge.Spec.IsSortUsingCollator,
                    forge.Spec.SortDescending));
            ctor.Block.AssignRef(sorted, NewInstance(typeof(OrderedDictionary<object, object>), comparator));

            sortedSerde = classScope.AddOrGetDefaultFieldSharable(
                new ProxyCodegenFieldSharable {
                    ProcType = () => { return typeof(DIOSerdeTreeMapEventsMayDeque); },
                    ProcInitCtorScoped = () => {
                        var type = EventTypeUtility.ResolveTypeCodegen(
                            forge.Spec.StreamEventType,
                            EPStatementInitServicesConstants.REF);
                        return ExprDotMethodChain(EPStatementInitServicesConstants.REF)
                            .Get(EPStatementInitServicesConstants.DATAINPUTOUTPUTSERDEPROVIDER)
                            .Add(
                                "TreeMapEventsMayDeque",
                                Constant(forge.Spec.CriteriaTypes),
                                type);
                    }
                });

            if (join) {
                joinRefs = membersColumnized.AddMember(col, typeof(RefCountedSetAtomicInteger<object>), "refs");
                ctor.Block.AssignRef(joinRefs, NewInstance(typeof(RefCountedSetAtomicInteger<object>)));
                joinRefsSerde = classScope.AddOrGetDefaultFieldSharable(
                    new CodegenSharableSerdeEventTyped(REFCOUNTEDSETATOMICINTEGER, forge.Spec.StreamEventType));
            }
            else {
                joinRefs = null;
                joinRefsSerde = null;
            }
        }
예제 #13
0
 public AggregatorAccessCountMinSketch(
     AggregationStateCountMinSketchForge forge,
     int col,
     CodegenCtor rowCtor,
     CodegenMemberCol membersColumnized,
     CodegenClassScope classScope)
 {
     this.forge = forge;
     state = membersColumnized.AddMember(col, typeof(CountMinSketchAggState), "state");
     spec = classScope.NamespaceScope.AddDefaultFieldUnshared(
         true,
         typeof(CountMinSketchSpec),
         forge.specification.CodegenMake(classScope.NamespaceScope.InitMethod, classScope));
     rowCtor.Block.AssignRef(state, ExprDotMethod(spec, "MakeAggState"));
 }
예제 #14
0
        public override CodegenExpression EvaluateCodegen(
            CodegenMethodScope parent,
            ExprSubselectEvalMatchSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenExpressionInstanceField eventToPublic =
                TableDeployTimeResolver.MakeTableEventToPublicField(table, classScope, this.GetType());
            CodegenMethod method = parent.MakeChild(subselect.EvaluationType, this.GetType(), classScope);

            method.Block.ApplyTri(DECLARE_EVENTS_SHIFTED, method, symbols);

            method.Block.DeclareVar<EventBean>("filtered", ConstantNull());
            CodegenBlock @foreach = method.Block.ForEach(
                typeof(EventBean),
                "@event",
                symbols.GetAddMatchingEvents(method));
            {
                @foreach.AssignArrayElement(REF_EVENTS_SHIFTED, Constant(0), Ref("@event"));
                CodegenMethod filter = CodegenLegoMethodExpression.CodegenExpression(subselect.FilterExpr, method, classScope, true);
                CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                    @foreach,
                    typeof(bool?),
                    LocalMethod(
                        filter,
                        REF_EVENTS_SHIFTED,
                        symbols.GetAddIsNewData(method),
                        symbols.GetAddExprEvalCtx(method)));
                @foreach.IfCondition(NotEqualsNull(Ref("filtered")))
                    .BlockReturn(ConstantNull())
                    .AssignRef("filtered", Ref("@event"));
            }

            method.Block.IfRefNullReturnNull("filtered")
                .MethodReturn(
                    ExprDotMethod(
                        eventToPublic,
                        "ConvertToUnd",
                        Ref("filtered"),
                        symbols.GetAddEPS(method),
                        symbols.GetAddIsNewData(method),
                        symbols.GetAddExprEvalCtx(method)));
            return LocalMethod(method);
        }
예제 #15
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(tableMetadata, codegenClassScope, this.GetType());
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(BindProcessorStreamTable),
         "EvaluateConvertTableEventToUnd",
         Constant(streamNum),
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
예제 #16
0
 public CodegenExpression EvaluateCodegenUninstrumented(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionRef refEps = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(_tableMetadata, codegenClassScope, this.GetType());
     return StaticMethod(
         typeof(ExprEvalStreamInsertTable),
         "ConvertToTableEvent",
         Constant(_streamNum),
         eventToPublic,
         refEps,
         refIsNewData,
         refExprEvalCtx);
 }
예제 #17
0
 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));
 }
예제 #18
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));
 }
예제 #19
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, codegenClassScope, this.GetType());
     CodegenMethod methodNode = codegenMethodScope.MakeChild(
         typeof(EventBean),
         this.GetType(),
         codegenClassScope);
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);
     methodNode.Block
         .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(0)))
         .IfRefNullReturnNull("@event")
         .MethodReturn(
             ExprDotMethod(eventToPublic, "Convert", Ref("@event"), refEPS, refIsNewData, refExprEvalCtx));
     return methodNode;
 }