You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/14 19:48:52 UTC

[GitHub] [arrow] carols10cents commented on a change in pull request #8402: ARROW-8426: [Rust] [Parquet] - Add more support for converting Dicts

carols10cents commented on a change in pull request #8402:
URL: https://github.com/apache/arrow/pull/8402#discussion_r504931448



##########
File path: rust/parquet/src/arrow/converter.rs
##########
@@ -253,6 +256,34 @@ impl Converter<Vec<Option<ByteArray>>, LargeBinaryArray> for LargeBinaryArrayCon
     }
 }
 
+pub struct DictionaryArrayConverter {}
+
+impl<K: ArrowDictionaryKeyType> Converter<Vec<Option<ByteArray>>, DictionaryArray<K>>
+    for DictionaryArrayConverter
+{
+    fn convert(&self, source: Vec<Option<ByteArray>>) -> Result<DictionaryArray<K>> {
+        let data_size = source
+            .iter()
+            .map(|x| x.as_ref().map(|b| b.len()).unwrap_or(0))
+            .sum();
+
+        let keys_builder = PrimitiveBuilder::<K>::new(source.len());
+        let values_builder = StringBuilder::with_capacity(source.len(), data_size);
+
+        let mut builder = StringDictionaryBuilder::new(keys_builder, values_builder);
+        for v in source {
+            match v {
+                Some(array) => {
+                    builder.append(array.as_utf8()?)?;

Review comment:
       Do you mean make this one line again, like:
   
   `Some(array) => let _ = builder.append(array.as_utf8()?)?,`




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org