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


##########
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);

Review Comment:
   `append` copied the data from one buffer to another,  is there any more 
better way to avoid copy data since this is the critical path of writing data.



-- 
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