protected override bool MoveNextCore() { Ch.AssertValue(_currentCursor); while (!_currentCursor.MoveNext()) { // Mark the current cursor as finished. _currentCursor.Dispose(); _currentCursor = null; if (++_currentSourceIndex >= Sources.Length) { return(false); } var columnsNeeded = Schema.Where(col => IsColumnActive(col.Index)); _currentCursor = Sources[_currentSourceIndex].GetRowCursor(columnsNeeded); _currentIdGetter = _currentCursor.GetIdGetter(); } return(true); }
public sealed override RowCursor[] GetRowCursorSet(Func <int, bool> predicate, int n, Random rand = null) { Host.CheckValue(predicate, nameof(predicate)); Host.CheckValueOrNull(rand); var inputPred = _bindings.GetDependencies(predicate); var active = _bindings.GetActive(predicate); var inputs = Source.GetRowCursorSet(inputPred, n, rand); Host.AssertNonEmpty(inputs); // No need to split if this is given 1 input cursor. var cursors = new RowCursor[inputs.Length]; for (int i = 0; i < inputs.Length; i++) { cursors[i] = new Cursor(Host, _bindings, inputs[i], active); } return(cursors); }
public override RowCursor[] GetRowCursorSet(IEnumerable <Schema.Column> columnsNeeded, int n, Random rand = null) { Host.CheckValueOrNull(rand); var predicate = RowCursorUtils.FromColumnsToPredicate(columnsNeeded, OutputSchema); bool[] active; Func <int, bool> inputPred = GetActive(predicate, out active); var inputCols = Source.Schema.Where(x => inputPred(x.Index)); var inputs = Source.GetRowCursorSet(inputCols, n, rand); Host.AssertNonEmpty(inputs); // No need to split if this is given 1 input cursor. var cursors = new RowCursor[inputs.Length]; for (int i = 0; i < inputs.Length; i++) { cursors[i] = new Cursor(this, inputs[i], active); } return(cursors); }
public Cursor(Impl <T1, T2> parent, RowCursor input, bool[] active) : base(parent.Host, input, parent.OutputSchema, active) { _getSrc = Input.GetGetter <T1>(parent._colSrc); if (parent._conv == null) { Ch.Assert(typeof(T1) == typeof(T2)); _pred = (InPredicate <T1>)(Delegate) parent._pred; } else { T2 val = default(T2); var pred = parent._pred; var conv = parent._conv; _pred = (in T1 src) => { conv(in _src, ref val); return(pred(in val)); }; } }
public Cursor(IChannelProvider provider, OneToOneTransformBase parent, RowCursor input, bool[] active) : base(provider, input) { Ch.AssertValue(parent); Ch.Assert(active == null || active.Length == parent._bindings.ColumnCount); _bindings = parent._bindings; _active = active; _getters = new Delegate[parent.Infos.Length]; // Build the disposing delegate. Action masterDisposer = null; for (int iinfo = 0; iinfo < _getters.Length; iinfo++) { if (!IsColumnActive(parent._bindings.MapIinfoToCol(iinfo))) continue; _getters[iinfo] = parent.GetGetterCore(Ch, Input, iinfo, out Action disposer); if (disposer != null) masterDisposer += disposer; } _disposer = masterDisposer; }
public sealed override RowCursor[] GetRowCursorSet(IEnumerable<Schema.Column> columnsNeeded, int n, Random rand = null) { Host.CheckValueOrNull(rand); var predicate = RowCursorUtils.FromColumnsToPredicate(columnsNeeded, OutputSchema); var inputPred = _bindings.GetDependencies(predicate); var active = _bindings.GetActive(predicate); var inputCols = Source.Schema.Where(x => inputPred(x.Index)); var inputs = Source.GetRowCursorSet(inputCols, n, rand); Host.AssertNonEmpty(inputs); if (inputs.Length == 1 && n > 1 && WantParallelCursors(predicate)) inputs = DataViewUtils.CreateSplitCursors(Host, inputs[0], n); Host.AssertNonEmpty(inputs); var cursors = new RowCursor[inputs.Length]; for (int i = 0; i < inputs.Length; i++) cursors[i] = new Cursor(Host, this, inputs[i], active); return cursors; }
public Cursor(IChannelProvider provider, RowToRowScorerBase parent, RowCursor input, bool[] active, Func <int, bool> predicateMapper) : base(provider, input) { Ch.AssertValue(parent); Ch.AssertValue(active); Ch.AssertValue(predicateMapper); _bindings = parent.GetBindings(); Schema = parent.OutputSchema; Ch.Assert(active.Length == _bindings.ColumnCount); _active = active; _output = _bindings.RowMapper.GetRow(input, predicateMapper); try { Ch.Assert(_output.Schema == _bindings.RowMapper.OutputSchema); _getters = parent.GetGetters(_output, iinfo => active[_bindings.MapIinfoToCol(iinfo)]); } catch (Exception) { _output.Dispose(); throw; } }
protected LinkedRowFilterCursorBase(IChannelProvider provider, RowCursor input, Schema schema, bool[] active) : base(provider, input, schema, active) { }
public Cursor(PerGroupTransformBase <TLabel, TScore, TState> parent, RowCursor input, RowCursor 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); }