jklamer commented on a change in pull request #1602:
URL: https://github.com/apache/avro/pull/1602#discussion_r829585824



##########
File path: lang/rust/avro/src/encode.rs
##########
@@ -45,155 +50,177 @@ fn encode_int(i: i32, buffer: &mut Vec<u8>) {
     zig_i32(i, buffer)
 }
 
-/// Encode a `Value` into avro format.
-///
-/// **NOTE** This will not perform schema validation. The value is assumed to
-/// be valid with regards to the schema. Schema are needed only to guide the
-/// encoding for complex type values.
-pub fn encode_ref(value: &Value, schema: &Schema, buffer: &mut Vec<u8>) {
-    fn encode_ref0(
-        value: &Value,
-        schema: &Schema,
-        buffer: &mut Vec<u8>,
-        schemas_by_name: &mut HashMap<Name, Schema>,
-    ) {
-        match &schema {
-            Schema::Ref { ref name } => {
-                let resolved = schemas_by_name.get(name).unwrap();
-                return encode_ref0(value, resolved, buffer, &mut 
schemas_by_name.clone());
-            }
-            Schema::Record { ref name, .. }
-            | Schema::Enum { ref name, .. }
-            | Schema::Fixed { ref name, .. } => {
-                schemas_by_name.insert(name.clone(), schema.clone());
-            }
-            _ => (),
-        }
+fn encode_internal(
+    value: &Value,
+    schema: &Schema,
+    names: &HashMap<Name, &Schema>,

Review comment:
       Names right now is type aliases to `HashMap<Name, Schema>`. I'll make an 
alias called `NamesRef` for `HashMap<Name, &Schema>`. 




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