diff --git a/sstables/row.cc b/sstables/row.cc index e67efcd17a..8fcc378992 100644 --- a/sstables/row.cc +++ b/sstables/row.cc @@ -532,8 +532,9 @@ future<> data_consume_context::read() { data_consume_context sstable::data_consume_rows( row_consumer& consumer, uint64_t start, uint64_t end) { + auto estimated_size = std::min(uint64_t(sstable_buffer_size), align_up(end - start, uint64_t(8 << 10))); return std::make_unique( - consumer, data_stream_at(start), end - start); + consumer, data_stream_at(start, estimated_size), end - start); } data_consume_context sstable::data_consume_rows(row_consumer& consumer) { diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 8713239c8a..bd7652d665 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -1470,12 +1470,12 @@ sstable::component_type sstable::component_from_sstring(sstring &s) { return reverse_map(s, _component_map); } -input_stream sstable::data_stream_at(uint64_t pos) { +input_stream sstable::data_stream_at(uint64_t pos, uint64_t buf_size) { if (_compression) { return make_compressed_file_input_stream( _data_file, &_compression, pos); } else { - return make_file_input_stream(_data_file, pos); + return make_file_input_stream(_data_file, pos, buf_size); } } diff --git a/sstables/sstables.hh b/sstables/sstables.hh index 27e4b96d86..69e53068cd 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -334,7 +334,7 @@ private: future read_indexes(uint64_t summary_idx); - input_stream data_stream_at(uint64_t pos); + input_stream data_stream_at(uint64_t pos, uint64_t buf_size = 8192); // Read exactly the specific byte range from the data file (after // uncompression, if the file is compressed). This can be used to read