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:
[email protected]