Repository navigation
Add canonical Map arrays and builder - #9108
Conversation
Merging this PR will improve performance by 14.39%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
b158bfe to
bc1872e
Compare
| builder: &mut dyn ArrayBuilder, | ||
| ctx: &mut ExecutionCtx, | ||
| ) -> VortexResult<()> { | ||
| builder.append_map_array(array, ctx) |
There was a problem hiding this comment.
downcast the builder here
| /// | ||
| /// Only map-typed builders support this; canonical map arrays dispatch through this hook so | ||
| /// the generic offset and size types of their nested list-view builders stay erased. | ||
| fn append_map_array( |
There was a problem hiding this comment.
If you rebase the listview/list array methods are gone
1ff6f07 to
364b5d2
Compare
## Rationale for this change Vortex currently has no native logical map type, so Arrow maps must be represented as lists of structs and lose map-specific semantics such as non-null keys and the `keys_sorted` assertion. This provides the type-level foundation for native Map support; #9108 builds on it with canonical arrays and builders. Related to #428. ## What changes are included in this PR? - Adds `DType::Map` and `MapDType`, including key/value dtypes, outer nullability, sortedness, validation, coercion, display, equality, and hashing. - Adds map scalar construction and typed access through `Scalar::map`, `Scalar::try_map`, and `MapScalar`. - Adds map dtype and scalar serialization through Serde, Protobuf, and FlatBuffers. - Adds Arrow dtype/schema round-tripping, Vortex-to-Arrow map scalar conversion, and DataFusion physical-schema reconciliation. - Tests cover dtype and scalar validation, null and empty maps, coercion, serialization round-trips, Arrow schema conversion, and nested extension metadata. ## What APIs are changed? Are there any user-facing changes? This adds the public `DType::Map` and `ScalarValue::Map` variants, `MapDType`, `MapScalar`, and their constructors and accessors. Consumers that exhaustively match `DType` or `ScalarValue` must handle the new variants. The Protobuf and FlatBuffers dtype schemas also gain Map variants. This PR supports Map dtypes, schemas, and scalars, but not full Arrow `MapArray` transport. Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Rationale for this change
Building on the logical type and scalar support in #9107, this makes map-typed arrays constructible, canonicalizable, and serializable. A dedicated canonical representation preserves Map semantics instead of treating maps as ordinary lists of structs.
What changes are included in this PR?
vortex.mapcanonical encoding, backed byListView<Struct<key, value>>storage while retaining the Map dtype andkeys_sortedassertion.MapArray, validated construction, entry access, validity delegation, scalar access, serialization, and session registration.MapBuilderand integrates Map values with generic builder and canonicalization paths, including empty, constant, and chunked arrays.What APIs are changed? Are there any user-facing changes?
This adds the public
Map,MapArray,MapArrayExt,MapDataParts, andMapBuilderAPIs.CanonicalandCanonicalViewgain Map variants and corresponding accessors, so exhaustive matches over those enums must handle Map arrays.Map arrays can now be built, canonicalized, inspected, and serialized. Compute paths such as take, filter, masking, compression, and Arrow array transport continue to reject Map arrays at this point in the stack.