zarr-specs icon indicating copy to clipboard operation
zarr-specs copied to clipboard

Tracking intermediate buffer sizes (in ZEP 2 or otherwise)

Open jakirkham opened this issue 2 years ago • 2 comments

Currently if a pipeline of codecs is used, it would be useful to track the intermediate sizes of the buffers as they are transformed so that enough scratch space can be allocated to decode data efficiently

jakirkham avatar Nov 01 '23 07:11 jakirkham

When it can be determined independent of the data, just based on e.g. shapes, implementations can already (and do already) do this. Some compression codecs also store the decoded size. In general, though, it might be necessary to store an additional size field along with the encoded data. Is that what you are proposing?

jbms avatar Nov 01 '23 14:11 jbms

Indeed for the case of a single codec, this is unneeded

Think it comes up in cases when codecs are chained. For example using run-length encoding or bit packing followed by another compressor. It would be helpful to know what size the buffer between those steps is for decoding so as to allocate for it appropriately

Yeah this is what I'm thinking

It's possible the exact size of any intermediate buffers is not strictly necessary, but instead some largest intermediate buffer seen may be good enough. In this way it might be similar to Python's __length_hint__

jakirkham avatar Nov 01 '23 21:11 jakirkham