-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow AlignedBuffer
to return "owned slices" (like Bytes
), which refer to the same buffer in RAM
#114
Comments
Some more thoughts on this: Use-cases
|
AlignedBytes
to return "owned slices" (like Bytes
), which refer to the same buffer in RAMAlignedBuffer
to return "owned slices" (like Bytes
), which refer to the same buffer in RAM
For now, I'm going to ignore re-using buffers. But I do need to support the two use-cases at the top of this thread: 1. The user requests multiple contiguous byte ranges.Let's say the user requests byte_ranges: 0..1000, 1000..2000, 2000..3000, 3000..4000. LSIO then:
2. The user requests a single 8 GB file.Linux can't read more than 2 GB at once. LSIO:
|
Implementation
Maybe something like this: struct InnerAlignedBuffer {
buf: *mut u8, // Should be NotNull?
layout: alloc::Layout,
exclusive_ranges: Vec<Range<usize>>,
}
impl InnerAlignedBuffer {
// `AlignedBufferMut.split` must call this function:
fn get_exclusive_slice(&mut self, slice: Range<usize>) -> Result<()> {
for exclusive_range in self.exclusive_ranges.iter() {
if overlaps(slice, exclusive_range) {
return Err
}
}
Ok(())
}
// `AlignedBufferMut.drop` must call this function:
fn remove_exclusive_slice(&mut self, slice: Range<usize>) -> Result<()) {
}
} |
OK, I think the main functionality is implemented in 030920d Still TODO:
|
todo: doctest for 2nd use-case above |
Great! I think this is done! I just want to re-read the code with fresh eyes, and then I can close this issue! |
Use-cases
get_ranges
, and return the individual "owned slices".Related
Bytes
withinAlignedBuffer
#112ndarray
,numpy
, & compression crates can consume&[u8]
(and hence consume fromAlignedBuffer
) #113Implementation
I think I can't just use
Arc<AlignedBuffer>
because each clone needs to have its ownvalid_slice
.The text was updated successfully, but these errors were encountered: