Xuanwo commented on code in PR #797: URL: https://github.com/apache/iceberg-rust/pull/797#discussion_r1899967184
########## crates/iceberg/src/spec/manifest.rs: ########## @@ -1189,6 +1211,47 @@ impl DataFile { self.sort_order_id } } + +/// Convert data files to avro bytes. +pub fn data_files_to_avro( + data_files: impl IntoIterator<Item = DataFile>, + partition_type: &StructType, + version: FormatVersion, +) -> Result<Vec<u8>> { + let avro_schema = match version { + FormatVersion::V1 => _const_schema::data_file_schema_v1(partition_type.clone()).unwrap(), + FormatVersion::V2 => _const_schema::data_file_schema_v2(partition_type.clone()).unwrap(), + }; + let mut writer = AvroWriter::new(&avro_schema, Vec::new()); + + for data_file in data_files { + let value = to_value(_serde::DataFile::try_from(data_file, partition_type, true)?)? + .resolve(&avro_schema)?; + writer.append(value)?; + } + + Ok(writer.into_inner()?) +} + +/// Parse data files from avro bytes. +pub fn parse_from_avro( Review Comment: Hi, it's better for these two API accept `&mut W` and `&mut R` instead of returning `Vec<u8>` or `&[u8]`. ########## crates/iceberg/src/spec/manifest.rs: ########## @@ -1189,6 +1211,47 @@ impl DataFile { self.sort_order_id } } + +/// Convert data files to avro bytes. Review Comment: I suggest to use API: - `format_data_files_into_avro_bytes` - `parse_data_files_from_avro_bytes` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org