liukun4515 commented on code in PR #1855:
URL: https://github.com/apache/arrow-rs/pull/1855#discussion_r903726865


##########
arrow/src/ipc/writer.rs:
##########
@@ -55,9 +61,50 @@ pub struct IpcWriteOptions {
     /// version 2.0.0: V4, with legacy format enabled
     /// version 4.0.0: V5
     metadata_version: ipc::MetadataVersion,
+    batch_compression_type: CompressionCodecType,
 }
 
 impl IpcWriteOptions {
+    pub fn try_new_with_compression(
+        alignment: usize,
+        write_legacy_ipc_format: bool,
+        metadata_version: ipc::MetadataVersion,
+        batch_compression_type: CompressionCodecType,
+    ) -> Result<Self> {
+        if alignment == 0 || alignment % 8 != 0 {
+            return Err(ArrowError::InvalidArgumentError(
+                "Alignment should be greater than 0 and be a multiple of 
8".to_string(),
+            ));
+        }
+        match batch_compression_type {
+            CompressionCodecType::NoCompression => {}
+            _ => {
+                if metadata_version != ipc::MetadataVersion::V5 {
+                    return Err(ArrowError::InvalidArgumentError(
+                        "Compress buffer just support from metadata 
v5".to_string(),
+                    ));
+                }
+            }
+        };
+        match metadata_version {
+            ipc::MetadataVersion::V5 => {
+                if write_legacy_ipc_format {
+                    Err(ArrowError::InvalidArgumentError(
+                        "Legacy IPC format only supported on metadata version 
4"
+                            .to_string(),
+                    ))
+                } else {
+                    Ok(Self {
+                        alignment,
+                        write_legacy_ipc_format,
+                        metadata_version,
+                        batch_compression_type,
+                    })
+                }
+            }
+            z => panic!("Unsupported ipc::MetadataVersion {:?}", z),

Review Comment:
   I just copy some code from  `try_new`.
   `try_new` just use the `CompressionCodecType::NoCompression` and it is same 
with older version.
   `try_new_with_compression` want to open the compression, but I think I made 
a mistake.
   I should use the `CompressionType` instead of `CompressionCodecType` and 
make sure the compression is enable



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