Repository navigation
feat: Allow to supply own names when using Value::resolve and Value::Validate - #579
Conversation
flxo
left a comment
There was a problem hiding this comment.
LGTM.
Thanks for the addition - this is really valuable for higher throughputs.
| /// resolution. | ||
| /// in the Avro specification for the full set of rules of schema resolution. | ||
| pub fn resolve_schemata(self, schema: &Schema, schemata: Vec<&Schema>) -> AvroResult<Self> { | ||
| let enclosing_namespace = schema.namespace(); |
There was a problem hiding this comment.
There is no enclosing namespace for schema. Either schema has it's own namespace (in which resolve_internal will use that) or schema has no namespace in which case this is None. So it is useless to set it here.
There was a problem hiding this comment.
I still do not understand.
The idea of enclosing_namespace is to provide the namespace to any (grand)children schemas which do not have their own "namespace" attribute.
If we pass None to
Line 752 in 7fda107
resolve_record() at Line 796 in 7fda107
There was a problem hiding this comment.
The only schemas for which schema.namespace() will return a namespace are:
Schema::RefSchema::RecordSchema::EnumSchema::FixedSchema::Decimal(Fixed)Schema::Uuid(Fixed)Schema::Duration
resolve_internal will only use the enclosing_namespace parameter in the following situations:
schema == Schema::Refto get the fqn of the reference. But if the reference has a namespace that will be used for the fqnschema == Schema::Union, but directly fromresolve_schematathe enclosing namespace will not existschema == Schema::Array, same as unionschema == Schema::Map, same as unionschema == Schema::Record, it should use the namespace from the record first but I see now that it doesn't.
I've updated the Schema::Record branch to use the namespace from the record first then the enclosing namespace if it does not have one.
2362ee1 to
0d44d25
Compare
…losing namespace
I ended up using the suggestion from @flxo instead of my own suggestion as it is not clear from a
ResolvedSchemawhich schema needs to be resolved against.This also optimizes
Value::resolve_internalto take anOption<&JsonValue>instead of an&Option<JsonValue>which saves a memory load on every function call.Closes #574