erratic-pattern commented on PR #10386:
URL: https://github.com/apache/datafusion/pull/10386#issuecomment-2113033273

   > I think the logic is correct, although it takes me sometime to understand 
the difference between the first pass and other pass, but I did not have a 
better design about this.
   
   We need to figure out how many rewrites are in a cycle. Since there is no 
`Vec` or other data structure, we cannot use a length, so we manually count and 
then record the cycle length at the end of the first pass. 
   
   Note that the dynamic dispatch API that I deleted from this PR does not have 
this problem, since we can simply set `cycle_length` to `vec.len()`.
   
   You can make this code to not have a special first pass if you wanted to 
make it simpler to understand. If you check `cycle_length.is_none()` in 
`record_cycle_length` before setting the `cycle_length`, you could call it at 
the end of each cycle and then you can just run everything in a single 
`try_fold` loop. However, I wanted to avoid unneccessary conditional  checks, 
so I run the first cycle, record the cycle length, the continue with the 
remaining cycles.


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to