Skip to content

Commit 8c5ae77

Browse files
committed
change!: Remove deprecated compound and linked object databases
The dynamic/general store is the only maintained can-do-it-all DB now.
1 parent 2abedb8 commit 8c5ae77

File tree

18 files changed

+50
-728
lines changed

18 files changed

+50
-728
lines changed

experiments/object-access/src/main.rs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{path::Path, sync::Arc, time::Instant};
1+
use std::{path::Path, time::Instant};
22

33
use anyhow::anyhow;
44
use git_repository::{hash::ObjectId, odb, threading::OwnShared, ThreadSafeRepository};
@@ -67,21 +67,6 @@ fn main() -> anyhow::Result<()> {
6767
objs_per_sec(elapsed)
6868
);
6969

70-
let start = Instant::now();
71-
do_gitoxide_in_parallel_through_arc(
72-
&hashes,
73-
repo.objects_dir(),
74-
odb::pack::cache::Never::default,
75-
AccessMode::ObjectExists,
76-
)?;
77-
let elapsed = start.elapsed();
78-
println!(
79-
"parallel gitoxide (Arc): confirmed {} objects exists in {:?} ({:0.0} objects/s)",
80-
hashes.len(),
81-
elapsed,
82-
objs_per_sec(elapsed)
83-
);
84-
8570
let start = Instant::now();
8671
do_parallel_git2(hashes.as_slice(), repo.git_dir(), AccessMode::ObjectExists)?;
8772
let elapsed = start.elapsed();
@@ -161,21 +146,6 @@ fn main() -> anyhow::Result<()> {
161146
objs_per_sec(elapsed)
162147
);
163148

164-
let start = Instant::now();
165-
let bytes = do_gitoxide_in_parallel_through_arc(
166-
&hashes,
167-
repo.objects_dir(),
168-
odb::pack::cache::Never::default,
169-
AccessMode::ObjectData,
170-
)?;
171-
let elapsed = start.elapsed();
172-
println!(
173-
"parallel gitoxide (uncached, Arc): confirmed {} bytes in {:?} ({:0.0} objects/s)",
174-
bytes,
175-
elapsed,
176-
objs_per_sec(elapsed)
177-
);
178-
179149
let start = Instant::now();
180150
let bytes = do_gitoxide_in_parallel_sync(
181151
&hashes,
@@ -430,49 +400,3 @@ where
430400
)?;
431401
Ok((store, bytes.load(std::sync::atomic::Ordering::Acquire)))
432402
}
433-
434-
fn do_gitoxide_in_parallel_through_arc<C>(
435-
hashes: &[ObjectId],
436-
objects_dir: &Path,
437-
new_cache: impl Fn() -> C + Send + Sync + Clone + 'static,
438-
mode: AccessMode,
439-
) -> anyhow::Result<u64>
440-
where
441-
C: odb::pack::cache::DecodeEntry + Send + 'static,
442-
{
443-
use git_repository::prelude::FindExt;
444-
let bytes = std::sync::atomic::AtomicU64::default();
445-
#[allow(deprecated)]
446-
let odb = Arc::new(odb::linked::Store::at(objects_dir)?);
447-
448-
git_repository::parallel::in_parallel(
449-
hashes.chunks(1000),
450-
None,
451-
move |_| {
452-
(
453-
Vec::new(),
454-
odb.to_cache_arc().with_pack_cache({
455-
let new_cache = new_cache.clone();
456-
move || Box::new(new_cache())
457-
}),
458-
)
459-
},
460-
|hashes, (buf, odb)| {
461-
for hash in hashes {
462-
match mode {
463-
AccessMode::ObjectData => {
464-
let obj = odb.find(hash, buf)?;
465-
bytes.fetch_add(obj.data.len() as u64, std::sync::atomic::Ordering::Relaxed);
466-
}
467-
AccessMode::ObjectExists => {
468-
use git_repository::prelude::Find;
469-
assert!(odb.contains(hash), "each traversed object exists");
470-
}
471-
}
472-
}
473-
Ok(())
474-
},
475-
git_repository::parallel::reduce::IdentityWithResult::<(), anyhow::Error>::default(),
476-
)?;
477-
Ok(bytes.load(std::sync::atomic::Ordering::Acquire))
478-
}

