Skip to content

Commit

Permalink
object: fix read range over chunks (#61)
Browse files Browse the repository at this point in the history
When reading small ranges this could lead to an error in the read_at stitch-cross-chunk-ranges-together code. Also improves overall efficiency as the previous fix (reading chunks + 1) could introduce at least 4MiB read amplification.
  • Loading branch information
jwuensche authored May 8, 2024
1 parent 915868a commit 916cab7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions betree/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ impl<'ds> ObjectHandle<'ds> {
let mut last_offset = offset;

let chunks = self
.read_chunk_range(chunk_range.start.chunk_id..chunk_range.end.chunk_id + 1)
.read_chunk_range(chunk_range.start.chunk_id..chunk_range.end.chunk_id)
.map_err(|e| (total_read, e))?;

for chunk in chunks {
Expand Down Expand Up @@ -892,7 +892,7 @@ impl<'ds> ObjectHandle<'ds> {
let start = Instant::now();
let iter = self.store.data.range(
&object_chunk_key(self.object.id, chunk_range.start)[..]
..&object_chunk_key(self.object.id, chunk_range.end),
..=&object_chunk_key(self.object.id, chunk_range.end),
)?;

let with_chunks = iter.map(|res| match res {
Expand Down

0 comments on commit 916cab7

Please sign in to comment.