예제 #1
0
 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)));
 }
예제 #2
0
        // 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();
                }
            }
        }
예제 #3
0
 public TimeSeriesWriter(string fname, ITimeSeriesEncoder <T> encoder)
     : this(fname, encoder, new WriterOptions())
 {
 }
예제 #4
0
 // 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);
 }