protected override bool MoveNextCore() { Ch.Assert(Position < _view._rowCount); return(1 < _view._rowCount - Position); }
protected override void ProcessValue(ref TItem val, int slot) { Ch.Assert(0 <= slot && slot < Stat.Length); _valuesProcessed[slot]++; ProcValueDelegate(ref val, slot); }
protected override void ProcessValue(ref Double val, int slot) { Ch.Assert(0 <= slot && slot < Stat.Length); Stat[slot].Update(val); }
private Delegate CreateGetterDelegate <TValue>(int col) { Delegate getterDelegate; var colInfo = _bindings.Infos[col]; Ch.Assert(colInfo.ColType.RawType == typeof(TValue)); if (typeof(TValue) == typeof(bool)) { getterDelegate = CreateBooleanGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(byte)) { getterDelegate = CreateByteGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(DateTime)) { getterDelegate = CreateDateTimeGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(double)) { getterDelegate = CreateDoubleGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(short)) { getterDelegate = CreateInt16GetterDelegate(colInfo); } else if (typeof(TValue) == typeof(int)) { getterDelegate = CreateInt32GetterDelegate(colInfo); } else if (typeof(TValue) == typeof(long)) { getterDelegate = CreateInt64GetterDelegate(colInfo); } else if (typeof(TValue) == typeof(sbyte)) { getterDelegate = CreateSByteGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(float)) { getterDelegate = CreateSingleGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(ReadOnlyMemory <char>)) { getterDelegate = CreateStringGetterDelegate(colInfo); } else if (typeof(TValue) == typeof(ushort)) { getterDelegate = CreateUInt16GetterDelegate(colInfo); } else if (typeof(TValue) == typeof(uint)) { getterDelegate = CreateUInt32GetterDelegate(colInfo); } else if (typeof(TValue) == typeof(ulong)) { getterDelegate = CreateUInt64GetterDelegate(colInfo); } else { throw new NotSupportedException(); } return(getterDelegate as ValueGetter <TValue>); }
public Cursor(SequentialTransformBase <TInput, TOutput, TState> parent, IRowCursor input) : base(parent.Host, input) { Ch.Assert(input.Schema.ColumnCount == parent.Schema.ColumnCount); _parent = parent; }
protected override bool MoveManyCore(long count) { Ch.Assert(State != CursorState.Done); Ch.Assert(Position < _data.Count); return(count < _data.Count - Position); }
protected override Delegate GetGetter() { Ch.Assert(Parent._type == NumberType.R8); return(_getter); }
protected override bool MoveNextCore() { Ch.Assert(State != CursorState.Done); Ch.Assert(Position < _view._rowCount); return(1 < _view._rowCount - Position); }
protected override bool MoveManyCore(long count) { Ch.Assert(State != CursorState.Done); return(true); }
private bool IsIndexActive(int iinfo) { Ch.Assert(0 <= iinfo & iinfo < _bindings.Infos.Length); return(_active == null || _active[_bindings.MapIinfoToCol(iinfo)]); }
private ValueGetter <T> GetSrcGetter <T>(int iinfo, int isrc) { Ch.Assert(IsIndexActive(iinfo)); return(Input.GetGetter <T>(_bindings.Infos[iinfo].SrcIndices[isrc])); }
protected override Delegate GetGetter() { Ch.Assert(Parent._type is KeyType); return(_getter); }
protected override bool Accept() { Ch.Assert(Parent._type == NumberDataViewType.Double); _srcGetter(ref _value); return(CheckBounds(_value)); }
protected override Delegate GetGetter() { Ch.Assert(Parent._type == NumberDataViewType.Double); return(_getter); }
private Delegate CreateGetter(int index) { var colType = DataView.Schema.GetColumnType(index); var column = DataView._schema.SchemaDefn.Columns[index]; var outputType = column.IsComputed ? column.ReturnType : column.FieldInfo.FieldType; var genericType = outputType; Func <int, Delegate> del; if (outputType.IsArray) { Ch.Assert(colType.IsVector); // String[] -> VBuffer<DvText> if (outputType.GetElementType() == typeof(string)) { Ch.Assert(colType.ItemType.IsText); return(CreateConvertingArrayGetterDelegate <String, DvText>(index, x => x == null ? DvText.NA : new DvText(x))); } else if (outputType.GetElementType() == typeof(int)) { Ch.Assert(colType.ItemType == NumberType.I4); return(CreateConvertingArrayGetterDelegate <int, DvInt4>(index, x => x)); } else if (outputType.GetElementType() == typeof(int?)) { Ch.Assert(colType.ItemType == NumberType.I4); return(CreateConvertingArrayGetterDelegate <int?, DvInt4>(index, x => x ?? DvInt4.NA)); } else if (outputType.GetElementType() == typeof(long)) { Ch.Assert(colType.ItemType == NumberType.I8); return(CreateConvertingArrayGetterDelegate <long, DvInt8>(index, x => x)); } else if (outputType.GetElementType() == typeof(long?)) { Ch.Assert(colType.ItemType == NumberType.I8); return(CreateConvertingArrayGetterDelegate <long?, DvInt8>(index, x => x ?? DvInt8.NA)); } else if (outputType.GetElementType() == typeof(short)) { Ch.Assert(colType.ItemType == NumberType.I2); return(CreateConvertingArrayGetterDelegate <short, DvInt2>(index, x => x)); } else if (outputType.GetElementType() == typeof(short?)) { Ch.Assert(colType.ItemType == NumberType.I2); return(CreateConvertingArrayGetterDelegate <short?, DvInt2>(index, x => x ?? DvInt2.NA)); } else if (outputType.GetElementType() == typeof(sbyte)) { Ch.Assert(colType.ItemType == NumberType.I1); return(CreateConvertingArrayGetterDelegate <sbyte, DvInt1>(index, x => x)); } else if (outputType.GetElementType() == typeof(sbyte?)) { Ch.Assert(colType.ItemType == NumberType.I1); return(CreateConvertingArrayGetterDelegate <sbyte?, DvInt1>(index, x => x ?? DvInt1.NA)); } else if (outputType.GetElementType() == typeof(bool)) { Ch.Assert(colType.ItemType.IsBool); return(CreateConvertingArrayGetterDelegate <bool, DvBool>(index, x => x)); } else if (outputType.GetElementType() == typeof(bool?)) { Ch.Assert(colType.ItemType.IsBool); return(CreateConvertingArrayGetterDelegate <bool?, DvBool>(index, x => x ?? DvBool.NA)); } // T[] -> VBuffer<T> if (outputType.GetElementType().IsGenericType&& outputType.GetElementType().GetGenericTypeDefinition() == typeof(Nullable <>)) { Ch.Assert(Nullable.GetUnderlyingType(outputType.GetElementType()) == colType.ItemType.RawType); } else { Ch.Assert(outputType.GetElementType() == colType.ItemType.RawType); } del = CreateDirectArrayGetterDelegate <int>; genericType = outputType.GetElementType(); } else if (colType.IsVector) { // VBuffer<T> -> VBuffer<T> // REVIEW: Do we care about accomodating VBuffer<string> -> VBuffer<DvText>? Ch.Assert(outputType.IsGenericType); Ch.Assert(outputType.GetGenericTypeDefinition() == typeof(VBuffer <>)); Ch.Assert(outputType.GetGenericArguments()[0] == colType.ItemType.RawType); del = CreateDirectVBufferGetterDelegate <int>; } else if (colType.IsPrimitive) { if (outputType == typeof(string)) { // String -> DvText Ch.Assert(colType.IsText); return(CreateConvertingGetterDelegate <String, DvText>(index, x => x == null ? DvText.NA : new DvText(x))); } else if (outputType == typeof(bool)) { // Bool -> DvBool Ch.Assert(colType.IsBool); return(CreateConvertingGetterDelegate <bool, DvBool>(index, x => x)); } else if (outputType == typeof(bool?)) { // Bool? -> DvBool Ch.Assert(colType.IsBool); return(CreateConvertingGetterDelegate <bool?, DvBool>(index, x => x ?? DvBool.NA)); } else if (outputType == typeof(int)) { // int -> DvInt4 Ch.Assert(colType == NumberType.I4); return(CreateConvertingGetterDelegate <int, DvInt4>(index, x => x)); } else if (outputType == typeof(int?)) { // int? -> DvInt4 Ch.Assert(colType == NumberType.I4); return(CreateConvertingGetterDelegate <int?, DvInt4>(index, x => x ?? DvInt4.NA)); } else if (outputType == typeof(short)) { // short -> DvInt2 Ch.Assert(colType == NumberType.I2); return(CreateConvertingGetterDelegate <short, DvInt2>(index, x => x)); } else if (outputType == typeof(short?)) { // short? -> DvInt2 Ch.Assert(colType == NumberType.I2); return(CreateConvertingGetterDelegate <short?, DvInt2>(index, x => x ?? DvInt2.NA)); } else if (outputType == typeof(long)) { // long -> DvInt8 Ch.Assert(colType == NumberType.I8); return(CreateConvertingGetterDelegate <long, DvInt8>(index, x => x)); } else if (outputType == typeof(long?)) { // long? -> DvInt8 Ch.Assert(colType == NumberType.I8); return(CreateConvertingGetterDelegate <long?, DvInt8>(index, x => x ?? DvInt8.NA)); } else if (outputType == typeof(sbyte)) { // sbyte -> DvInt1 Ch.Assert(colType == NumberType.I1); return(CreateConvertingGetterDelegate <sbyte, DvInt1>(index, x => x)); } else if (outputType == typeof(sbyte?)) { // sbyte? -> DvInt1 Ch.Assert(colType == NumberType.I1); return(CreateConvertingGetterDelegate <sbyte?, DvInt1>(index, x => x ?? DvInt1.NA)); } // T -> T if (outputType.IsGenericType && outputType.GetGenericTypeDefinition() == typeof(Nullable <>)) { Ch.Assert(colType.RawType == Nullable.GetUnderlyingType(outputType)); } else { Ch.Assert(colType.RawType == outputType); } del = CreateDirectGetterDelegate <int>; } else { // REVIEW: Is this even possible? throw Ch.ExceptNotImpl("Type '{0}' is not yet supported.", outputType.FullName); } MethodInfo meth = del.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(genericType); return((Delegate)meth.Invoke(this, new object[] { index })); }
public Cursor(IHost host, SequentialDataTransform parent, DataViewRowCursor input) : base(host, input) { Ch.Assert(input.Schema.Count == parent.OutputSchema.Count); _parent = parent; }
protected override bool MoveNextCore() { Ch.Assert(State != CursorState.Done); Ch.Assert(Position < _data.Count); return(Position + 1 < _data.Count); }
// Note that we don't filter out rows with parsing issues since it's not acceptable to // produce a different set of rows when subsetting columns. Any parsing errors need to be // translated to NaN, not result in skipping the row. We should produce some diagnostics // to alert the user to the issues. private Cursor(TextLoader parent, ParseStats stats, bool[] active, LineReader reader, int srcNeeded, int cthd) : base(parent._host) { Ch.Assert(active == null || active.Length == parent._bindings.Infos.Length); Ch.AssertValue(reader); Ch.AssertValue(stats); Ch.Assert(srcNeeded >= 0); Ch.Assert(cthd > 0); _total = -1; _batch = -1; _bindings = parent._bindings; _parser = parent._parser; _active = active; _reader = reader; _stats = stats; _srcNeeded = srcNeeded; ParallelState state = null; if (cthd > 1) { state = new ParallelState(this, out _rows, cthd); } else { _rows = _parser.CreateRowSet(_stats, 1, _active); } try { _getters = new Delegate[_bindings.Infos.Length]; for (int i = 0; i < _getters.Length; i++) { if (_active != null && !_active[i]) { continue; } ColumnPipe v = _rows.Pipes[i]; Ch.Assert(v != null); _getters[i] = v.GetGetter(); Ch.Assert(_getters[i] != null); } if (state != null) { _ator = ParseParallel(state).GetEnumerator(); state = null; } else { _ator = ParseSequential().GetEnumerator(); } } finally { if (state != null) { state.Dispose(); } } }
protected override bool MoveNextCore() { Ch.Assert(State != CursorState.Done); return(true); }
public bool IsColumnActive(int col) { Ch.CheckParam(0 <= col && col < _colToActivesIndex.Length, nameof(col)); Ch.Assert((_colToActivesIndex[col] >= 0) == _input.IsColumnActive(col)); return(_input.IsColumnActive(col)); }