[
https://issues.apache.org/jira/browse/AVRO-3448?focusedWorklogId=742945&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-742945
]
ASF GitHub Bot logged work on AVRO-3448:
----------------------------------------
Author: ASF GitHub Bot
Created on: 17/Mar/22 03:51
Start Date: 17/Mar/22 03:51
Worklog Time Spent: 10m
Work Description: jklamer commented on a change in pull request #1602:
URL: https://github.com/apache/avro/pull/1602#discussion_r828731421
##########
File path: lang/rust/avro/src/encode.rs
##########
@@ -50,24 +51,25 @@ fn encode_int(i: i32, buffer: &mut Vec<u8>) {
/// **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>) {
+pub fn encode_ref(
+ value: &Value,
+ schema: &Schema,
+ names: &HashMap<Name, &Schema>,
+ enclosing_namespace: &Namespace,
+ buffer: &mut Vec<u8>,
+) {
fn encode_ref0(
value: &Value,
schema: &Schema,
+ names: &HashMap<Name, &Schema>,
buffer: &mut Vec<u8>,
- schemas_by_name: &mut HashMap<Name, Schema>,
+ enclosing_namespace: &Namespace,
) {
- 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());
- }
- _ => (),
+ if let Schema::Ref { ref name } = schema {
+ let resolved = *names
+ .get(&name.fully_qualified_name(enclosing_namespace))
+ .unwrap();
Review comment:
Removed all panics from encode
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 742945)
Time Spent: 3h 10m (was: 3h)
> Rust: Encoding Panic with valid schema and input
> -------------------------------------------------
>
> Key: AVRO-3448
> URL: https://issues.apache.org/jira/browse/AVRO-3448
> Project: Apache Avro
> Issue Type: Bug
> Reporter: Jack Klamer
> Assignee: Jack Klamer
> Priority: Major
> Labels: pull-request-available
> Time Spent: 3h 10m
> Remaining Estimate: 0h
>
> After a recent bug regarding Rust Avro's schema ref was fixed to help
> preserve the parsing form of schema
> (https://issues.apache.org/jira/browse/AVRO-3433). This exposed an issue
> where named schemas defined with the rules of the spec (depth first, left to
> right), are not available to the encoding workflow because it indexes schemas
> as it traverses the data. This is a problem for the common use case of
> defining a record within an optional field and it being encoded as Null, and
> not having that type then available during encoding for the next field.
>
> This was patched for level + 1 schema definitions but was not solved within
> the fullness of the spec
--
This message was sent by Atlassian Jira
(v8.20.1#820001)