protected internal static void ApplyViewResultUnboundCodegen(
            ResultSetProcessorRowPerGroupRollupForge forge,
            CodegenClassScope classScope,
            CodegenMethod method,
            CodegenInstanceAux instance)
        {
            var generateGroupKeysView = GenerateGroupKeysViewCodegen(forge, classScope, instance);

            method.Block
                .DeclareVar<object[][]>(
                    "newDataMultiKey",
                    LocalMethod(
                        generateGroupKeysView,
                        REF_NEWDATA,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantTrue()))
                .DeclareVar<object[][]>(
                    "oldDataMultiKey",
                    LocalMethod(
                        generateGroupKeysView,
                        REF_OLDDATA,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantFalse()))
                .DeclareVar<EventBean[]>("eventsPerStream", NewArrayByLength(typeof(EventBean), Constant(1)))
                .StaticMethod(
                    typeof(ResultSetProcessorGroupedUtil),
                    METHOD_APPLYAGGVIEWRESULTKEYEDVIEW,
                    MEMBER_AGGREGATIONSVC,
                    MEMBER_AGENTINSTANCECONTEXT,
                    REF_NEWDATA,
                    Ref("newDataMultiKey"),
                    REF_OLDDATA,
                    Ref("oldDataMultiKey"),
                    Ref("eventsPerStream"));
        }
 protected internal static void StopMethodUnboundCodegen(
     ResultSetProcessorRowPerGroupRollupForge forge,
     CodegenClassScope classScope,
     CodegenMethod method,
     CodegenInstanceAux instance)
 {
     StopMethodCodegenBound(method, instance);
     method.Block.ExprDotMethod(Ref(NAME_UNBOUNDHELPER), "Destroy");
 }
        public static void GetEnumeratorViewUnboundCodegen(
            ResultSetProcessorRowPerGroupRollupForge forge,
            CodegenClassScope classScope,
            CodegenMethod method,
            CodegenInstanceAux instance)
        {
            var generateOutputEventsView = GenerateOutputEventsViewCodegen(forge, classScope, instance);

            method.Block.DeclareVar<EventBean[]>(
                    "output",
                    LocalMethod(
                        generateOutputEventsView,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantTrue(),
                        ConstantTrue()))
                .MethodReturn(StaticMethod(typeof(Arrays), "GetEnumerator", Ref("output")));
        }
        protected internal static void ProcessViewResultUnboundCodegen(
            ResultSetProcessorRowPerGroupRollupForge forge,
            CodegenClassScope classScope,
            CodegenMethod method,
            CodegenInstanceAux instance)
        {
            var factory = classScope.AddOrGetDefaultFieldSharable(ResultSetProcessorHelperFactoryField.INSTANCE);
            CodegenExpression eventTypes = classScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType[]),
                EventTypeUtility.ResolveTypeArrayCodegen(forge.EventTypes, EPStatementInitServicesConstants.REF));
            instance.AddMember(NAME_UNBOUNDHELPER, typeof(ResultSetProcessorRowPerGroupRollupUnboundHelper));
            instance.ServiceCtor.Block.AssignRef(
                NAME_UNBOUNDHELPER,
                ExprDotMethod(
                    factory,
                    "MakeRSRowPerGroupRollupSnapshotUnbound",
                    MEMBER_AGENTINSTANCECONTEXT,
                    Ref("this"),
                    Constant(forge.GroupKeyTypes),
                    Constant(forge.NumStreams),
                    eventTypes));

            var generateGroupKeysView = GenerateGroupKeysViewCodegen(forge, classScope, instance);
            var generateOutputEventsView = GenerateOutputEventsViewCodegen(forge, classScope, instance);

            method.Block
                .DeclareVar<object[][]>(
                    "newDataMultiKey",
                    LocalMethod(
                        generateGroupKeysView,
                        REF_NEWDATA,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantTrue()))
                .DeclareVar<object[][]>(
                    "oldDataMultiKey",
                    LocalMethod(
                        generateGroupKeysView,
                        REF_OLDDATA,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantFalse()))
                .DeclareVar<EventBean[]>(
                    "selectOldEvents",
                    forge.IsSelectRStream
                        ? LocalMethod(
                            generateOutputEventsView,
                            ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                            ConstantFalse(),
                            REF_ISSYNTHESIZE)
                        : ConstantNull())
                .DeclareVar<EventBean[]>("eventsPerStream", NewArrayByLength(typeof(EventBean), Constant(1)))
                .StaticMethod(
                    typeof(ResultSetProcessorGroupedUtil),
                    METHOD_APPLYAGGVIEWRESULTKEYEDVIEW,
                    MEMBER_AGGREGATIONSVC,
                    MEMBER_AGENTINSTANCECONTEXT,
                    REF_NEWDATA,
                    Ref("newDataMultiKey"),
                    REF_OLDDATA,
                    Ref("oldDataMultiKey"),
                    Ref("eventsPerStream"))
                .DeclareVar<EventBean[]>(
                    "selectNewEvents",
                    LocalMethod(
                        generateOutputEventsView,
                        ExprDotName(Ref(NAME_UNBOUNDHELPER), "Buffer"),
                        ConstantTrue(),
                        REF_ISSYNTHESIZE))
                .MethodReturn(
                    StaticMethod(
                        typeof(ResultSetProcessorUtil),
                        METHOD_TOPAIRNULLIFALLNULL,
                        Ref("selectNewEvents"),
                        Ref("selectOldEvents")));
        }