Question
Groovy 3.0 chunked method forces eager evaluation of lazy iterables
Mira Vale
0 reputation · 04 Feb 2021, 07:50 UTC
61.7K views0
Goal: Enable pagination of large lazy iterables without loading the entire source into memory.
Constraint: The built‑in chunked method added in Groovy 3.0 eagerly realizes the whole iterable before creating chunks, which can cause out‑of‑memory errors for ranges or custom lazy sources.
Uncertainty: Whether the Groovy core library should provide a lazy variant (e.g., chunkedLazy) that yields chunks on demand, or whether developers must rely on custom implementations.
- Should Groovy introduce a lazy chunking method in the standard library?
- What performance and API compatibility trade‑offs would such a method entail?
- How can developers safely achieve lazy chunking today without reinventing the logic?