private void GetterCodegen(
            string methodName,
            CodegenMethod method,
            CodegenClassScope classScope,
            CodegenNamedMethods namedMethods)
        {
            var rowLevelDesc = RowLevelDesc;

            var blocks = method.Block.SwitchBlockOfLength(
                AggregationServiceCodegenNames.REF_COLUMN,
                localGroupByPlan.ColumnsForges.Length,
                true);
            for (var i = 0; i < blocks.Length; i++) {
                AggregationLocalGroupByColumnForge col = localGroupByPlan.ColumnsForges[i];

                if (hasGroupBy && col.IsDefaultGroupLevel) {
                    AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalAdditionalRows[col.LevelNum];
                    var num = GetRowFieldNum(col, levelDesc);
                    blocks[i]
                        .BlockReturn(
                            ExprDotMethod(
                                MEMBER_CURRENTROW,
                                methodName,
                                Constant(num),
                                REF_EPS,
                                REF_ISNEWDATA,
                                REF_EXPREVALCONTEXT));
                }
                else if (col.LevelNum == -1) {
                    AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalTopRow;
                    var num = GetRowFieldNum(col, levelDesc);
                    blocks[i]
                        .BlockReturn(
                            ExprDotMethod(
                                MEMBER_AGGREGATORSTOPLEVEL,
                                methodName,
                                Constant(num),
                                REF_EPS,
                                REF_ISNEWDATA,
                                REF_EXPREVALCONTEXT));
                }
                else {
                    AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalAdditionalRows[col.LevelNum];
                    var num = GetRowFieldNum(col, levelDesc);
                    blocks[i]
                        .DeclareVar<object>(
                            "groupByKey",
                            LocalMethod(
                                AggregationServiceCodegenUtil.ComputeMultiKeyCodegen(
                                    col.LevelNum,
                                    col.PartitionForges,
                                    levelDesc.MultiKeyClassRef,
                                    classScope,
                                    namedMethods),
                                REF_EPS,
                                REF_ISNEWDATA,
                                REF_EXPREVALCONTEXT))
                        .DeclareVar<AggregationRow>(
                            "row",
                            Cast(
                                typeof(AggregationRow),
                                ExprDotMethod(
                                    ArrayAtIndex(MEMBER_AGGREGATORSPERLEVELANDGROUP, Constant(col.LevelNum)),
                                    "Get",
                                    Ref("groupByKey"))))
                        .BlockReturn(
                            ExprDotMethod(
                                Ref("row"),
                                methodName,
                                Constant(num),
                                REF_EPS,
                                REF_ISNEWDATA,
                                REF_EXPREVALCONTEXT));
                }
            }
        }
        private void ApplyCodegen(
            bool enter,
            CodegenMethod method,
            CodegenClassScope classScope,
            CodegenNamedMethods namedMethods,
            AggregationClassNames classNames)
        {
            if (enter) {
                method.Block.LocalMethod(HandleRemovedKeysCodegen(method, classScope));
            }

            if (localGroupByPlan.OptionalLevelTopForge != null) {
                method.Block.IfCondition(EqualsNull(MEMBER_AGGREGATORSTOPLEVEL))
                    .AssignRef(MEMBER_AGGREGATORSTOPLEVEL, NewInstanceInner(classNames.RowTop, Ref("o")))
                    .BlockEnd()
                    .ExprDotMethod(
                        MEMBER_AGGREGATORSTOPLEVEL,
                        enter ? "ApplyEnter" : "ApplyLeave",
                        REF_EPS,
                        REF_EXPREVALCONTEXT);
            }

            for (var levelNum = 0; levelNum < localGroupByPlan.AllLevelsForges.Length; levelNum++) {
                AggregationLocalGroupByLevelForge level = localGroupByPlan.AllLevelsForges[levelNum];
                ExprNode[] partitionForges = level.PartitionForges;

                var groupKeyName = "groupKeyLvl_" + levelNum;
                var rowName = "row_" + levelNum;
                CodegenExpression groupKeyExp;
                if (hasGroupBy && level.IsDefaultLevel) {
                    groupKeyExp = AggregationServiceCodegenNames.REF_GROUPKEY;
                }
                else {
                    groupKeyExp = LocalMethod(
                        AggregationServiceCodegenUtil.ComputeMultiKeyCodegen(
                            levelNum,
                            partitionForges,
                            level.PartitionMKClasses,
                            classScope,
                            namedMethods),
                        REF_EPS,
                        ConstantTrue(),
                        REF_EXPREVALCONTEXT);
                }

                method.Block.CommentFullLine("--about to declare var--");

                method.Block
                    .DeclareVar<object>(groupKeyName, groupKeyExp)
                    .DeclareVar<AggregationRow>(
                        rowName,
                        Cast(
                            typeof(AggregationRow),
                            ExprDotMethod(
                                ArrayAtIndex(MEMBER_AGGREGATORSPERLEVELANDGROUP, Constant(levelNum)),
                                "Get",
                                Ref(groupKeyName))))
                    .IfCondition(EqualsNull(Ref(rowName)))
                    .AssignRef(rowName, NewInstanceInner(classNames.GetRowPerLevel(levelNum), Ref("o")))
                    .ExprDotMethod(
                        ArrayAtIndex(MEMBER_AGGREGATORSPERLEVELANDGROUP, Constant(levelNum)),
                        "Put",
                        Ref(groupKeyName),
                        Ref(rowName))
                    .BlockEnd()
                    .ExprDotMethod(Ref(rowName), enter ? "IncreaseRefcount" : "DecreaseRefcount")
                    .ExprDotMethod(Ref(rowName), enter ? "ApplyEnter" : "ApplyLeave", REF_EPS, REF_EXPREVALCONTEXT);

                if (!enter) {
                    method.Block.IfCondition(Relational(ExprDotMethod(Ref(rowName), "GetRefcount"), LE, Constant(0)))
                        .ExprDotMethod(
                            MEMBER_REMOVEDKEYS,
                            "Add",
                            NewInstance<AggSvcLocalGroupLevelKeyPair>(Constant(levelNum), Ref(groupKeyName)));
                }
            }
        }