What is the best method to randomly access individual elements ("Scalars") of arrow::ChunkedArray e.g. for testing and display purposes? Is there some equivalent method to Array::GetScalar which takes into account that the ChunkedArray consists of multiple chunks?
The way I found so far is an own helper function which "searches" the appropriate chunk like this (not tested):
std::shared_ptr<arrow::Scalar>
get_scalar(const std::shared_ptr<arrow::ChunkedArray>& chunked_array, int64_t index) {
auto it = chunked_array->chunks().begin();
while (index >= (*it)->length()) {
index -= (*it)->length();
++it;
}
auto result = (*it)->GetScalar(index);
if (!result.ok()) {
return nullptr;
}
return result.MoveValueUnsafe();
}
But I'm wondering if there is something like this already provided or there is a better practice to do so?
Similar applies to the arrow::stl::ArrayIterator - is there an equivalent iterator for Chunked::Array?