diff --git a/parquet_derive/src/lib.rs b/parquet_derive/src/lib.rs index edb6291..c920b84 100644 --- a/parquet_derive/src/lib.rs +++ b/parquet_derive/src/lib.rs @@ -192,15 +192,15 @@ impl FieldInfo { // TODO: can this be lumped with str by doing Borrow/AsRef in the // ByteArray::from? "String" => { - // panic!("{:#?}", self); quote! { { let definition_levels : Vec = self.iter(). - map(|x| x.#field_name). + map(|x| &x.#field_name). map(|y| if y.is_some() { 1 } else { 0 }). collect(); let vals : Vec = self.iter(). - map(|x| x.#field_name). + map(|x| & + gix.#field_name). filter_map(|z| { if let Some(ref inner) = z { Some((&inner[..]).into()) diff --git a/parquet_derive_test/src/lib.rs b/parquet_derive_test/src/lib.rs index f6e0347..e4c6aaf 100644 --- a/parquet_derive_test/src/lib.rs +++ b/parquet_derive_test/src/lib.rs @@ -12,12 +12,14 @@ struct ACompleteRecord<'a> { pub a_string: String, pub a_borrowed_string: &'a String, pub maybe_a_str: Option<&'a str>, + pub maybe_a_string: Option, pub magic_number: i32, pub low_quality_pi: f32, pub high_quality_pi: f64, pub maybe_pi: Option, pub maybe_best_pi: Option, pub borrowed_maybe_a_string: &'a Option, + pub borrowed_maybe_a_str: &'a Option<&'a str>, } #[cfg(test)] @@ -42,12 +44,14 @@ mod tests { REQUIRED BINARY a_string (UTF8); REQUIRED BINARY a_borrowed_string (UTF8); OPTIONAL BINARY a_maybe_str (UTF8); + OPTIONAL BINARY a_maybe_string (UTF8); REQUIRED INT32 magic_number; REQUIRED FLOAT low_quality_pi; REQUIRED DOUBLE high_quality_pi; OPTIONAL FLOAT maybe_pi; OPTIONAL DOUBLE maybe_best_pi; OPTIONAL BINARY borrowed_maybe_a_string (UTF8); + OPTIONAL BINARY maybe_a_str (UTF8); }"; let schema = Rc::new(parse_message_type(schema_str).unwrap()); @@ -56,7 +60,8 @@ mod tests { let a_str = "hello mother".to_owned(); let a_borrowed_string = "cool news".to_owned(); - let maybe_a_string = Some("it's true, I'm a string".into()); + let maybe_a_string = Some("it's true, I'm a string".to_owned()); + let maybe_a_str = Some(&a_str[..]); let drs: Vec = vec![ACompleteRecord { a_bool: true, @@ -64,12 +69,14 @@ mod tests { a_string: "hello father".into(), a_borrowed_string: &a_borrowed_string, maybe_a_str: Some(&a_str[..]), + maybe_a_string: Some(a_str.clone()), magic_number: 100, low_quality_pi: 3.14, high_quality_pi: 3.1415, maybe_pi: Some(3.14), maybe_best_pi: Some(3.1415), borrowed_maybe_a_string: &maybe_a_string, + borrowed_maybe_a_str: &maybe_a_str, }]; let chunks = &drs[..];