FANNG1 commented on code in PR #6280:
URL: https://github.com/apache/gravitino/pull/6280#discussion_r1926322142


##########
clients/filesystem-fuse/src/open_dal_filesystem.rs:
##########
@@ -210,19 +227,44 @@ impl FileReader for FileReaderImpl {
 
 struct FileWriterImpl {
     writer: opendal::Writer,
+    buffer: Vec<u8>,
+}
+
+impl FileWriterImpl {
+    fn new(writer: opendal::Writer) -> Self {
+        Self {
+            writer,
+            buffer: Vec::with_capacity(OpenDalFileSystem::WRITE_BUFFER_SIZE + 
4096),
+        }
+    }
 }
 
 #[async_trait]
 impl FileWriter for FileWriterImpl {
     async fn write(&mut self, _offset: u64, data: &[u8]) -> Result<u32> {
-        self.writer
-            .write(data.to_vec())
-            .await
-            .map_err(opendal_error_to_errno)?;
+        if self.buffer.len() > OpenDalFileSystem::WRITE_BUFFER_SIZE {
+            let mut new_buffer: Vec<u8> =
+                Vec::with_capacity(OpenDalFileSystem::WRITE_BUFFER_SIZE + 
4096);
+            new_buffer.append(&mut self.buffer);
+
+            self.writer
+                .write(new_buffer)
+                .await
+                .map_err(opendal_error_to_errno)?;
+        }
+        self.buffer.extend(data);
         Ok(data.len() as u32)
     }
 
     async fn close(&mut self) -> Result<()> {
+        if !self.buffer.is_empty() {
+            let mut new_buffer: Vec<u8> = vec![];

Review Comment:
   buffer not cleared too?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to