From 8411ce71d1dbd2d9e1794f149d5aaa6d0fcf66fb Mon Sep 17 00:00:00 2001 From: adiholden Date: Tue, 2 Jan 2024 21:57:52 +0200 Subject: [PATCH] fix(dash table): bucket count returns the number of buckets (#2359) Signed-off-by: adi_holden --- src/core/dash.h | 6 +++--- src/core/dash_test.cc | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/dash.h b/src/core/dash.h index 7bc2a97c0..ab08b5a63 100644 --- a/src/core/dash.h +++ b/src/core/dash.h @@ -213,12 +213,12 @@ class DashTable : public detail::DashTableBase { } size_t bucket_count() const { - return unique_segments_ * SegmentType::capacity(); + return unique_segments_ * SegmentType::kNumBuckets; } // Overall capacity of the table (including stash buckets). size_t capacity() const { - return bucket_count(); + return unique_segments_ * SegmentType::capacity(); } double load_factor() const { @@ -721,7 +721,7 @@ void DashTable<_Key, _Value, Policy>::Erase(iterator it) { template void DashTable<_Key, _Value, Policy>::Reserve(size_t size) { - if (size <= bucket_count()) + if (size <= capacity()) return; size_t sg_floor = (size - 1) / SegmentType::capacity(); diff --git a/src/core/dash_test.cc b/src/core/dash_test.cc index d4a161d5e..25ef87f80 100644 --- a/src/core/dash_test.cc +++ b/src/core/dash_test.cc @@ -465,7 +465,7 @@ TEST_F(DashTest, Custom) { } TEST_F(DashTest, Reserve) { - unsigned bc = dt_.bucket_count(); + unsigned bc = dt_.capacity(); for (unsigned i = 0; i <= bc * 2; ++i) { dt_.Reserve(i); ASSERT_GE((1 << dt_.depth()) * Dash64::kSegCapacity, i); @@ -562,7 +562,7 @@ struct TestEvictionPolicy { } bool CanGrow(const Dash64& tbl) const { - return tbl.bucket_count() < max_capacity; + return tbl.capacity() < max_capacity; } void RecordSplit(Dash64::Segment_t*) { @@ -876,7 +876,7 @@ struct SimpleEvictPolicy { static constexpr bool can_evict = true; bool CanGrow(const U64Dash& tbl) { - return tbl.bucket_count() + U64Dash::kSegCapacity < max_capacity; + return tbl.capacity() + U64Dash::kSegCapacity < max_capacity; } void RecordSplit(U64Dash::Segment_t* segment) { @@ -921,7 +921,7 @@ struct ShiftRightPolicy { static constexpr bool can_evict = true; bool CanGrow(const U64Dash& tbl) { - return tbl.bucket_count() + U64Dash::kSegCapacity < max_capacity; + return tbl.capacity() + U64Dash::kSegCapacity < max_capacity; } void RecordSplit(U64Dash::Segment_t* segment) {