Add HKEYS command. Account for listpack blobs

This commit is contained in:
Roman Gershman 2022-03-04 14:06:48 +02:00
parent b3e5730377
commit 2213c1b38b
9 changed files with 255 additions and 36 deletions

View file

@ -42,6 +42,8 @@ struct DbStats {
size_t small_string_bytes = 0;
size_t listpack_blob_cnt = 0;
size_t listpack_bytes = 0;
DbStats& operator+=(const DbStats& o);
};
@ -54,14 +56,6 @@ struct SliceEvents {
};
class DbSlice {
struct InternalDbStats {
// Number of inline keys.
uint64_t inline_keys = 0;
// Object memory usage besides hash-table capacity.
// Applies for any non-inline objects.
size_t obj_memory_usage = 0;
};
DbSlice(const DbSlice&) = delete;
void operator=(const DbSlice&) = delete;
@ -72,6 +66,18 @@ class DbSlice {
SliceEvents events;
};
struct InternalDbStats {
// Number of inline keys.
uint64_t inline_keys = 0;
// Object memory usage besides hash-table capacity.
// Applies for any non-inline objects.
size_t obj_memory_usage = 0;
size_t listpack_blob_cnt = 0;
size_t listpack_bytes = 0;
};
DbSlice(uint32_t index, EngineShard* owner);
~DbSlice();
@ -165,6 +171,10 @@ class DbSlice {
void PreUpdate(DbIndex db_ind, MainIterator it);
void PostUpdate(DbIndex db_ind, MainIterator it);
InternalDbStats* MutableStats(DbIndex db_ind) {
return &db_arr_[db_ind]->stats;
}
// Check whether 'it' has not expired. Returns it if it's still valid. Otherwise, erases it
// from both tables and return MainIterator{}.
std::pair<MainIterator, ExpireIterator> ExpireIfNeeded(DbIndex db_ind, MainIterator it) const;