felipecrv commented on code in PR #41824:
URL: https://github.com/apache/arrow/pull/41824#discussion_r1628389968


##########
cpp/src/arrow/util/iterator.h:
##########
@@ -105,9 +105,18 @@ class Iterator : public 
util::EqualityComparable<Iterator<T>> {
   Iterator() : ptr_(NULLPTR, [](void*) {}) {}
 
   /// \brief Return the next element of the sequence, 
IterationTraits<T>::End() when the
-  /// iteration is completed. Calling this on a default constructed Iterator
-  /// will result in undefined behavior.
-  Result<T> Next() { return next_(ptr_.get()); }
+  /// iteration is completed.
+  Result<T> Next() {
+    if (ptr_) {
+      auto next_result = next_(ptr_.get());
+      if (next_result.ok() && IsIterationEnd(next_result.ValueUnsafe())) {

Review Comment:
   > Could you explain the reason? Performance?
   
   Performance, binary code size, and overall elegance of the iterator tree.
   
   But I see that it's not possible because these iterators are like C++ in 
that the iterator itself is the value as well instead of being something that 
produces the value. So just ignore my comment.



-- 
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]

Reply via email to