コード例 #1
0
 public Chunks(TimeSeriesReader <T> reader, DateTime after, long from, long to)
 {
     _reader = reader;
     _after  = after;
     _from   = from;
     _to     = to;
 }
コード例 #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();
                }
            }
        }