gix_odb

Struct Store

source
pub struct Store { /* private fields */ }
Expand description

The object store for use in any applications with support for auto-updates in the light of changes to the object database.

§Features

  • entirely lazy, creating an instance does no disk IO at all if Slots::Given is used.
  • multi-threaded lazy-loading of indices and packs
  • per-thread pack and object caching avoiding cache trashing.
  • most-recently-used packs are always first for speedups if objects are stored in the same pack, typical for packs organized by commit graph and object age.
  • lock-free reading for perfect scaling across all cores, and changes to it don’t affect readers as long as these don’t want to enter the same branch.
  • sync with the state on disk if objects aren’t found to catch up with changes if an object seems to be missing.
    • turn off the behaviour above for all handles if objects are expected to be missing due to spare checkouts.

Implementations§

source§

impl Store

source

pub fn iter(&self) -> Result<AllObjects, Error>

Like Handle::iter(), but accessible directly on the store.

source§

impl Store

source

pub fn at_opts( objects_dir: PathBuf, replacements: &mut dyn Iterator<Item = (ObjectId, ObjectId)>, _: Options, ) -> Result<Self>

Open the store at objects_dir (containing loose objects and packs/), which must only be a directory for the store to be created without any additional work being done. slots defines how many multi-pack-indices as well as indices we can know about at a time, which includes the allowance for all additional object databases coming in via alternates as well. Note that the slots isn’t used for packs, these are included with their multi-index or index respectively. For example, In a repository with 250m objects and geometric packing one would expect 27 index/pack pairs, or a single multi-pack index. replacements is an iterator over pairs of old and new object ids for replacement support. This means that when asking for object X, one will receive object X-replaced given an iterator like Some((X, X-replaced)).

source§

impl Store

Handle creation

source

pub const INITIAL_MAX_RECURSION_DEPTH: usize = 32usize

The amount of times a ref-delta base can be followed when multi-indices are involved.

source

pub fn to_cache(self: &OwnShared<Self>) -> Cache<Handle<OwnShared<Store>>>

Create a new cache filled with a handle to this store, if this store is supporting shared ownership.

Note that the actual type of OwnShared depends on the parallel feature toggle of the gix-features crate.

source

pub fn to_cache_arc(self: &Arc<Self>) -> Cache<Handle<Arc<Store>>>

Create a new cache filled with a handle to this store if this store is held in an Arc.

source

pub fn to_handle(self: &OwnShared<Self>) -> Handle<OwnShared<Store>>

Create a new database handle to this store if this store is supporting shared ownership.

See also, to_cache() which is probably more useful.

source

pub fn to_handle_arc(self: &Arc<Self>) -> Handle<Arc<Store>>

Create a new database handle to this store if this store is held in an Arc.

This method is useful in applications that know they will use threads.

source

pub fn into_shared_arc(self: OwnShared<Self>) -> Arc<Self>

Transform the only instance into an Arc<Self> or panic if this is not the only Rc handle to the contained store.

This is meant to be used when the gix_features::threading::OwnShared refers to an Rc as it was compiled without the parallel feature toggle.

source§

impl Store

source

pub fn verify_integrity<C, F>( &self, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, options: Options<F>, ) -> Result<Outcome, Error>
where C: DecodeEntry, F: Fn() -> C + Send + Clone,

Check the integrity of all objects as per the given options.

Note that this will not force loading all indices or packs permanently, as we will only use the momentarily loaded disk state. This does, however, include all alternates.

source§

impl Store

source

pub fn metrics(&self) -> Metrics

Return metrics collected in a racy fashion, giving an idea of what’s currently going on in the store.

Use this to decide whether a new instance should be created to get a chance at dropping all open handles.

source§

impl Store

source

pub fn path(&self) -> &Path

The root path at which we expect to find all objects and packs, and which is the source of the alternate file traversal in case there are linked repositories.

source

pub fn object_hash(&self) -> Kind

The kind of object hash to assume when dealing with pack indices and pack data files.

source

pub fn use_multi_pack_index(&self) -> bool

Whether or not we are allowed to use multi-pack indices

source

pub fn replacements(&self) -> impl Iterator<Item = (ObjectId, ObjectId)> + '_

An iterator over replacements from object-ids X to X-replaced as (X, X-replaced), sorted by the original id X.

source§

impl Store

source

pub fn structure(&self) -> Result<Vec<Record>, Error>

Return information about all files known to us as well as their loading state.

Note that this call is expensive as it gathers additional information about loose object databases. Note that it may change as we collect information due to the highly volatile nature of the implementation. The likelihood of actual changes is low though as these still depend on something changing on disk and somebody reading at the same time.

source

pub fn alternate_db_paths(&self) -> Result<Vec<PathBuf>, Error>

Provide a list of all objects directories of alternate object database paths. This list might be empty if there are no alternates.

Read more about alternates in the documentation of the resolve function.

Trait Implementations§

source§

impl TryFrom<&Store> for Store

source§

type Error = Error

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

fn try_from(s: &Store) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

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.