You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ho...@apache.org on 2024/04/11 05:32:04 UTC

(opendal) branch block-write-buffer updated (e448492d7e -> bed4171371)

This is an automated email from the ASF dual-hosted git repository.

hoslo pushed a change to branch block-write-buffer
in repository https://gitbox.apache.org/repos/asf/opendal.git


 discard e448492d7e feat(raw/oio): block write change to buffer
     new bed4171371 feat(raw/oio): block write change to buffer

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e448492d7e)
            \
             N -- N -- N   refs/heads/block-write-buffer (bed4171371)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/src/raw/oio/write/block_write.rs | 14 --------------
 1 file changed, 14 deletions(-)


(opendal) 01/01: feat(raw/oio): block write change to buffer

Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hoslo pushed a commit to branch block-write-buffer
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit bed4171371dbd88d4f4b36cca6088a7254770e04
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Thu Apr 11 11:19:03 2024 +0800

    feat(raw/oio): block write change to buffer
---
 core/src/raw/oio/write/block_write.rs | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/core/src/raw/oio/write/block_write.rs b/core/src/raw/oio/write/block_write.rs
index a88b00cb46..d3625c41d0 100644
--- a/core/src/raw/oio/write/block_write.rs
+++ b/core/src/raw/oio/write/block_write.rs
@@ -20,7 +20,6 @@ use std::sync::Arc;
 use std::task::Context;
 use std::task::Poll;
 
-use bytes::Bytes;
 use futures::Future;
 use futures::FutureExt;
 use futures::StreamExt;
@@ -110,7 +109,7 @@ pub trait BlockWrite: Send + Sync + Unpin + 'static {
 /// WriteBlockResult is the result returned by [`WriteBlockFuture`].
 ///
 /// The error part will carries input `(block_id, bytes, err)` so caller can retry them.
-type WriteBlockResult = std::result::Result<Uuid, (Uuid, Bytes, Error)>;
+type WriteBlockResult = std::result::Result<Uuid, (Uuid, Buffer, Error)>;
 
 struct WriteBlockFuture(BoxedStaticFuture<WriteBlockResult>);
 
@@ -132,9 +131,9 @@ impl Future for WriteBlockFuture {
 }
 
 impl WriteBlockFuture {
-    pub fn new<W: BlockWrite>(w: Arc<W>, block_id: Uuid, bytes: Bytes) -> Self {
+    pub fn new<W: BlockWrite>(w: Arc<W>, block_id: Uuid, bytes: Buffer) -> Self {
         let fut = async move {
-            w.write_block(block_id, bytes.len() as u64, Buffer::from(bytes.clone()))
+            w.write_block(block_id, bytes.len() as u64, bytes.clone())
                 .await
                 // Return bytes while we got an error to allow retry.
                 .map_err(|err| (block_id, bytes, err))
@@ -152,7 +151,7 @@ pub struct BlockWriter<W: BlockWrite> {
     w: Arc<W>,
 
     block_ids: Vec<Uuid>,
-    cache: Option<Bytes>,
+    cache: Option<Buffer>,
     futures: ConcurrentFutures<WriteBlockFuture>,
 }
 
@@ -167,7 +166,7 @@ impl<W: BlockWrite> BlockWriter<W> {
         }
     }
 
-    fn fill_cache(&mut self, bs: Bytes) -> usize {
+    fn fill_cache(&mut self, bs: Buffer) -> usize {
         let size = bs.len();
         assert!(self.cache.is_none());
         self.cache = Some(bs);
@@ -184,7 +183,7 @@ where
             if self.futures.has_remaining() {
                 // Fill cache with the first write.
                 if self.cache.is_none() {
-                    let size = self.fill_cache(bs.to_bytes());
+                    let size = self.fill_cache(bs);
                     return Ok(size);
                 }
 
@@ -195,7 +194,7 @@ where
                     cache,
                 ));
 
-                let size = self.fill_cache(bs.to_bytes());
+                let size = self.fill_cache(bs);
                 return Ok(size);
             } else if let Some(res) = self.futures.next().await {
                 match res {
@@ -220,7 +219,7 @@ where
         // No write block has been sent.
         if self.futures.is_empty() && self.block_ids.is_empty() {
             let (size, body) = match self.cache.clone() {
-                Some(cache) => (cache.len(), Buffer::from(cache)),
+                Some(cache) => (cache.len(), cache),
                 None => (0, Buffer::new()),
             };
             self.w.write_once(size as u64, body).await?;