ZENOTME commented on code in PR #82:
URL: https://github.com/apache/iceberg-rust/pull/82#discussion_r1390885977
##########
crates/iceberg/src/avro/schema.rs:
##########
@@ -233,23 +222,46 @@ pub(crate) fn schema_to_avro_schema(name: impl ToString,
schema: &Schema) -> Res
visit_schema(schema, &mut converter).map(Either::unwrap_left)
}
-pub(crate) fn avro_fixed_schema(len: usize) -> Result<AvroSchema> {
+fn avro_record_schema(name: &str, fields: Vec<AvroRecordField>) ->
Result<AvroSchema> {
+ let lookup = fields
+ .iter()
+ .enumerate()
+ .map(|f| (f.1.name.clone(), f.0))
+ .collect();
+
+ Ok(AvroSchema::Record(RecordSchema {
+ name: Name::new(name)?,
+ aliases: None,
+ doc: None,
+ fields,
+ lookup,
+ attributes: Default::default(),
+ }))
+}
+
+pub(crate) fn avro_fixed_schema(len: usize, logical_type: Option<&str>) ->
Result<AvroSchema> {
+ let attributes = if let Some(logical_type) = logical_type {
+ BTreeMap::from([(
+ LOGICAL_TYPE.to_string(),
+ Value::String(logical_type.to_string()),
+ )])
Review Comment:
No, it's not default. For here it's just because [avro::FixedSchema use
BTreeMap](https://github.com/apache/avro/blob/da98719ad84bad1ef71c17779ba6b3c482d84b2c/lang/rust/avro/src/schema.rs#L814).
And indeed HashMap can save more memory. But I find that seems avro prefer to
use BTreeMap. (I'm not sure that maybe they need the sorted order when iterate
it the attributes in serialization?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]