Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent infinite loop while writing on CategoricalArrays (#44)
Supporting CategoricalArrays is a bit tricky. Ideally, we could use the same interface as PooledArrays and just rely on `DataAPI.refarray` and `DataAPI.refpool`, but alas, a `CategoricalArray` returns a `CategoricalRefPool` from `DataAPI.refpool`, with `CategoricalValue` elements. The core issue comes when we try to serialize the pool, which is a recursive process: recursive until we reach a known "leaf" type, at which point the recursion stops. Unfortunately, a `CategoricalValue` isn't a known leaf type, so it's treated as a `StructType`, where each of its fields are serialized. One of the fields is the `CategoricalRefPool`, so we get stuck in a never-ending recursive loop serializing `CategoricalValue`s and `CategoricalRefPool`s. This PR proposes a quick hack where we check the `DataType` name for `:CategoricalRefPool` or `:CategoricalArray` and if so, just unwrap the values so the recursion will be broken. It's obviously a little hacky, but also avoids taking on the always-problematic CategoricalArrays dependency.
- Loading branch information