baumgold commented on PR #428:
URL: https://github.com/apache/arrow-julia/pull/428#issuecomment-1520107608

   @quinnj - Iterating on Arrow.Stream modifies the `inputindex` field, making 
it stateful iteration rather than stateless.  The default implementation for 
Base.isempty uses iteration to check if there are further elements remaining:
   
   https://github.com/JuliaLang/julia/blob/v1.8.5/base/essentials.jl#L785-L789
   
   Unfortunately this doesn't work for stateful iterators since calling 
Base.isdone modifies the iterator's state.  A solution to this is to define 
Base.isdone:
   
   https://github.com/JuliaLang/julia/blob/v1.8.5/base/essentials.jl#L882-L895
   
   Note the doc-string explains this quite clearly:
   
   > This function provides a fast-path hint for iterator completion. This is 
useful for mutable iterators that want to avoid having elements consumed, if 
they are not going to be exposed to the user (e.g. to check for done-ness in 
`isempty` or `zip`). Mutable iterators that want to opt into this feature 
should define an isdone method that returns true/false depending on whether the 
iterator is done or not. Stateless iterators need not implement this function. 
If the result is `missing`, callers may go ahead and compute `iterate(x, 
state...) === nothing` to compute a definite answer.


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