Skip to content

Commit

Permalink
disk index remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Mar 31, 2023
1 parent 3f6c33d commit ede6ff3
Showing 1 changed file with 1 addition and 70 deletions.
71 changes: 1 addition & 70 deletions bucket_map/src/index_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ use {
std::{fmt::Debug, marker::PhantomData},
};

/// in use/occupied
const OCCUPIED_OCCUPIED: u64 = 1;
/// free, ie. not occupied
const OCCUPIED_FREE: u64 = 0;

/// header for elements in a bucket
/// needs to be multiple of size_of::<u64>()
#[repr(C)]
struct OccupiedHeader {
/// OCCUPIED_OCCUPIED or OCCUPIED_FREE
occupied: u64,
}

/// allocated in `contents` in a BucketStorage
pub struct BucketWithBitVec<T: 'static> {
pub occupied: BitVec,
Expand Down Expand Up @@ -169,24 +156,6 @@ impl<T> IndexEntryPlaceInBucket<T> {
index_entry.multiple_slots = MultipleSlots::default();
}

pub fn set_storage_capacity_when_created_pow2(
&self,
index_bucket: &mut BucketStorage<IndexBucket<T>>,
storage_capacity_when_created_pow2: u8,
) {
self.get_multiple_slots_mut(index_bucket)
.set_storage_capacity_when_created_pow2(storage_capacity_when_created_pow2);
}

pub fn set_storage_offset(
&self,
index_bucket: &mut BucketStorage<IndexBucket<T>>,
storage_offset: u64,
) {
self.get_multiple_slots_mut(index_bucket)
.set_storage_offset(storage_offset);
}

pub(crate) fn get_multiple_slots<'a>(
&self,
index_bucket: &'a BucketStorage<IndexBucket<T>>,
Expand Down Expand Up @@ -255,22 +224,7 @@ impl<T> IndexEntryPlaceInBucket<T> {

#[cfg(test)]
mod tests {
use {
super::*,
std::{path::PathBuf, sync::Arc},
tempfile::tempdir,
};

impl<T> IndexEntry<T> {
pub fn new(key: Pubkey) -> Self {
IndexEntry {
key,
packed_ref_count: PackedRefCount::default(),
multiple_slots: MultipleSlots::default(),
_phantom: PhantomData,
}
}
}
use super::*;

/// verify that accessors for storage_offset and capacity_when_created are
/// correct and independent
Expand Down Expand Up @@ -298,29 +252,6 @@ mod tests {
assert_eq!(std::mem::size_of::<IndexEntry<u64>>(), 32 + 8 + 8 + 8);
}

fn index_bucket_for_testing() -> BucketStorage<IndexBucket<u64>> {
let tmpdir = tempdir().unwrap();
let paths: Vec<PathBuf> = vec![tmpdir.path().to_path_buf()];
assert!(!paths.is_empty());

// `new` here creates a file in `tmpdir`. Once the file is created, `tmpdir` can be dropped without issue.
BucketStorage::<IndexBucket<u64>>::new(
Arc::new(paths),
1,
std::mem::size_of::<IndexEntry<u64>>() as u64,
1,
Arc::default(),
Arc::default(),
)
}

fn index_entry_for_testing() -> (
BucketStorage<IndexBucket<u64>>,
IndexEntryPlaceInBucket<u64>,
) {
(index_bucket_for_testing(), IndexEntryPlaceInBucket::new(0))
}

#[test]
#[should_panic(expected = "New storage offset must fit into 7 bytes!")]
fn test_set_storage_offset_value_too_large() {
Expand Down

0 comments on commit ede6ff3

Please sign in to comment.