spiraldb / vortex

An extensible, state-of-the-art columnar file format
https://vortex.dev
Apache License 2.0
991 stars 27 forks source link

Add Array::is_some(array_data) for cheaper downcast #1377

Open gatesn opened 3 days ago

gatesn commented 3 days ago

Currently we use SomeArray::try_from(array_data) all over the place, but this incurs a large cost of creating backtraces.

We do have array_data.is_encoding(SomeEncoding.id()) but it's a bit clunky.

Proposal is for SomeArray::is_some(array_data) -> Option<SomeArray>

robert3005 commented 3 days ago

as_some? Is_some returning non bool is very weird imho. Is_encoding is only useful if you don’t want to convert the array data to an encoding, ie do some upfront validation

gatesn commented 3 days ago

SomeArray::maybe_from(array_data)