luoyuxia commented on code in PR #97:
URL: https://github.com/apache/fluss-rust/pull/97#discussion_r2634985547


##########
crates/fluss/src/record/arrow.rs:
##########
@@ -523,7 +523,8 @@ impl<'a> LogRecordBatch<'a> {
 /// - `body_buffer`: The buffer containing the record batch body data.
 /// - `version`: The Arrow IPC metadata version.
 ///
-/// Returns `None` if the data is malformed or too short.
+/// # Panics
+/// Panics if the data is malformed e.g. too short or bad continuation marker.

Review Comment:
   we won't expect panic in here, we expect to return a `Result`



##########
crates/fluss/src/record/arrow.rs:
##########
@@ -523,7 +523,8 @@ impl<'a> LogRecordBatch<'a> {
 /// - `body_buffer`: The buffer containing the record batch body data.
 /// - `version`: The Arrow IPC metadata version.
 ///
-/// Returns `None` if the data is malformed or too short.
+/// # Panics
+/// Panics if the data is malformed e.g. too short or bad continuation marker.
 fn parse_ipc_message(
     data: &[u8],
 ) -> Option<(

Review Comment:
   ```suggestion
   ) ->Result<(
       arrow::ipc::RecordBatch<'_>,
       Buffer,
       arrow::ipc::MetadataVersion,
   )>
   ```



##########
crates/fluss/src/record/arrow.rs:
##########
@@ -534,18 +535,19 @@ fn parse_ipc_message(
     const CONTINUATION_MARKER: u32 = 0xFFFFFFFF;
 
     if data.len() < 8 {
-        return None;
+        panic!("Invalid data length: {}", data.len());

Review Comment:
   ```suggestion
           Err(ParseError(format!("Invalid data length: {}", data.len())))?
   ```



##########
crates/fluss/src/record/arrow.rs:
##########
@@ -523,7 +523,8 @@ impl<'a> LogRecordBatch<'a> {
 /// - `body_buffer`: The buffer containing the record batch body data.
 /// - `version`: The Arrow IPC metadata version.
 ///
-/// Returns `None` if the data is malformed or too short.
+/// # Panics
+/// Panics if the data is malformed e.g. too short or bad continuation marker.

Review Comment:
   So that in the caller, we can just use that:
   ```
   let (batch_metadata, body_buffer, version) = parse_ipc_message(data)?;
   ```



##########
crates/fluss/src/record/arrow.rs:
##########
@@ -577,7 +579,7 @@ pub fn to_arrow_schema(fluss_schema: &DataType) -> 
SchemaRef {
             SchemaRef::new(arrow_schema::Schema::new(fields))
         }
         _ => {
-            panic!("must be row data tyoe.")
+            panic!("Must be row data type.")

Review Comment:
   dito



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