History

minor improvements to module layout, docs (#266)

Sebastian Thiel committed 4 years ago

Commit 0364f481 parent 360bf9d5 files · +17 −33Browse files

Unified · Split

5 files
  1. experiments/object-access/src/main.rs +1 −0
  2. git-odb/src/find.rs +2 −17
  3. git-odb/src/lib.rs +10 −15
  4. git-odb/src/store/compound/mod.rs +3 −1
  5. git-odb/src/store/linked/mod.rs +1 −0
experiments/object-access/src/main.rs+1−0
@@ -503,6 +503,7 @@ where · 502 unmodified lines
503{503{
504 use git_repository::prelude::FindExt;504 use git_repository::prelude::FindExt;
505 let bytes = std::sync::atomic::AtomicU64::default();505 let bytes = std::sync::atomic::AtomicU64::default();
506 #[allow(deprecated)]
506 let odb = Arc::new(git_repository::odb::linked::Store::at(objects_dir)?);507 let odb = Arc::new(git_repository::odb::linked::Store::at(objects_dir)?);
507 508
508 git_repository::parallel::in_parallel(509 git_repository::parallel::in_parallel(
git-odb/src/find.rs+2−17
@@ -17,7 +17,7 @@ pub mod existing { · 16 unmodified lines
17pub mod existing_object {17pub mod existing_object {
18 use git_hash::ObjectId;18 use git_hash::ObjectId;
19 19
20 /// The error returned by the various [`find_*`][crate::FindExt::find_commit()] trait methods.20 /// The error returned by the various [`find_*()`][crate::FindExt::find_commit()] trait methods.
21 #[derive(Debug, thiserror::Error)]21 #[derive(Debug, thiserror::Error)]
22 #[allow(missing_docs)]22 #[allow(missing_docs)]
23 pub enum Error<T: std::error::Error + 'static> {23 pub enum Error<T: std::error::Error + 'static> {
@@ -36,7 +36,7 @@ pub mod existing_object { · 12 unmodified lines
36pub mod existing_iter {36pub mod existing_iter {
37 use git_hash::ObjectId;37 use git_hash::ObjectId;
38 38
39 /// The error returned by the various [`find_*`][crate::FindExt::find_commit()] trait methods.39 /// The error returned by the various [`find_*_iter()`][crate::FindExt::find_commit_iter()] trait methods.
40 #[derive(Debug, thiserror::Error)]40 #[derive(Debug, thiserror::Error)]
41 #[allow(missing_docs)]41 #[allow(missing_docs)]
42 pub enum Error<T: std::error::Error + 'static> {42 pub enum Error<T: std::error::Error + 'static> {
@@ -48,18 +48,3 @@ pub mod existing_iter { · 5 unmodified lines
48 ObjectKind { expected: git_object::Kind },48 ObjectKind { expected: git_object::Kind },
49 }49 }
50}50}
51
52/// An Entry in a pack providing access to its data.
53///
54/// Its commonly retrieved by reading from a pack index file followed by a read from a pack data file.
55#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
56#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
57#[allow(missing_docs)]
58pub struct Entry<'a> {
59 /// The pack-data encoded bytes of the pack data entry as present in the pack file, including the header followed by compressed data.
60 pub data: &'a [u8],
61 /// The crc32 hash over the entirety of `data`, or None if the pack file format doesn't support it yet.
62 pub crc32: Option<u32>,
63 /// The version of the pack file containing `data`
64 pub version: crate::pack::data::Version,
65}
git-odb/src/lib.rs+10−15
@@ -1,20 +1,15 @@
1#![deny(missing_docs, unsafe_code, rust_2018_idioms)]1#![deny(missing_docs, unsafe_code, rust_2018_idioms)]
2 2
3//! Git stores all of its data as _Objects_, which ata along with a hash over all data. Thus it's an3//! Git stores all of its data as _Objects_, which are data along with a hash over all data. Thus it's an
4//! object store indexed by data with inherent deduplication: the same data will have the same hash, and thus occupy the same4//! object store indexed by the signature of data itself with inherent deduplication: the same data will have the same hash,
5//! space within the store.5//! and thus occupy the same space within the store.
6//!6//!
7//! There are various flavours of object stores, all of which supporting iteration, reading and possibly writing.7//! There is only one all-round object store, also known as the [`Store`], as it supports ~~everything~~ most of what git has to offer.
8//!8//!
9//! * [`loose::Store`]9//! * loose object reading and writing
10//! * A database storing one object per file, named by its hash, using zlib compression.10//! * access to packed objects
11//! * O(1) reads and writes, bound by IO operations per second11//! * multiple loose objects and pack locations as gathered from `alternates` files.
12//! * [`compound::Store`]12#![allow(deprecated)] // TODO: actually remove the deprecated items and remove thos allow
13//! * A database using a [`loose::Store`] for writes and multiple [`pack::Bundle`]s for object reading. It can also refer to multiple
14//! additional [`compound::Store`] instances using git-alternates.
15//! * This is the database closely resembling the object database in a git repository, and probably what most people would want to use.
16//! * [`linked::Store`]
17//! * A database containing various [`compound::Stores`][compound::Store] as gathered from `alternates` files.
18use std::path::PathBuf;13use std::path::PathBuf;
19use std::sync::Arc;14use std::sync::Arc;
20 15
@@ -28,13 +23,13 @@ pub mod alternate; · 7 unmodified lines
28 23
29/// A thread-local handle to access any object.24/// A thread-local handle to access any object.
30pub type Handle = Cache<general::Handle<OwnShared<general::Store>>>;25pub type Handle = Cache<general::Handle<OwnShared<general::Store>>>;
31/// A thread-local handle to access any object, but thread-safe and independent of the actual type of OwnShared.26/// A thread-local handle to access any object, but thread-safe and independent of the actual type of `OwnShared` or feature toggles in `git-features`.
32pub type HandleArc = Cache<general::Handle<Arc<general::Store>>>;27pub type HandleArc = Cache<general::Handle<Arc<general::Store>>>;
33 28
34/// A thread-safe store for creation of handles.29/// A thread-safe store for creation of handles.
35pub type Store = general::Store;30pub type Store = general::Store;
36 31
37/// Create a new cached odb handle.32/// Create a new cached odb handle with support for additional options.
38pub fn at_opts(objects_dir: impl Into<PathBuf>, slots: general::init::Slots) -> std::io::Result<Handle> {33pub fn at_opts(objects_dir: impl Into<PathBuf>, slots: general::init::Slots) -> std::io::Result<Handle> {
39 let handle =34 let handle =
40 OwnShared::new(general::Store::at_opts(objects_dir, slots)?).to_handle(RefreshMode::AfterAllIndicesLoaded);35 OwnShared::new(general::Store::at_opts(objects_dir, slots)?).to_handle(RefreshMode::AfterAllIndicesLoaded);
git-odb/src/store/compound/mod.rs+3−1
@@ -7,8 +7,10 @@ pub mod find; · 6 unmodified lines
7pub mod init;7pub mod init;
8mod write;8mod write;
9 9
10/// An object database with tiered lookup packs and loose objects.10/// A static object database with tiered lookup in packs and loose objects.
11/// This is a typical git database as used in git repositories, sans 'alternates'.11/// This is a typical git database as used in git repositories, sans 'alternates'.
12/// Note that this ODB won't detect changes on disk and will eagerly map all relevant files. Multipack indices are not supported either.
13#[deprecated(since = "0.27", note = "superseded by git_odb::Store")]
12pub struct Store {14pub struct Store {
13 /// A loose object database into which new objects are written15 /// A loose object database into which new objects are written
14 pub loose: loose::Store,16 pub loose: loose::Store,
git-odb/src/store/linked/mod.rs+1−0
@@ -6,6 +6,7 @@ use crate::store::compound; · 5 unmodified lines
6/// It does not contain any objects itself.6/// It does not contain any objects itself.
7///7///
8/// Furthermore, it won't handle multi-pack indices and might be removed at some point in the future to allow focussing on a single database.8/// Furthermore, it won't handle multi-pack indices and might be removed at some point in the future to allow focussing on a single database.
9#[deprecated(since = "0.27", note = "superseded by git_odb::Store")]
9pub struct Store {10pub struct Store {
10 /// The compound databases containing the actual objects.11 /// The compound databases containing the actual objects.
11 pub dbs: Vec<compound::Store>,12 pub dbs: Vec<compound::Store>,