mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-18 05:30:37 +00:00
Revert "try a closure approach, also has same error "Send is not general enough""
This reverts commit ef2b384cf8.
This commit is contained in:
@@ -319,10 +319,11 @@ impl InMemoryLayer {
|
||||
|
||||
// Execute the read.
|
||||
vectored_dio_read::execute(
|
||||
|_, _| async move { todo!() },
|
||||
&inner.file,
|
||||
reads
|
||||
.iter()
|
||||
.flat_map(|(_, value_reads)| value_reads.iter().map(|v| &v.read)),
|
||||
&ctx,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -359,6 +360,17 @@ impl InMemoryLayer {
|
||||
}
|
||||
}
|
||||
|
||||
impl vectored_dio_read::File for EphemeralFile {
|
||||
async fn read_at_to_end<'a, 'b, B: tokio_epoll_uring::IoBufMut + Send>(
|
||||
&'b self,
|
||||
start: u32,
|
||||
dst: tokio_epoll_uring::Slice<B>,
|
||||
ctx: &'a RequestContext,
|
||||
) -> std::io::Result<(tokio_epoll_uring::Slice<B>, usize)> {
|
||||
EphemeralFile::read_at_to_end(self, start, dst, ctx).await
|
||||
}
|
||||
}
|
||||
|
||||
fn inmem_layer_display(mut f: impl Write, start_lsn: Lsn, end_lsn: Lsn) -> std::fmt::Result {
|
||||
write!(f, "inmem-{:016X}-{:016X}", start_lsn.0, end_lsn.0)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,15 @@ use tokio_epoll_uring::{BoundedBuf, IoBufMut, Slice};
|
||||
|
||||
use crate::context::RequestContext;
|
||||
|
||||
pub trait File {
|
||||
async fn read_at_to_end<'a, 'b, B: IoBufMut + Send>(
|
||||
&'b self,
|
||||
start: u32,
|
||||
dst: Slice<B>,
|
||||
ctx: &'a RequestContext,
|
||||
) -> std::io::Result<(Slice<B>, usize)>;
|
||||
}
|
||||
|
||||
trait Sealed {}
|
||||
|
||||
pub trait Buffer: Sealed + std::ops::Deref<Target = [u8]> {
|
||||
@@ -71,11 +80,10 @@ impl Buffer for Vec<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn execute<'a, 'b, I, F, Fut, B>(file: F, reads: I)
|
||||
pub async fn execute<'a, 'b, 'c, I, F, B>(file: &'c F, reads: I, ctx: &'b RequestContext)
|
||||
where
|
||||
I: IntoIterator<Item = &'a ValueRead<B>> + Send,
|
||||
F: Fn(u32, Slice<Vec<u8>>) -> Fut + Send,
|
||||
Fut: std::future::Future<Output = Result<(Slice<Vec<u8>>, usize), Arc<std::io::Error>>> + Send,
|
||||
F: File + Send,
|
||||
B: Buffer + IoBufMut + Send,
|
||||
{
|
||||
const DIO_CHUNK_SIZE: usize = 512;
|
||||
@@ -198,11 +206,13 @@ where
|
||||
if all_done {
|
||||
continue;
|
||||
}
|
||||
let (merged_read_buf_slice, nread) = match file(
|
||||
start_chunk_no * DIO_CHUNK_SIZE as u32,
|
||||
get_chunk_buf(nchunks).slice_full(),
|
||||
)
|
||||
.await
|
||||
let (merged_read_buf_slice, nread) = match file
|
||||
.read_at_to_end(
|
||||
start_chunk_no * DIO_CHUNK_SIZE as u32,
|
||||
get_chunk_buf(nchunks).slice_full(),
|
||||
ctx,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
|
||||
Reference in New Issue
Block a user