Пример #1
0
            public Cursor(PerGroupTransformBase <TLabel, TScore, TState> parent, DataViewRowCursor input, DataViewRowCursor groupCursor, bool[] active)
                : base(parent.Host)
            {
                Ch.AssertValue(parent);
                // REVIEW: Try to see if we can relax this requirement in case there are no
                // active columns from the input (that are not required for output computation).
                Ch.AssertValue(input);
                Ch.AssertValue(groupCursor);
                Ch.AssertValue(active);

                _parent      = parent;
                _input       = input;
                _groupCursor = groupCursor;
                _active      = active;

                _state = _parent.InitializeState(_input);

                var bindings = _parent.GetBindings();

                _getters = _parent.CreateGetters(_state, iinfo => active[bindings.MapIinfoToCol(iinfo)]);

                _newGroupInGroupCursorDel = RowCursorUtils.GetIsNewGroupDelegate(_groupCursor, bindings.GroupIndex);
                _newGroupInInputCursorDel = RowCursorUtils.GetIsNewGroupDelegate(_input, bindings.GroupIndex);
                _labelGetter = _parent.GetLabelGetter(_groupCursor);
                _scoreGetter = _parent.GetScoreGetter(_groupCursor);
            }
Пример #2
0
            internal override void InitializeNextPass(DataViewRow row, RoleMappedSchema schema)
            {
                Contracts.Assert(PassNum < 1);
                Contracts.Assert(schema.Label.HasValue);
                Contracts.Assert(schema.Group.HasValue);

                var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);

                _labelGetter = RowCursorUtils.GetLabelGetter(row, schema.Label.Value.Index);
                _scoreGetter = row.GetGetter <Single>(score);
                _newGroupDel = RowCursorUtils.GetIsNewGroupDelegate(row, schema.Group.Value.Index);
                if (schema.Weight.HasValue)
                {
                    _weightGetter = row.GetGetter <Single>(schema.Weight.Value);
                }

                if (UnweightedCounters.GroupSummary)
                {
                    ValueGetter <StringBuilder> groupIdBuilder = RowCursorUtils.GetGetterAsStringBuilder(row, schema.Group.Value.Index);
                    _groupSbUpdate = () => groupIdBuilder(ref _groupSb);
                }
                else
                {
                    _groupSbUpdate = () => { }
                };
            }