db: Compute key hash once in partition_presence_checker

I measured reduction of cache update time by 20% for 6 sstables and by
40% for 16.

Refs #1943.
This commit is contained in:
Tomasz Grabiec
2016-12-19 13:39:24 +01:00
parent ab5c77fcf1
commit 0e487b3499
3 changed files with 12 additions and 1 deletions

View File

@@ -146,8 +146,9 @@ column_family::make_partition_presence_checker(lw_shared_ptr<sstables::sstable_s
if (sst.empty()) {
return partition_presence_checker_result::definitely_doesnt_exist;
}
auto hk = sstables::sstable::make_hashed_key(*_schema, key.key());
for (auto&& s : sst) {
if (s->filter_has_key(*_schema, key.key())) {
if (s->filter_has_key(hk)) {
return partition_presence_checker_result::maybe_exists;
}
}

View File

@@ -2627,6 +2627,10 @@ sstable::get_shards_for_this_sstable() const {
return boost::copy_range<std::vector<unsigned>>(shards);
}
utils::hashed_key sstable::make_hashed_key(const schema& s, const partition_key& key) {
return utils::make_hashed_key(static_cast<bytes_view>(key::from_partition_key(s, key)));
}
std::ostream&
operator<<(std::ostream& os, const sstable_to_delete& std) {
return os << std.name << "(" << (std.shared ? "shared" : "unshared") << ")";

View File

@@ -607,10 +607,16 @@ public:
return _filter->is_present(bytes_view(key));
}
bool filter_has_key(utils::hashed_key key) {
return _filter->is_present(key);
}
bool filter_has_key(const schema& s, partition_key_view key) {
return filter_has_key(key::from_partition_key(s, key));
}
static utils::hashed_key make_hashed_key(const schema& s, const partition_key& key);
uint64_t filter_get_false_positive() {
return _filter_tracker.false_positive;
}