You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@arrow.apache.org by Marc Allen <al...@gmail.com> on 2020/07/28 15:38:08 UTC
Accessing nested lists in arrow::Table in c++
I'm trying to write a C++ unit test that accesses a populated arrow::Table,
where the table contains a column with a 2-D matrix, i.e. each row has a
list(list(double)). I haven't been able to figure out how to access that
data to finish this unit test. I am getting stuck here:
auto cmat = table->GetColumnByName("mat");
auto lmat = std::static_pointer_cast<arrow::ListArray>(cmat->chunk(0))
// How do I get from the parent ListArray to the child ListArrays?
I took a look at
https://arrow.apache.org/docs/cpp/examples/row_columnar_conversion.html,
but couldn't quite map it to my use case. Thanks,
-Marc
Re: Accessing nested lists in arrow::Table in c++
Posted by Wes McKinney <we...@gmail.com>.
The list's child array (representing the inner values) can be accessed
with ListArray::values
https://github.com/apache/arrow/blob/master/cpp/src/arrow/array/array_nested.h#L54
So cast that to a ListArray
On Tue, Jul 28, 2020 at 10:38 AM Marc Allen <al...@gmail.com> wrote:
>
> I'm trying to write a C++ unit test that accesses a populated arrow::Table, where the table contains a column with a 2-D matrix, i.e. each row has a list(list(double)). I haven't been able to figure out how to access that data to finish this unit test. I am getting stuck here:
>
> auto cmat = table->GetColumnByName("mat");
> auto lmat = std::static_pointer_cast<arrow::ListArray>(cmat->chunk(0))
> // How do I get from the parent ListArray to the child ListArrays?
>
> I took a look at https://arrow.apache.org/docs/cpp/examples/row_columnar_conversion.html, but couldn't quite map it to my use case. Thanks,
>
> -Marc