Exemplo n.º 1
0
 public void Reset()
 {
     _chunk?.Dispose();
     _chunk = null;
     _next  = 0;
     _done  = false;
 }
Exemplo n.º 2
0
            public async Task <bool> MoveNextAsync(CancellationToken cancel)
            {
                if (_done)
                {
                    return(false);
                }

                if (_chunk == null)
                {
                    _chunk = await _reader._reader.ReadAtPartitionAsync(_from, _to, u => new DateTime(u.Long0) > _after);
                }
                else
                {
                    _chunk.Dispose();
                    _chunk = await _reader._reader.ReadFirstAsync(_next, _to);
                }

                if (_chunk == null)
                {
                    _done = true;
                    return(false);
                }
                else
                {
                    Current = new TimeSeriesChunk(_chunk, _reader.Decoder);
                    _next   = _chunk.EndPosition;
                    return(true);
                }
            }
Exemplo n.º 3
0
        static async Task <InputChunk> Decompress(IChunk chunk)
        {
            var content = new byte[chunk.ContentLength];

            if (!await chunk.ReadContentAsync(content, 0))
            {
                return(null);
            }
            var res = new InputChunk(chunk.BeginPosition, chunk.EndPosition, chunk.UserData);

            try {
                Compression.DecompressTo(content, 0, content.Length, res);
            } catch {
                res.Dispose();
                // This translation of decompression errors into missing chunks is the only reason
                // why ReadAtPartitionAsync is implemented in BufferedReader rather than ChunkReader.
                return(null);
            }
            return(res);
        }