public ValueGetter <TValue> GetGetter <TValue>(int col)
            {
                Ch.CheckParam(0 <= col && col < _bindings.ColumnCount, nameof(col));
                Ch.CheckParam(IsColumnActive(col), nameof(col));
                bool isSrc;
                int  index = _bindings.MapColumnIndex(out isSrc, col);

                if (isSrc)
                {
                    return(Input.GetGetter <TValue>(index));
                }
                Ch.Assert(index == 0);
                Delegate idGetter = Input.GetIdGetter();

                Ch.AssertValue(idGetter);
                var fn = idGetter as ValueGetter <TValue>;

                if (fn == null)
                {
                    throw Ch.Except("Invalid TValue in GetGetter: '{0}'", typeof(TValue));
                }
                return(fn);
            }
            /// <summary>
            /// Returns a value getter delegate to fetch the value of column with the given columnIndex, from the row.
            /// This throws if the column is not active in this row, or if the type
            /// <typeparamref name="TValue"/> differs from this column's type.
            /// </summary>
            /// <typeparam name="TValue"> is the column's content type.</typeparam>
            /// <param name="column"> is the output column whose getter should be returned.</param>
            public override ValueGetter <TValue> GetGetter <TValue>(DataViewSchema.Column column)
            {
                Ch.CheckParam(column.Index < _bindings.ColumnCount, nameof(column));
                Ch.CheckParam(IsColumnActive(column), nameof(column.Index));
                bool isSrc;
                int  index = _bindings.MapColumnIndex(out isSrc, column.Index);

                if (isSrc)
                {
                    return(Input.GetGetter <TValue>(Input.Schema[index]));
                }
                Ch.Assert(index == 0);
                Delegate idGetter = Input.GetIdGetter();

                Ch.AssertValue(idGetter);
                var fn = idGetter as ValueGetter <TValue>;

                if (fn == null)
                {
                    throw Ch.Except($"Invalid TValue in GetGetter: '{typeof(TValue)}', " +
                                    $"expected type: '{idGetter.GetType().GetGenericArguments().First()}'.");
                }
                return(fn);
            }
Beispiel #3
0
 public bool IsColumnActive(int col)
 {
     Ch.CheckParam(0 <= col && col < _colToActivesIndex.Length, nameof(col));
     return(_colToActivesIndex[col] >= 0);
 }
Beispiel #4
0
            private Delegate CreateGetterDelegate(int col)
            {
                Ch.CheckParam(IsColumnActive(col), nameof(col));

                var parquetType = _loader._columnsLoaded[col].DataType;

                switch (parquetType)
                {
                case DataType.Boolean:
                    return(CreateGetterDelegateCore <bool, bool>(col, _parquetConversions.Conv));

                case DataType.Byte:
                    return(CreateGetterDelegateCore <byte, byte>(col, _parquetConversions.Conv));

                case DataType.SignedByte:
                    return(CreateGetterDelegateCore <sbyte?, sbyte>(col, _parquetConversions.Conv));

                case DataType.UnsignedByte:
                    return(CreateGetterDelegateCore <byte, byte>(col, _parquetConversions.Conv));

                case DataType.Short:
                    return(CreateGetterDelegateCore <short?, short>(col, _parquetConversions.Conv));

                case DataType.UnsignedShort:
                    return(CreateGetterDelegateCore <ushort, ushort>(col, _parquetConversions.Conv));

                case DataType.Int16:
                    return(CreateGetterDelegateCore <short?, short>(col, _parquetConversions.Conv));

                case DataType.UnsignedInt16:
                    return(CreateGetterDelegateCore <ushort, ushort>(col, _parquetConversions.Conv));

                case DataType.Int32:
                    return(CreateGetterDelegateCore <int?, int>(col, _parquetConversions.Conv));

                case DataType.Int64:
                    return(CreateGetterDelegateCore <long?, long>(col, _parquetConversions.Conv));

                case DataType.Int96:
                    return(CreateGetterDelegateCore <BigInteger, UInt128>(col, _parquetConversions.Conv));

                case DataType.ByteArray:
                    return(CreateGetterDelegateCore <byte[], VBuffer <Byte> >(col, _parquetConversions.Conv));

                case DataType.String:
                    return(CreateGetterDelegateCore <string, ReadOnlyMemory <char> >(col, _parquetConversions.Conv));

                case DataType.Float:
                    return(CreateGetterDelegateCore <float?, Single>(col, _parquetConversions.Conv));

                case DataType.Double:
                    return(CreateGetterDelegateCore <double?, Double>(col, _parquetConversions.Conv));

                case DataType.Decimal:
                    return(CreateGetterDelegateCore <decimal?, Double>(col, _parquetConversions.Conv));

                case DataType.DateTimeOffset:
                    return(CreateGetterDelegateCore <DateTimeOffset, DateTimeOffset>(col, _parquetConversions.Conv));

                case DataType.Interval:
                    return(CreateGetterDelegateCore <Interval, TimeSpan>(col, _parquetConversions.Conv));

                default:
                    return(CreateGetterDelegateCore <IList, ReadOnlyMemory <char> >(col, _parquetConversions.Conv));
                }
            }
 /// <summary>
 /// Returns whether the given column is active in this row.
 /// </summary>
 public override bool IsColumnActive(DataViewSchema.Column column)
 {
     Ch.CheckParam(column.Index < _colToActivesIndex.Length, nameof(column));
     return(_colToActivesIndex[column.Index] >= 0);
 }
 /// <summary>
 /// Returns a value getter delegate to fetch the value of column with the given columnIndex, from the row.
 /// This throws if the column is not active in this row, or if the type
 /// <typeparamref name="TValue"/> differs from this column's type.
 /// </summary>
 /// <typeparam name="TValue"> is the column's content type.</typeparam>
 /// <param name="column"> is the output column whose getter should be returned.</param>
 public override ValueGetter <TValue> GetGetter <TValue>(DataViewSchema.Column column)
 {
     Ch.CheckParam(IsColumnActive(column), nameof(column), "requested column not active");
     return((ref TValue value) => throw Ch.Except(RowCursorUtils.FetchValueStateError));
 }
Beispiel #7
0
 /// <summary>
 /// Returns whether the given column is active in this row.
 /// </summary>
 public override bool IsColumnActive(DataViewSchema.Column column)
 {
     Ch.CheckParam(column.Index < _active.Length, nameof(column));
     _parent._groupBinding.CheckColumnInRange(column.Index);
     return(_active[column.Index]);
 }