database: fix type for sstable generation.

Avoid using long for it, and let's use a fixed size instead.  Let's do signed
instead of unsigned to avoid upsetting any code that we may have converted.

Signed-off-by: Glauber Costa <glommer@scylladb.com>
This commit is contained in:
Glauber Costa
2015-10-21 14:29:11 +02:00
parent 16006949d0
commit f3bad2032d
4 changed files with 16 additions and 16 deletions

View File

@@ -137,7 +137,7 @@ private:
// generation -> sstable. Ordered by key so we can easily get the most recent.
lw_shared_ptr<sstable_list> _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

View File

@@ -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<version_types, std::function<sstring (entry_descriptor d)>, enum_hash<version_types>> 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.

View File

@@ -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<sstring> 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<sstable>;
using sstable_list = std::map<unsigned long, shared_sstable>;
using sstable_list = std::map<int64_t, shared_sstable>;
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) {}
};

View File

@@ -1612,7 +1612,7 @@ static std::vector<std::pair<sstring, dht::token>> token_generation_for_current_
return key_and_token_pair;
}
static void add_sstable_for_leveled_test(lw_shared_ptr<column_family>& cf, unsigned long gen, uint64_t fake_data_size,
static void add_sstable_for_leveled_test(lw_shared_ptr<column_family>& 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<sstable>("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<column_family>& cf, unsigned long generation) {
static shared_sstable get_sstable(const lw_shared_ptr<column_family>& 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<column_family>& cf, unsign
return entry->second;
}
static bool sstable_overlaps(const lw_shared_ptr<column_family>& cf, unsigned long gen1, unsigned long gen2) {
static bool sstable_overlaps(const lw_shared_ptr<column_family>& cf, int64_t gen1, int64_t gen2) {
const schema& s = *cf->schema();
auto candidate1 = get_sstable(cf, gen1);
auto range1 = range<dht::token>::make(candidate1->get_first_decorated_key(s)._token, candidate1->get_last_decorated_key(s)._token);