TieredObjectStore

Struct TieredObjectStore 

Source
pub struct TieredObjectStore { /* private fields */ }
Expand description

Tiered object store composing a hot (memory) and cold (block) tier.

New objects are written to the hot tier. When the hot tier is full, the least recently used object is demoted to the cold tier. On a hot-tier miss, the cold tier is consulted and matching objects are promoted back to the hot tier.

§Example

use grafos_store::{TieredObjectStore, ObjectStore, FabricUri};

let mut store = TieredObjectStore::new(32, 256, 16)?;
let uri: FabricUri = "fabric://p/b/k".parse()?;
store.put(&uri, b"data", None)?;
let obj = store.get(&uri)?.unwrap();
assert_eq!(obj.data, b"data");

Implementations§

Source§

impl TieredObjectStore

Source

pub fn new(hot_buckets: usize, cold_blocks: u64, max_hot: usize) -> Result<Self>

Create a tiered store.

  • hot_buckets: number of hash map buckets for the hot tier
  • cold_blocks: number of blocks for the cold tier
  • max_hot: maximum objects in hot tier before LRU eviction
Source

pub fn checkpoint(&self) -> Result<()>

Checkpoint the cold tier index to block storage.

Source§

impl TieredObjectStore

Mutable get with LRU tracking and cold-to-hot promotion.

Source

pub fn get_mut(&mut self, uri: &FabricUri) -> Result<Option<ObjectData>>

Get an object, promoting from cold tier to hot tier on a miss.

This is the preferred get method as it maintains LRU state and promotes cold objects to the hot tier for faster subsequent access.

Trait Implementations§

Source§

impl ObjectStore for TieredObjectStore

Source§

fn put( &mut self, uri: &FabricUri, data: &[u8], opts: Option<PutOptions>, ) -> Result<()>

Store an object at the given URI. Read more
Source§

fn get(&self, uri: &FabricUri) -> Result<Option<ObjectData>>

Retrieve an object by URI. Read more
Source§

fn head(&self, uri: &FabricUri) -> Result<Option<ObjectInfo>>

Retrieve object metadata without reading the data.
Source§

fn delete(&mut self, uri: &FabricUri) -> Result<bool>

Delete an object by URI. Returns true if the object existed.
Source§

fn list(&self, pool: &str, bucket: &str, prefix: &str) -> Result<Vec<String>>

List object keys matching a prefix within a bucket. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.