diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 1cbfc88d63..0f97db0e24 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -438,6 +438,14 @@ future<> sstable::read_statistics() { return read_simple(); } +future<> sstable::open_data() { + return when_all(engine().open_file_dma(filename(component_type::Index), open_flags::ro), + engine().open_file_dma(filename(component_type::Data), open_flags::ro)).then([this] (auto files) { + _index_file = make_lw_shared(std::move(std::get(std::get<0>(files).get()))); + _data_file = make_lw_shared(std::move(std::get(std::get<1>(files).get()))); + }); +} + future<> sstable::load() { return read_toc().then([this] { return read_statistics(); @@ -447,6 +455,8 @@ future<> sstable::load() { return read_filter(); }).then([this] {; return read_summary(); + }).then([this] { + return open_data(); }); } diff --git a/sstables/sstables.hh b/sstables/sstables.hh index 7a621951b7..3f1df8f749 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -6,6 +6,7 @@ #pragma once #include "core/file.hh" +#include "core/fstream.hh" #include "core/future.hh" #include "core/sstring.hh" #include "core/enum.hh" @@ -52,6 +53,8 @@ private: filter _filter; summary _summary; statistics _statistics; + lw_shared_ptr _index_file; + lw_shared_ptr _data_file; sstring _dir; unsigned long _epoch = 0; @@ -74,6 +77,7 @@ private: return read_simple(); } future<> read_statistics(); + future<> open_data(); public: sstable(sstring dir, unsigned long epoch, version_types v, format_types f) : _dir(dir), _epoch(epoch), _version(v), _format(f) {}