Skip to main content

CompactionIndex

Trait CompactionIndex 

Source
pub trait CompactionIndex<K: Key>: Send + Sync {
    // Required methods
    fn update_if_match(
        &self,
        key: &K,
        old_loc: DiskLoc,
        new_loc: DiskLoc,
    ) -> bool;
    fn contains_key(&self, key: &K) -> bool;
    fn is_live(&self, shard_id: u8, key: &K, loc: DiskLoc) -> bool;

    // Provided method
    fn invalidate_blocks(&self, _shard_id: u8, _file_id: u32, _total_bytes: u64) { ... }
}

Required Methods§

Source

fn update_if_match(&self, key: &K, old_loc: DiskLoc, new_loc: DiskLoc) -> bool

If the current index points to old_loc, it is updated to new_loc and returns true.

Source

fn contains_key(&self, key: &K) -> bool

Returns true if the key currently exists in the index (i.e. has a live Put).

Source

fn is_live(&self, shard_id: u8, key: &K, loc: DiskLoc) -> bool

Returns true iff the index currently maps key to exactly loc — i.e. the entry at loc is the live (latest) version of key.

shard_id is the shard being compacted. Every key scanned during a shard’s compaction routes to that shard, so sharded (map) indexes use shard_id directly instead of recomputing shard_for(key) per entry; tree indexes are global and ignore it.

Used by compaction to skip superseded entries before copying them into a new file. A superseded entry can never become live again (a newer version with a higher GSN exists), so a false result is permanently safe to act on even while writers run concurrently. A true result may still race with a concurrent overwrite; the post-copy update_if_match CAS is the authoritative guard that re-marks the copy dead if it lost the race.

Provided Methods§

Source

fn invalidate_blocks(&self, _shard_id: u8, _file_id: u32, _total_bytes: u64)

Invalidate cached blocks for a file after compaction replaces its contents.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K: Key + Send + Sync + Hash + Eq, H: WriteHook<K>> CompactionIndex<K> for VarMap<K, H>

Source§

impl<K: Key + Send + Sync + Hash + Eq, T: Clone + Send + Sync, C: Codec<T> + Sync, H: TypedWriteHook<K, T>> CompactionIndex<K> for TypedMap<K, T, C, H>

Source§

impl<K: Key + Send + Sync + Hash + Eq, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> CompactionIndex<K> for VarTypedMap<K, T, C, H>

Source§

impl<K: Key + Send + Sync + Hash + Eq, const V: usize, H: WriteHook<K>> CompactionIndex<K> for ConstMap<K, V, H, Bitcask>

Source§

impl<K: Key + Send + Sync + Hash + Eq, const V: usize, T: Copy + IntoBytes + FromBytes + Immutable + Send + Sync, H: TypedWriteHook<K, T>> CompactionIndex<K> for ZeroMap<K, V, T, H, Bitcask>

Source§

impl<K: Key, H: WriteHook<K>> CompactionIndex<K> for VarTree<K, H>

Source§

impl<K: Key, T: Clone + Send + Sync, C: Codec<T> + Sync, H: TypedWriteHook<K, T>> CompactionIndex<K> for TypedTree<K, T, C, H>

Source§

impl<K: Key, T: Send + Sync, C: Codec<T> + Clone, H: TypedWriteHook<K, T>> CompactionIndex<K> for VarTypedTree<K, T, C, H>

Source§

impl<K: Key, const V: usize, H: WriteHook<K>> CompactionIndex<K> for ConstTree<K, V, H, Bitcask>

Source§

impl<K: Key, const V: usize, T: Copy + IntoBytes + FromBytes + Immutable + Send + Sync, H: TypedWriteHook<K, T>> CompactionIndex<K> for ZeroTree<K, V, T, H, Bitcask>