-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: return Bytes from readers (#1330)
No pooling right now. I had implemented a naive buffer pool on a separate branch and it drastically hurt performance, so just getting this up as a first step
- Loading branch information
Showing
13 changed files
with
151 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
use std::io; | ||
|
||
use bytes::BytesMut; | ||
use bytes::{Bytes, BytesMut}; | ||
use futures_util::{AsyncRead, AsyncReadExt}; | ||
|
||
use crate::VortexRead; | ||
|
||
pub struct FuturesAdapter<IO>(pub IO); | ||
|
||
impl<R: AsyncRead + Unpin> VortexRead for FuturesAdapter<R> { | ||
async fn read_into(&mut self, mut buffer: BytesMut) -> io::Result<BytesMut> { | ||
async fn read_bytes(&mut self, len: u64) -> io::Result<Bytes> { | ||
let mut buffer = BytesMut::with_capacity(len as usize); | ||
unsafe { | ||
buffer.set_len(len as usize); | ||
} | ||
self.0.read_exact(buffer.as_mut()).await?; | ||
Ok(buffer) | ||
Ok(buffer.freeze()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.