public static Task TranscodeAsync <T>( string input, string output, ITimeSeriesDecoder <T> decoder, ITimeSeriesEncoder <T> encoder, Func <T, T> transform = null) { return(TranscodeAsync <T, T>(input, output, decoder, encoder, transform ?? (x => x))); }
// Reads all chunks from the ChunkIO file named `input`, decodes their content with `decoder`, // transforms records with `transform`, encodes them with `encoder` and appends to the ChunkIO // file named `output`. // // The output ChunkIO file is written with default WriterOptions. Some input chunks may get // merged but no chunks get split. public static async Task TranscodeAsync <T, U>( string input, string output, ITimeSeriesDecoder <T> decoder, ITimeSeriesEncoder <U> encoder, Func <T, U> transform) { using (var reader = new TimeSeriesReader <T>(input, decoder)) { var writer = new TimeSeriesWriter <U>(output, encoder); try { long len = await reader.FlushRemoteWriterAsync(flushToDisk : false); await reader.ReadAfter(DateTime.MinValue, 0, len).ForEachAsync(async(IDecodedChunk <T> c) => { await writer.WriteBatchAsync(c.Select(transform)); }); } finally { await writer.DisposeAsync(); } } }
public TimeSeriesWriter(string fname, ITimeSeriesEncoder <T> encoder) : this(fname, encoder, new WriterOptions()) { }
// The file must be exclusively writable. If it exists, it gets appended to. // You can use TimeSeriesReader to read the file. You can even do it while // having an active writer. // // Takes ownership of the encoder. TimeSeriesWriter.Dispose() will dispose it. public TimeSeriesWriter(string fname, ITimeSeriesEncoder <T> encoder, WriterOptions opt) { Encoder = encoder ?? throw new ArgumentNullException(nameof(encoder)); _writer = new BufferedWriter(fname, opt); }