sstables: allow read_toc to be called more than once

We do that by bailing immediately if we detect that the components
map is already populated. This allow us to call read_toc() earlier
if we need to - for instance, to inquire about the existence of the
Summary - without the need to re-read the components again later.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
This commit is contained in:
Glauber Costa
2016-04-08 16:42:44 -04:00
parent 736e21222e
commit 4de26fdec8

View File

@@ -696,6 +696,10 @@ inline void write(file_writer& out, estimated_histogram& eh) {
// This is small enough, and well-defined. Easier to just read it all
// at once
future<> sstable::read_toc() {
if (_components.size()) {
return make_ready_future<>();
}
auto file_path = filename(sstable::component_type::TOC);
sstlog.debug("Reading TOC file {} ", file_path);