edponce commented on PR #13009:
URL: https://github.com/apache/arrow/pull/13009#issuecomment-1112256516
Here are some observations on the `Array/ChunkedArray` iterator support in
Arrow.
1. For `ChunkedArray`, how would we know if the iterator is in the begin/end?
I suggest we add begin/end methods to `ChunkedArray` ( [for example, see
`NumericArray`](https://github.com/apache/arrow/blob/master/cpp/src/arrow/array/array_primitive.h#L118-L120))
so that it can be traversed in for-loop idioms.
Note: Currently, not all Arrow `Arrays` have begin/end methods.
```c++
# Iterator
for (auto it = chunked_array.begin(); it != chunked_array.end(); ++it) {
... }
# STL for_each
std::for_each(chunked_array.begin(), chunked_array.end(), [](T const&
elem) { ... }
# range-for
for (const auto& elem: chunked_array) { ... }
```
2. C++ has begin/end and their const variants cbegin/cend. In Arrow `Array`
and `ChunkedArray` are immutable types, so I would expect for them to only
support cbegin/cend, but range-for requires begin/end. A solution is to have
begin/end return a const iterator.
3. There is an [experimental
`MultipleChunkIterator`](https://github.com/apache/arrow/blob/master/cpp/src/arrow/chunked_array.h#L194)
that seems to not be used in the codebase. Should it be removed?
--
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]