use std::sync::Arc;
use crate::persistent_artrie::block_storage::BlockStorage;
use crate::persistent_artrie::swizzled_ptr::SwizzledPtr;
use crate::persistent_artrie_core::key_encoding::CharKey;
use crate::persistent_artrie_core::overlay::{OverlayFaulter, OverlayNode};
use crate::value::DictionaryValue;
use super::PersistentARTrieChar;
impl<V: DictionaryValue, S: BlockStorage> OverlayFaulter<CharKey, V>
for PersistentARTrieChar<V, S>
{
#[inline]
fn fault_overlay_slot(&self, slot: &SwizzledPtr) -> Option<Arc<OverlayNode<CharKey, V>>> {
self.load_overlay_node_from_disk(slot).ok()
}
}
pub(crate) struct SharedOverlayFaulter<V: DictionaryValue, S: BlockStorage> {
trie: Arc<PersistentARTrieChar<V, S>>,
}
impl<V: DictionaryValue, S: BlockStorage> SharedOverlayFaulter<V, S> {
pub(crate) fn new(trie: Arc<PersistentARTrieChar<V, S>>) -> Self {
Self { trie }
}
}
impl<V: DictionaryValue, S: BlockStorage> OverlayFaulter<CharKey, V>
for SharedOverlayFaulter<V, S>
{
#[inline]
fn fault_overlay_slot(&self, slot: &SwizzledPtr) -> Option<Arc<OverlayNode<CharKey, V>>> {
self.trie.load_overlay_node_from_disk(slot).ok()
}
}