mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-17 05:00:38 +00:00
follow bytes::Bytes convention for AlignedBuffer
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
This commit is contained in:
@@ -823,7 +823,7 @@ impl InMemoryLayer {
|
||||
len,
|
||||
will_init,
|
||||
} = entry;
|
||||
let buf = file_contents.slice(pos as usize, (pos + len) as usize);
|
||||
let buf = file_contents.slice(pos as usize..(pos + len) as usize);
|
||||
let (_buf, res) = delta_layer_writer
|
||||
.put_value_bytes(
|
||||
Key::from_compact(*key),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
ops::{Deref, Range},
|
||||
ops::{Deref, Range, RangeBounds},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
@@ -49,9 +49,22 @@ impl<A: Alignment> AlignedBuffer<A> {
|
||||
}
|
||||
|
||||
/// Returns a slice of self for the index range `[begin..end)`.
|
||||
pub fn slice(&self, begin: usize, end: usize) -> Self {
|
||||
pub fn slice(&self, range: impl RangeBounds<usize>) -> Self {
|
||||
use core::ops::Bound;
|
||||
let len = self.len();
|
||||
|
||||
let begin = match range.start_bound() {
|
||||
Bound::Included(&n) => n,
|
||||
Bound::Excluded(&n) => n.checked_add(1).expect("out of range"),
|
||||
Bound::Unbounded => 0,
|
||||
};
|
||||
|
||||
let end = match range.end_bound() {
|
||||
Bound::Included(&n) => n.checked_add(1).expect("out of range"),
|
||||
Bound::Excluded(&n) => n,
|
||||
Bound::Unbounded => len,
|
||||
};
|
||||
|
||||
assert!(
|
||||
begin <= end,
|
||||
"range start must not be greater than end: {:?} <= {:?}",
|
||||
|
||||
Reference in New Issue
Block a user