sunchao commented on a change in pull request #1407:
URL: https://github.com/apache/arrow-rs/pull/1407#discussion_r822123240
##########
File path: arrow/src/array/ffi.rs
##########
@@ -127,4 +128,14 @@ mod tests {
let data = array.data();
test_round_trip(data)
}
+
+ #[test]
+ fn test_dictionary() -> Result<()> {
Review comment:
Good idea. Will add.
##########
File path: arrow/src/ffi.rs
##########
@@ -508,14 +541,20 @@ pub trait ArrowArrayRef {
let buffers = self.buffers()?;
let null_bit_buffer = self.null_bit_buffer();
- let child_data = (0..self.array().n_children as usize)
+ let mut child_data: Vec<ArrayData> = (0..self.array().n_children as
usize)
.map(|i| {
let child = self.child(i);
child.to_data()
})
.map(|d| d.unwrap())
.collect();
+ if let Some(d) = self.dictionary() {
+ // For dictionary type there should only be a single child, so we
don't need to worry if
Review comment:
Sure
##########
File path: arrow/src/ffi.rs
##########
@@ -555,18 +594,22 @@ pub trait ArrowArrayRef {
// for variable-sized buffers, such as the second buffer of a stringArray,
we need
// to fetch offset buffer's len to build the second buffer.
fn buffer_len(&self, i: usize) -> Result<usize> {
- // Inner type is not important for buffer length.
- let data_type = &self.data_type()?;
+ // Special handling for dictionary type as we only care about the key
type in the case.
+ let data_type = match &self.data_type()? {
+ DataType::Dictionary(key_data_type, _) =>
key_data_type.as_ref().clone(),
Review comment:
Yea we can do this. I need to move `&self.data_type()?` into a separate
assignment though since otherwise I'm getting "temporary value dropped while
borrowed" error.
--
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]