[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767874&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767874 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 09/May/22 11:52 Start Date: 09/May/22 11:52 Worklog Time Spent: 10m Work Description: martin-g commented on PR #1681: URL: https://github.com/apache/avro/pull/1681#issuecomment-1121000341 Thank you, @jklamer ! Issue Time Tracking --- Worklog Id: (was: 767874) Time Spent: 1h 10m (was: 1h) > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767873&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767873 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 09/May/22 11:51 Start Date: 09/May/22 11:51 Worklog Time Spent: 10m Work Description: martin-g merged PR #1681: URL: https://github.com/apache/avro/pull/1681 Issue Time Tracking --- Worklog Id: (was: 767873) Time Spent: 1h (was: 50m) > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Labels: pull-request-available > Time Spent: 1h > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767862&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767862 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 09/May/22 11:00 Start Date: 09/May/22 11:00 Worklog Time Spent: 10m Work Description: martin-g commented on code in PR #1681: URL: https://github.com/apache/avro/pull/1681#discussion_r867890412 ## lang/rust/avro/examples/test_interop_single_object_encoding.rs: ## @@ -58,3 +63,15 @@ fn main() { .expect("Should encode"); assert_eq!(file_message, generated_encoding) } + +fn test_read() { +let file_message = std::fs::read(format!("{}/test_message.bin", RESOURCES_FOLDER)) Review Comment: I didn't understand the intention last evening! All is fine! Issue Time Tracking --- Worklog Id: (was: 767862) Time Spent: 50m (was: 40m) > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767717&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767717 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 08/May/22 20:44 Start Date: 08/May/22 20:44 Worklog Time Spent: 10m Work Description: jklamer commented on code in PR #1681: URL: https://github.com/apache/avro/pull/1681#discussion_r867539837 ## lang/rust/avro/examples/test_interop_single_object_encoding.rs: ## @@ -58,3 +63,15 @@ fn main() { .expect("Should encode"); assert_eq!(file_message, generated_encoding) } + +fn test_read() { +let file_message = std::fs::read(format!("{}/test_message.bin", RESOURCES_FOLDER)) Review Comment: just kidding, I can use a reference for test write Issue Time Tracking --- Worklog Id: (was: 767717) Time Spent: 40m (was: 0.5h) > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Labels: pull-request-available > Time Spent: 40m > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767715&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767715 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 08/May/22 20:40 Start Date: 08/May/22 20:40 Worklog Time Spent: 10m Work Description: jklamer commented on code in PR #1681: URL: https://github.com/apache/avro/pull/1681#discussion_r867539505 ## lang/rust/avro/examples/test_interop_single_object_encoding.rs: ## @@ -58,3 +63,15 @@ fn main() { .expect("Should encode"); assert_eq!(file_message, generated_encoding) } + +fn test_read() { +let file_message = std::fs::read(format!("{}/test_message.bin", RESOURCES_FOLDER)) Review Comment: I can reuse. I'll just need to clone because `test_read` needs the owned value Issue Time Tracking --- Worklog Id: (was: 767715) Time Spent: 0.5h (was: 20m) > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767711&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767711 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 08/May/22 19:45 Start Date: 08/May/22 19:45 Worklog Time Spent: 10m Work Description: martin-g commented on code in PR #1681: URL: https://github.com/apache/avro/pull/1681#discussion_r867534037 ## lang/rust/avro/src/reader.rs: ## @@ -569,4 +663,158 @@ mod tests { let reader = Reader::new(&result[..]).unwrap(); assert_eq!(reader.user_metadata(), &user_meta_data); } + +#[derive(Deserialize, Clone, PartialEq, Debug)] +struct TestSingleObjectReader { +a: i64, +b: f64, +c: Vec, +} + +impl AvroSchema for TestSingleObjectReader { +fn get_schema() -> Schema { +let schema = r#" +{ +"type":"record", +"name":"TestSingleObjectWrtierSerialize", +"fields":[ +{ +"name":"a", +"type":"long" +}, +{ +"name":"b", +"type":"double" +}, +{ +"name":"c", +"type":{ +"type":"array", +"items":"string" +} +} +] +} +"#; +Schema::parse_str(schema).unwrap() +} +} + +impl From for TestSingleObjectReader { +fn from(obj: Value) -> TestSingleObjectReader { +if let Value::Record(fields) = obj { +let mut a = None; +let mut b = None; +let mut c = vec![]; +for (field_name, v) in fields { +match (field_name.as_str(), v) { +("a", Value::Long(i)) => a = Some(i), +("b", Value::Double(d)) => b = Some(d), +("c", Value::Array(v)) => { +for inner_val in v { +if let Value::String(s) = inner_val { +c.push(s); +} +} +} +_ => panic!("Unexpected pair"), Review Comment: ```suggestion (key, value) => panic!("Unexpected pair: {:?} -> {:?}", key, value), ``` ## lang/rust/avro/examples/test_interop_single_object_encoding.rs: ## @@ -58,3 +63,15 @@ fn main() { .expect("Should encode"); assert_eq!(file_message, generated_encoding) } + +fn test_read() { +let file_message = std::fs::read(format!("{}/test_message.bin", RESOURCES_FOLDER)) Review Comment: Is this `read` really needed ? ## lang/rust/avro/src/reader.rs: ## @@ -569,4 +663,158 @@ mod tests { let reader = Reader::new(&result[..]).unwrap(); assert_eq!(reader.user_metadata(), &user_meta_data); } + +#[derive(Deserialize, Clone, PartialEq, Debug)] +struct TestSingleObjectReader { +a: i64, +b: f64, +c: Vec, +} + +impl AvroSchema for TestSingleObjectReader { +fn get_schema() -> Schema { +let schema = r#" +{ +"type":"record", +"name":"TestSingleObjectWrtierSerialize", +"fields":[ +{ +"name":"a", +"type":"long" +}, +{ +"name":"b", +"type":"double" +}, +{ +"name":"c", +"type":{ +"type":"array", +"items":"string" +} +} +] +} +"#; +Schema::parse_str(schema).unwrap() +} +} + +impl From for TestSingleObjectReader { +fn from(obj: Value) -> TestSingleObjectReader { +if let Value::Record(fields) = obj { +let mut a = None; +let mut b = None; +let mut c = vec![]; +for (field_name, v) in fields { +match (field_name.as_str(), v) { +("a", Value::Long(i)) => a = Some(i), +("b", Value::Double(d)) => b = Some(d), +("c", Value::Array(v)) => { +for inner_val in v { +if let Value::String(s) = inne
[jira] [Work logged] (AVRO-3507) [rust] Implement Single Object Reader
[ https://issues.apache.org/jira/browse/AVRO-3507?focusedWorklogId=767702&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767702 ] ASF GitHub Bot logged work on AVRO-3507: Author: ASF GitHub Bot Created on: 08/May/22 18:46 Start Date: 08/May/22 18:46 Worklog Time Spent: 10m Work Description: jklamer opened a new pull request, #1681: URL: https://github.com/apache/avro/pull/1681 Single object encoding readers. Both generic interfacing only with value, and Specific that takes advantage of traits to deserialize directly to the user's type. ### Jira https://issues.apache.org/jira/browse/AVRO-3507 ### Tests - [ ] Unit tests - [ ] Interop message test ### Documentation https://issues.apache.org/jira/browse/AVRO-3513 Issue Time Tracking --- Worklog Id: (was: 767702) Remaining Estimate: 0h Time Spent: 10m > [rust] Implement Single Object Reader > - > > Key: AVRO-3507 > URL: https://issues.apache.org/jira/browse/AVRO-3507 > Project: Apache Avro > Issue Type: New Feature >Reporter: Jack Klamer >Assignee: Jack Klamer >Priority: Major > Time Spent: 10m > Remaining Estimate: 0h > > The spec contains a definition for Single object Encoding: > https://avro.apache.org/docs/current/spec.html#single_object_encoding > Rust should have a compatible reader -- This message was sent by Atlassian Jira (v8.20.7#820007)