diff --git a/database.hh b/database.hh index 543e03e215..7def058a00 100644 --- a/database.hh +++ b/database.hh @@ -137,7 +137,7 @@ private: // generation -> sstable. Ordered by key so we can easily get the most recent. lw_shared_ptr _sstables; mutable row_cache _cache; // Cache covers only sstables. - unsigned _sstable_generation = 1; + int64_t _sstable_generation = 1; unsigned _mutation_count = 0; db::replay_position _highest_flushed_rp; // Provided by the database that owns this commitlog diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 3bff5f7afc..5bf2687836 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -1412,7 +1412,7 @@ sstring sstable::toc_filename() const { return filename(component_type::TOC); } -const sstring sstable::filename(sstring dir, sstring ks, sstring cf, version_types version, unsigned long generation, +const sstring sstable::filename(sstring dir, sstring ks, sstring cf, version_types version, int64_t generation, format_types format, component_type component) { static std::unordered_map, enum_hash> strmap = { @@ -1658,7 +1658,7 @@ file_exists(sstring filename) { } future<> -sstable::remove_sstable_with_temp_toc(sstring ks, sstring cf, sstring dir, unsigned long generation, version_types v, format_types f) { +sstable::remove_sstable_with_temp_toc(sstring ks, sstring cf, sstring dir, int64_t generation, version_types v, format_types f) { return seastar::async([ks, cf, dir, generation, v, f] { auto toc = file_exists(filename(dir, ks, cf, v, generation, f, component_type::TOC)).get0(); // assert that toc doesn't exist for sstable with temporary toc. diff --git a/sstables/sstables.hh b/sstables/sstables.hh index 3bd84990c7..db2733d2ff 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -126,7 +126,7 @@ public: enum class version_types { ka, la }; enum class format_types { big }; public: - sstable(sstring ks, sstring cf, sstring dir, unsigned long generation, version_types v, format_types f, gc_clock::time_point now = gc_clock::now()) + sstable(sstring ks, sstring cf, sstring dir, int64_t generation, version_types v, format_types f, gc_clock::time_point now = gc_clock::now()) : _ks(std::move(ks)) , _cf(std::move(cf)) , _dir(std::move(dir)) @@ -175,20 +175,20 @@ public: static component_type component_from_sstring(sstring& s); static version_types version_from_sstring(sstring& s); static format_types format_from_sstring(sstring& s); - static const sstring filename(sstring dir, sstring ks, sstring cf, version_types version, unsigned long generation, + static const sstring filename(sstring dir, sstring ks, sstring cf, version_types version, int64_t generation, format_types format, component_type component); // WARNING: it should only be called to remove components of a sstable with // a temporary TOC file. - static future<> remove_sstable_with_temp_toc(sstring ks, sstring cf, sstring dir, unsigned long generation, + static future<> remove_sstable_with_temp_toc(sstring ks, sstring cf, sstring dir, int64_t generation, version_types v, format_types f); future<> load(); future<> open_data(); - void set_generation(unsigned long generation) { + void set_generation(int64_t generation) { _generation = generation; } - unsigned long generation() const { + int64_t generation() const { return _generation; } @@ -239,7 +239,7 @@ public: return _marked_for_deletion; } - void add_ancestor(int generation) { + void add_ancestor(int64_t generation) { _collector.add_ancestor(generation); } @@ -306,7 +306,7 @@ public: std::vector component_filenames() const; private: - sstable(size_t wbuffer_size, sstring ks, sstring cf, sstring dir, unsigned long generation, version_types v, format_types f, gc_clock::time_point now = gc_clock::now()) + sstable(size_t wbuffer_size, sstring ks, sstring cf, sstring dir, int64_t generation, version_types v, format_types f, gc_clock::time_point now = gc_clock::now()) : sstable_buffer_size(wbuffer_size) , _ks(std::move(ks)) , _cf(std::move(cf)) @@ -506,20 +506,20 @@ public: }; using shared_sstable = lw_shared_ptr; -using sstable_list = std::map; +using sstable_list = std::map; struct entry_descriptor { sstring ks; sstring cf; sstable::version_types version; - unsigned long generation; + int64_t generation; sstable::format_types format; sstable::component_type component; static entry_descriptor make_descriptor(sstring fname); entry_descriptor(sstring ks, sstring cf, sstable::version_types version, - unsigned long generation, sstable::format_types format, + int64_t generation, sstable::format_types format, sstable::component_type component) : ks(ks), cf(cf), version(version), generation(generation), format(format), component(component) {} }; diff --git a/tests/sstable_datafile_test.cc b/tests/sstable_datafile_test.cc index 762a98172d..d7846c383f 100644 --- a/tests/sstable_datafile_test.cc +++ b/tests/sstable_datafile_test.cc @@ -1612,7 +1612,7 @@ static std::vector> token_generation_for_current_ return key_and_token_pair; } -static void add_sstable_for_leveled_test(lw_shared_ptr& cf, unsigned long gen, uint64_t fake_data_size, +static void add_sstable_for_leveled_test(lw_shared_ptr& cf, int64_t gen, uint64_t fake_data_size, uint32_t sstable_level, sstring first_key, sstring last_key, int64_t max_timestamp = 0) { auto sst = make_lw_shared("ks", "cf", "", gen, la, big); sstables::test(sst).set_values_for_leveled_strategy(fake_data_size, sstable_level, max_timestamp, std::move(first_key), std::move(last_key)); @@ -1631,7 +1631,7 @@ static bool key_range_overlaps(sstring a, sstring b, sstring c, sstring d) { return range1.overlaps(range2, dht::token_comparator()); } -static shared_sstable get_sstable(const lw_shared_ptr& cf, unsigned long generation) { +static shared_sstable get_sstable(const lw_shared_ptr& cf, int64_t generation) { auto sstables = cf->get_sstables(); auto entry = sstables->find(generation); assert(entry != sstables->end()); @@ -1640,7 +1640,7 @@ static shared_sstable get_sstable(const lw_shared_ptr& cf, unsign return entry->second; } -static bool sstable_overlaps(const lw_shared_ptr& cf, unsigned long gen1, unsigned long gen2) { +static bool sstable_overlaps(const lw_shared_ptr& cf, int64_t gen1, int64_t gen2) { const schema& s = *cf->schema(); auto candidate1 = get_sstable(cf, gen1); auto range1 = range::make(candidate1->get_first_decorated_key(s)._token, candidate1->get_last_decorated_key(s)._token);