vortex icon indicating copy to clipboard operation
vortex copied to clipboard

Arrays to only return EncodingId, not Encoding

Open gatesn opened this issue 2 months ago • 0 comments

@AdamGS pointed out our API is a little odd here, where an array needs to hold onto its own encoding in order to return it. This isn't a problem for most of our static encodings, but gets weird when the encoding is not static.

The only place that Array::encoding is used is 1) to return encoding().id(), and 2) when serializing an array we build up an ArrayContext.

Right now, an ArrayRegistry is essentially HashMap<EncodingId, Encoding>. And an ArrayContext is Vec<Encoding> such that we can get a stable dictionary encoding of the encoding IDs.

We could remove the Array::encoding() API if we have an ArrayContext internally hold an ArrayRegistry, and a Vec<EncodingId> instead.

This does mean that any operation requiring the encoding needs access to the session's ArrayRegistry.

cc @joseph-isaacs for thoughts

gatesn avatar Oct 24 '25 15:10 gatesn