twitter/pelikan

rust: storage/seg - implement an iterator for item info

brayniac opened this issue · 2 comments

In the hashtable module, we are frequently iterating through the hash buckets and info slots to get item info. This is a lot of duplicate code that feels like it can be more concisely expressed at the call sites as an iterator.

@brayniac are you referring to iterations like this repeated chunk:

for chain_idx in 0..=chain_len {
let n_item_slot = if chain_idx == chain_len {
N_BUCKET_SLOT
} else {
N_BUCKET_SLOT - 1
};
for i in 0..n_item_slot {
if chain_idx == 0 && i == 0 {
continue;
}
let current_info = bucket.data[i];

@hderms - yes. It feels like we can provide an iterator where the iterator's item type is ItemInfo which would be a new type