From 28a3eb7756c1b244baa297fadfed0acfd9b7a5a9 Mon Sep 17 00:00:00 2001 From: jeff washington Date: Mon, 3 Apr 2023 14:40:23 -0500 Subject: [PATCH] pr feedback --- bucket_map/src/bucket_map.rs | 2 ++ bucket_map/src/bucket_storage.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bucket_map/src/bucket_map.rs b/bucket_map/src/bucket_map.rs index 2016e9a0e486a6..f2b7f0ab89436e 100644 --- a/bucket_map/src/bucket_map.rs +++ b/bucket_map/src/bucket_map.rs @@ -53,6 +53,8 @@ pub enum BucketMapError { /// (bucket_index, current_capacity_pow2) /// Note that this is specific to data buckets DataNoSpace((u64, u8)), + + /// current_capacity_pow2 /// Note that this is specific to index buckets IndexNoSpace(u8), } diff --git a/bucket_map/src/bucket_storage.rs b/bucket_map/src/bucket_storage.rs index ba4e746ba91ab1..af95c0e087597d 100644 --- a/bucket_map/src/bucket_storage.rs +++ b/bucket_map/src/bucket_storage.rs @@ -107,21 +107,21 @@ pub(crate) enum IncludeHeader { pub enum Capacity { /// 1 << Pow2 produces # elements Pow2(u8), - /// Random IS the # elements - Random(u64), + /// Actual # elements + Actual(u64), } impl BucketCapacity for Capacity { fn capacity(&self) -> u64 { match self { Capacity::Pow2(pow2) => 1 << *pow2, - Capacity::Random(elements) => *elements, + Capacity::Actual(elements) => *elements, } } fn capacity_pow2(&self) -> u8 { match self { Capacity::Pow2(pow2) => *pow2, - Capacity::Random(_elements) => { + Capacity::Actual(_elements) => { panic!("illegal to ask for pow2 from random capacity"); } } @@ -164,7 +164,7 @@ impl BucketStorage { fn allocate_to_fill_page(capacity: &mut Capacity, cell_size: u64) -> u64 { let mut bytes = capacity.capacity() * cell_size; - if let Capacity::Random(_) = capacity { + if let Capacity::Actual(_) = capacity { // maybe bump up allocation to fit a page size const PAGE_SIZE: u64 = 4 * 1024; let full_page_bytes = bytes / PAGE_SIZE * PAGE_SIZE / cell_size * cell_size; @@ -173,7 +173,7 @@ impl BucketStorage { assert!(bytes_new >= bytes, "allocating less than requested, capacity: {}, bytes: {}, bytes_new: {}, full_page_bytes: {}", capacity.capacity(), bytes, bytes_new, full_page_bytes); assert_eq!(bytes_new % cell_size, 0); bytes = bytes_new; - *capacity = Capacity::Random(bytes / cell_size); + *capacity = Capacity::Actual(bytes / cell_size); } } bytes