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
impl Store
Sourcepub fn iter(&self) -> Result<AllObjects, Error>
pub fn iter(&self) -> Result<AllObjects, Error>
Like Handle::iter()
, but accessible directly on the store.
Source§impl Store
impl Store
Sourcepub fn at_opts(
objects_dir: PathBuf,
replacements: &mut dyn Iterator<Item = (ObjectId, ObjectId)>,
_: Options,
) -> Result<Self>
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
impl Store
Handle creation
Sourcepub const INITIAL_MAX_RECURSION_DEPTH: usize = 32usize
pub const INITIAL_MAX_RECURSION_DEPTH: usize = 32usize
The amount of times a ref-delta base can be followed when multi-indices are involved.
Sourcepub fn to_cache(self: &OwnShared<Self>) -> Cache<Handle<OwnShared<Store>>>
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.
Sourcepub fn to_cache_arc(self: &Arc<Self>) -> Cache<Handle<Arc<Store>>>
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
.
Sourcepub fn to_handle(self: &OwnShared<Self>) -> Handle<OwnShared<Store>>
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.
Sourcepub fn to_handle_arc(self: &Arc<Self>) -> Handle<Arc<Store>>
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.
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
impl Store
Sourcepub fn verify_integrity<C, F>(
&self,
progress: &mut dyn DynNestedProgress,
should_interrupt: &AtomicBool,
options: Options<F>,
) -> Result<Outcome, Error>
pub fn verify_integrity<C, F>( &self, progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, options: Options<F>, ) -> Result<Outcome, Error>
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
impl Store
Sourcepub fn path(&self) -> &Path
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.
Sourcepub fn object_hash(&self) -> Kind
pub fn object_hash(&self) -> Kind
The kind of object hash to assume when dealing with pack indices and pack data files.
Sourcepub fn use_multi_pack_index(&self) -> bool
pub fn use_multi_pack_index(&self) -> bool
Whether or not we are allowed to use multi-pack indices
Sourcepub fn replacements(&self) -> impl Iterator<Item = (ObjectId, ObjectId)> + '_
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
impl Store
Sourcepub fn structure(&self) -> Result<Vec<Record>, Error>
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.