sstable: fix compressed data file stream bug

We need to update _pos after we read, or we keep reading the same
chunk over and over :-( Also, don't read anything if we're already past
the end of file.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This commit is contained in:
Nadav Har'El
2015-04-07 00:25:54 +03:00
committed by Avi Kivity
parent 4fca9734c9
commit de58d08e59

View File

@@ -154,6 +154,9 @@ public:
_pos(pos)
{}
virtual future<temporary_buffer<char>> get() override {
if (_pos >= _compression_metadata->data_len) {
return make_ready_future<temporary_buffer<char>>();
}
auto addr = _compression_metadata->locate(_pos);
return read_exactly(_file, addr.chunk_start, addr.chunk_len).
then([this, addr](temporary_buffer<char> buf) {
@@ -182,6 +185,7 @@ public:
out.get_write(), out.size());
out.trim(len);
out.trim_front(addr.offset);
_pos += out.size();
return out;
});
}