Ji-Xinyou commented on code in PR #2880:
URL: 
https://github.com/apache/incubator-opendal/pull/2880#discussion_r1299215863


##########
core/src/raw/oio/write/append_object_write.rs:
##########
@@ -0,0 +1,176 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use async_trait::async_trait;
+use bytes::Bytes;
+
+use crate::raw::oio::Streamer;
+use crate::raw::*;
+use crate::*;
+
+const DEFAULT_WRITE_MIN_SIZE: usize = 8 * 1024 * 1024;
+
+/// AppendObjectWrite is used to implement [`Write`] based on append
+/// object. By implementing AppendObjectWrite, services don't need to
+/// care about the details of buffering and uploading parts.
+///
+/// The layout after adopting [`AppendObjectWrite`]:
+///
+/// - Services impl `AppendObjectWrite`
+/// - `AppendObjectWriter` impl `Write`
+/// - Expose `AppendObjectWriter` as `Accessor::Writer`
+#[async_trait]
+pub trait AppendObjectWrite: Send + Sync + Unpin {
+    /// Get the current offset of the append object.
+    ///
+    /// Returns `0` if the object is not exist.
+    async fn offset(&self) -> Result<u64>;
+
+    /// Append the data to the end of this object.
+    async fn append(&self, offset: u64, size: u64, body: AsyncBody) -> 
Result<()>;
+}
+
+/// AppendObjectWriter will implements [`Write`] based on append object.
+///
+/// ## TODO
+///
+/// - Allow users to switch to un-buffered mode if users write 16MiB every 
time.
+pub struct AppendObjectWriter<W: AppendObjectWrite> {
+    inner: W,
+
+    offset: Option<u64>,

Review Comment:
   Must we maintain two offsets here? All implementation of `AppendObjectWrite` 
should update their offset once they append.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to