History

frame for a pack iterator

Sebastian Thiel committed 6 years ago

Commit 07d10961 parent 45c35206 files · +51 −6Browse files

Unified · Split

6 files
  1. README.md +5 −4
  2. git-odb/src/pack/data/iter.rs +33 −0
  3. git-odb/src/pack/data/mod.rs +2 −0
  4. git-odb/src/pack/index/mod.rs +2 −0
  5. git-odb/tests/pack/file.rs +8 −2
  6. git-odb/tests/pack/index.rs +1 −0
README.md+5−4
@@ -21,7 +21,7 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 20 unmodified lines
21 * [x] [pack verify](https://asciinema.org/a/346975)21 * [x] [pack verify](https://asciinema.org/a/346975)
22 * [x] [pack index verify](https://asciinema.org/a/346976) including each object sha1 and statistics22 * [x] [pack index verify](https://asciinema.org/a/346976) including each object sha1 and statistics
23 * [x] pack explode, useful for transforming packs into loose objects for inspection or restoration23 * [x] pack explode, useful for transforming packs into loose objects for inspection or restoration
24 * [ ] verify written objects (by reading them back from disk)24 * [x] verify written objects (by reading them back from disk)
25* **git-object**25* **git-object**
26 * *decode (zero-copy)* borrowed objects26 * *decode (zero-copy)* borrowed objects
27 * [x] commit27 * [x] commit
@@ -46,7 +46,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 18 unmodified lines
46 * [x] traverse pack index46 * [x] traverse pack index
47 * [x] object abstraction47 * [x] object abstraction
48 * [x] decode (zero copy)48 * [x] decode (zero copy)
49 * [x] verify49 * [x] verify checksum
50 * [x] easy and fast pack traversal
50 * [x] decode51 * [x] decode
51 * [x] full objects52 * [x] full objects
52 * [x] deltified objects53 * [x] deltified objects
@@ -57,8 +58,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 4 unmodified lines
57 * [ ] create new pack58 * [ ] create new pack
58 * [ ] create 'thin' pack59 * [ ] create 'thin' pack
59 * [x] verify pack with statistics60 * [x] verify pack with statistics
60 * [ ] brute force - less memory61 * [x] brute force - less memory
61 * [ ] indexed - more memory62 * [x] indexed - more memory
62 * [ ] pack streaming (i.e. indexing + resolution)63 * [ ] pack streaming (i.e. indexing + resolution)
63 * [ ] API documentation with examples64 * [ ] API documentation with examples
64 * **sink**65 * **sink**
git-odb/src/pack/data/iter.rs+33−0
@@ -0,0 +1,33 @@
1use crate::pack;
2use std::{fs, io};
3
4#[derive(Debug)]
5pub struct Iter<R> {
6 read: R,
7}
8
9impl<R> Iter<R>
10where
11 R: io::Read,
12{
13 pub fn new(read: R) -> Self {
14 Iter { read }
15 }
16}
17
18impl<R> Iterator for Iter<R>
19where
20 R: io::Read,
21{
22 type Item = ();
23
24 fn next(&mut self) -> Option<Self::Item> {
25 unimplemented!("iter")
26 }
27}
28
29impl pack::data::File {
30 pub fn iter(&self) -> io::Result<impl Iterator<Item = ()>> {
31 Ok(Iter::new(io::BufReader::new(fs::File::open(&self.path)?)))
32 }
33}
git-odb/src/pack/data/mod.rs+2−0
@@ -1,3 +1,4 @@
1//! data within a pack file
1use filebuffer::FileBuffer;2use filebuffer::FileBuffer;
2use std::path::Path;3use std::path::Path;
3 4
@@ -6,6 +7,7 @@ mod decoded; · 2 unmodified lines
6pub use decoded::*;7pub use decoded::*;
7 8
8pub mod init;9pub mod init;
10pub mod iter;
9pub mod parse;11pub mod parse;
10pub mod verify;12pub mod verify;
11 13
git-odb/src/pack/index/mod.rs+2−0
@@ -1,3 +1,5 @@
1//! an index into the pack file
2//!
1/// From itertools3/// From itertools
2/// Create an iterator running multiple iterators in lockstep.4/// Create an iterator running multiple iterators in lockstep.
3///5///
git-odb/tests/pack/file.rs+8−2
@@ -7,8 +7,7 @@ fn pack_at(at: &str) -> pack::data::File { · 6 unmodified lines
7}7}
8 8
9mod method {9mod method {
10 use crate::pack::file::pack_at;10 use crate::{pack::file::pack_at, pack::SMALL_PACK};
11 use crate::pack::SMALL_PACK;
12 11
13 #[test]12 #[test]
14 fn checksum() {13 fn checksum() {
@@ -24,6 +23,13 @@ mod method { · 9 unmodified lines
24 let p = pack_at(SMALL_PACK);23 let p = pack_at(SMALL_PACK);
25 assert_eq!(p.verify_checksum().unwrap(), p.checksum());24 assert_eq!(p.verify_checksum().unwrap(), p.checksum());
26 }25 }
26
27 #[test]
28 fn iter() {
29 let pack = pack_at(SMALL_PACK);
30 let it = pack.iter().unwrap();
31 assert_eq!(it.count(), pack.num_objects() as usize);
32 }
27}33}
28 34
29/// All hardcoded offsets are obtained via `git pack-verify --verbose tests/fixtures/packs/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx`35/// All hardcoded offsets are obtained via `git pack-verify --verbose tests/fixtures/packs/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx`
git-odb/tests/pack/index.rs+1−0
@@ -187,6 +187,7 @@ fn pack_lookup() { · 186 unmodified lines
187 assert_ne!(pack_entry.data_offset, idx_entry.pack_offset);187 assert_ne!(pack_entry.data_offset, idx_entry.pack_offset);
188 assert!(sorted_offsets.binary_search(&idx_entry.pack_offset).is_ok());188 assert!(sorted_offsets.binary_search(&idx_entry.pack_offset).is_ok());
189 }189 }
190 // TODO: test iteration by sorted offsets yields the correct result when using the pack iterator
190 }191 }
191}192}
192 193

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t