public static Value Create(RowCursor cursor, ColInfo info) { Contracts.AssertValue(cursor); Contracts.AssertValue(info); MethodInfo meth; if (!info.Type.IsVector) { Func <RowCursor, ColInfo, ValueOne <int> > d = CreateOne <int>; meth = d.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(info.Type.RawType); } else { Func <RowCursor, ColInfo, ValueVec <int> > d = CreateVec <int>; meth = d.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(info.Type.ItemType.RawType); } return((Value)meth.Invoke(null, new object[] { cursor, info })); }
public override RowCursor[] GetRowCursorSet(Func <int, bool> predicate, int n, Random rand = null) { Host.CheckValue(predicate, nameof(predicate)); Host.CheckValueOrNull(rand); bool[] active; Func <int, bool> inputPred = GetActive(predicate, out active); 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(this, inputs[i], active); } return(cursors); }
public sealed override IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator, Func <int, bool> predicate, int n, IRandom rand = null) { Host.CheckValue(predicate, nameof(predicate)); Host.CheckValueOrNull(rand); var inputPred = _bindings.GetDependencies(predicate); var active = _bindings.GetActive(predicate); var inputs = Source.GetRowCursorSet(out consolidator, inputPred, n, rand); Host.AssertNonEmpty(inputs); // No need to split if this is given 1 input cursor. var cursors = new IRowCursor[inputs.Length]; for (int i = 0; i < inputs.Length; i++) { cursors[i] = new RowCursor(Host, _bindings, inputs[i], active); } return(cursors); }
public override IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator, Func<int, bool> predicate, int n, Random rand = null) { Host.CheckValue(predicate, nameof(predicate)); Host.CheckValueOrNull(rand); var bindings = GetBindings(); Func<int, bool> predicateInput; Func<int, bool> predicateMapper; var active = GetActive(bindings, predicate, out predicateInput, out predicateMapper); var inputs = Source.GetRowCursorSet(out consolidator, predicateInput, n, rand); Contracts.AssertNonEmpty(inputs); if (inputs.Length == 1 && n > 1 && WantParallelCursors(predicate) && (Source.GetRowCount() ?? int.MaxValue) > n) inputs = DataViewUtils.CreateSplitCursors(out consolidator, Host, inputs[0], n); Contracts.AssertNonEmpty(inputs); var cursors = new IRowCursor[inputs.Length]; for (int i = 0; i < inputs.Length; i++) cursors[i] = new RowCursor(Host, this, inputs[i], active, predicateMapper); 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, 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; } }
public ValueVec(RowCursor cursor, ValueGetter <VBuffer <T> > getSrc, RefPredicate <VBuffer <T> > hasBad) : base(cursor, getSrc, hasBad) { _getter = GetValue; }
public ValueOne(RowCursor cursor, ValueGetter <T> getSrc, RefPredicate <T> hasBad) : base(cursor, getSrc, hasBad) { _getter = GetValue; }
protected Value(RowCursor cursor) { Contracts.AssertValue(cursor); Cursor = cursor; }
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); }