git-diff/tests/visit/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ mod changes {
44
use git_diff::tree::{recorder, recorder::Change::*};
55
use git_hash::{oid, ObjectId};
66
use git_object::{bstr::ByteSlice, tree::EntryMode, TreeRefIter};
7-
use git_odb::{linked, pack::Find};
7+
use git_odb::pack::Find;
88

99
use crate::hex_to_id;
1010

1111
type Changes = Vec<recorder::Change>;
1212

13-
fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<linked::Store> {
14-
linked::Store::at(
13+
fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<git_odb::Handle> {
14+
git_odb::at(
1515
git_testtools::scripted_fixture_repo_read_only_with_args("make_diff_repo.sh", args)?
1616
.join(".git")
1717
.join("objects"),
@@ -20,7 +20,7 @@ mod changes {
2020
}
2121

2222
fn locate_tree_by_commit<'a>(
23-
db: &linked::Store,
23+
db: &git_odb::Handle,
2424
commit: &oid,
2525
buf: &'a mut Vec<u8>,
2626
) -> crate::Result<TreeRefIter<'a>> {
@@ -41,7 +41,7 @@ mod changes {
4141
.expect("id to be a tree"))
4242
}
4343

44-
fn diff_commits(db: &linked::Store, lhs: impl Into<Option<ObjectId>>, rhs: &oid) -> crate::Result<Changes> {
44+
fn diff_commits(db: &git_odb::Handle, lhs: impl Into<Option<ObjectId>>, rhs: &oid) -> crate::Result<Changes> {
4545
let mut buf = Vec::new();
4646
let lhs_tree = lhs
4747
.into()
@@ -63,7 +63,7 @@ mod changes {
6363
Ok(recorder.records)
6464
}
6565

66-
fn diff_with_previous_commit_from(db: &linked::Store, commit_id: &oid) -> crate::Result<Changes> {
66+
fn diff_with_previous_commit_from(db: &git_odb::Handle, commit_id: &oid) -> crate::Result<Changes> {
6767
let mut buf = Vec::new();
6868
let (main_tree_id, parent_commit_id) = {
6969
let commit = db
@@ -111,11 +111,10 @@ mod changes {
111111
Ok(recorder.records)
112112
}
113113

114-
fn head_of(db: &linked::Store) -> ObjectId {
114+
fn head_of(db: &git_odb::Handle) -> ObjectId {
115115
ObjectId::from_hex(
116116
std::fs::read(
117-
db.dbs[0]
118-
.loose
117+
db.store_ref()
119118
.path()
120119
.parent()
121120
.unwrap()
@@ -130,7 +129,7 @@ mod changes {
130129
.expect("valid hex id")
131130
}
132131

133-
fn all_commits(db: &linked::Store) -> Vec<ObjectId> {
132+
fn all_commits(db: &git_odb::Handle) -> Vec<ObjectId> {
134133
use git_traverse::commit;
135134

136135
let head = head_of(db);

git-odb/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
//! * loose object reading and writing
1010
//! * access to packed objects
1111
//! * multiple loose objects and pack locations as gathered from `alternates` files.
12-
// TODO: actually remove the deprecated items and remove thos allow
13-
#![allow(deprecated)]
1412
1513
use std::{
1614
cell::RefCell,
@@ -23,7 +21,7 @@ use git_features::{threading::OwnShared, zlib::stream::deflate};
2321
pub use git_pack as pack;
2422

2523
mod store_impls;
26-
pub use store_impls::{compound, dynamic as store, linked, loose};
24+
pub use store_impls::{dynamic as store, loose};
2725

2826
pub mod alternate;
2927

git-odb/src/store_impls/compound/find.rs

Lines changed: 0 additions & 80 deletions
This file was deleted.

git-odb/src/store_impls/compound/init.rs

Lines changed: 0 additions & 72 deletions
This file was deleted.

git-odb/src/store_impls/compound/mod.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

git-odb/src/store_impls/compound/write.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

git-odb/src/store_impls/dynamic/access.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::Store;
22

33
impl Store {
4-
/// The root path at which we expect to find all objects and packs.
4+
/// The root path at which we expect to find all objects and packs, and which is the source of the
5+
/// alternate file traversal in case there are linked repositories.
56
pub fn path(&self) -> &std::path::Path {
67
&self.path
78
}

0 commit comments

Comments
 (0)