private void EstimatorCore <T>(RowCursor cursor, ColumnCodec col, out Func <long> fetchWriteEstimator, out IValueWriter writer) { ValueGetter <T> getter = cursor.GetGetter <T>(col.SourceIndex); IValueCodec <T> codec = col.Codec as IValueCodec <T>; _host.AssertValue(codec); IValueWriter <T> specificWriter = codec.OpenWriter(Stream.Null); writer = specificWriter; T val = default(T); fetchWriteEstimator = () => { getter(ref val); specificWriter.Write(in val); return(specificWriter.GetCommitLengthEstimate()); }; }
private ColumnCodec[] GetActiveColumns(Schema schema, int[] colIndices) { _host.AssertValue(schema); _host.AssertValueOrNull(colIndices); ColumnCodec[] activeSourceColumns = new ColumnCodec[Utils.Size(colIndices)]; if (Utils.Size(colIndices) == 0) { return(activeSourceColumns); } for (int c = 0; c < colIndices.Length; ++c) { ColumnType type = schema[colIndices[c]].Type; IValueCodec codec; if (!_factory.TryGetCodec(type, out codec)) { throw _host.Except("Could not get codec for requested column {0} of type {1}", schema[c].Name, type); } _host.Assert(type.Equals(codec.Type)); activeSourceColumns[c] = new ColumnCodec(colIndices[c], codec); } return(activeSourceColumns); }
/// <summary> /// Returns an appropriate generic <c>WritePipe{T}</c> for the given column. /// </summary> public static WritePipe Create(BinarySaver parent, RowCursor cursor, ColumnCodec col) { Type writePipeType = typeof(WritePipe <>).MakeGenericType(col.Codec.Type.RawType); return((WritePipe)Activator.CreateInstance(writePipeType, parent, cursor, col)); }