suyashkumar / dicom

⚡High Performance DICOM Medical Image Parser in Go.
MIT License
950 stars 138 forks source link

Introduce FlatStatefulIterator, and ExhaustElementChannel #184

Closed suyashkumar closed 3 years ago

suyashkumar commented 3 years ago

This addresses the discussion in #183 by introducing a FlatStatefulIterator (that will be GC'd normally, even if it isn't exhausted). This also introduces ExhaustElementChannel which is an easy way for folks using the channel API to ensure it is always exhausted.

At some point either we should deprecate the channel-based API, or we should rename it so that it's not seen as the default for iteration (e.g. name it FlatChannelIterator or something). For most usecases, the stateful iterator should be sufficient.

Future improvements can we made to the stateful iterator, for example not recomputing the flat element representation if the dataset hasn't changed from a previous call.

suyashkumar commented 3 years ago

Thanks for the well thought out comments on the draft! Responded inline, and also pushed some updates. Will take this PR out of draft now as well.

suyashkumar commented 3 years ago

In the comments I will add a deprecated note on the existing iterator as well, and direct folks to use the stateful iterator, which will eventually become the default choice (pending some small benchmarks).

bpeake-illuscio commented 3 years ago

Sounds good!

suyashkumar commented 3 years ago

Going to go ahead and aim to get this first piece submitted shortly.