leekeiabstraction commented on code in PR #161:
URL: https://github.com/apache/fluss-rust/pull/161#discussion_r2693578065


##########
crates/fluss/src/row/encode/mod.rs:
##########
@@ -62,3 +64,65 @@ impl dyn KeyEncoder {
         }
     }
 }
+
+/// An encoder to write [`BinaryRow`]. It's used to write row
+/// multi-times one by one. When writing a new row:
+///
+/// 1. call method [`RowEncoder::start_new_row()`] to start the writing.
+/// 2. call method [`RowEncoder::encode_field()`] to write the row's field.
+/// 3. call method [`RowEncoder::finishRow()`] to finish the writing and get 
the written row.
+#[allow(dead_code)]
+pub trait RowEncoder {
+    /// Start to write a new row.
+    ///
+    /// # Returns
+    /// * Ok(()) if successful
+    fn start_new_row(&mut self) -> Result<()>;
+
+    /// Write the row's field in given pos with given value.
+    ///
+    /// # Arguments
+    /// * pos - the position of the field to write.
+    /// * value - the value of the field to write.
+    ///
+    /// # Returns
+    /// * Ok(()) if successful
+    fn encode_field(&mut self, pos: usize, value: Datum) -> Result<()>;
+
+    /// Finish write the row, returns the written row.
+    ///
+    /// Note that returned row borrows from [`RowEncoder`]'s internal buffer 
which is reused for subsequent rows

Review Comment:
   If I'm not mistaken you're suggesting to use GAT to tie the lifetime of the 
returned row to the Encoder interface? I don't see how that can prevent users 
from keep using the returned row after calling `start_new_row()`
   
   I believe it's possible to use GAT to do this but not without non-trivial 
refactoring on Encoder trait. I believe we should leave this for later, will 
raise an issue for it.



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