protected override Delegate[] CreateGetters(IRow input, Func<int, bool> active, out Action disp) { Func<int, bool> activeInfos = iinfo => { int col = _bindings.MapIinfoToCol(iinfo); return active(col); }; disp = null; var getters = new Delegate[_bindings.InfoCount]; var groupCurHelpers = new GroupCursorHelper[_bindings.SrcColsCount]; var resourcesExist = new bool?[Tokenizers.Length]; for (int iinfo = 0; iinfo < _bindings.Infos.Length; iinfo++) { if (!activeInfos(iinfo)) continue; int groupId = _bindings.Infos[iinfo].GroupInfoId; if (groupCurHelpers[groupId] == null) groupCurHelpers[groupId] = new GroupCursorHelper(input, _bindings.GroupInfos[groupId], resourcesExist); var groupState = groupCurHelpers[groupId]; ValueGetter<VBuffer<DvText>> fn; if (_bindings.Infos[iinfo].IsTypes) fn = (ref VBuffer<DvText> dst) => groupState.GetTypes(ref dst); else fn = (ref VBuffer<DvText> dst) => groupState.GetTokens(ref dst); getters[iinfo] = fn; } return getters; }
public RowCursor(NltTokenizeTransform parent, IRowCursor input, bool[] active) : base(parent.Host, input) { Ch.AssertValue(parent._bindings); Ch.AssertNonEmpty(parent._bindings.Infos); Ch.AssertNonEmpty(parent._bindings.GroupInfos); Ch.Assert(active == null || active.Length == parent._bindings.ColumnCount); _bindings = parent._bindings; _active = active; var resourcesExist = new bool?[Tokenizers.Length]; var infos = parent._bindings.Infos; _getters = new ValueGetter<VBuffer<DvText>>[infos.Length]; var groupCurHelpers = new GroupCursorHelper[_bindings.SrcColsCount]; for (int iinfo = 0; iinfo < infos.Length; iinfo++) { if (_active != null && !_active[_bindings.MapIinfoToCol(iinfo)]) continue; int groupId = infos[iinfo].GroupInfoId; if (groupCurHelpers[groupId] == null) groupCurHelpers[groupId] = new GroupCursorHelper(input, _bindings.GroupInfos[groupId], resourcesExist); var groupState = groupCurHelpers[groupId]; if (infos[iinfo].IsTypes) _getters[iinfo] = groupState.GetTypes; else _getters[iinfo] = groupState.GetTokens; } }