Skip to content

Add canonical Map arrays and builder - #9108

Merged
AdamGS merged 1 commit into
developfrom
adamg/maptype-2
Aug 4, 2026
Merged

AdamGS merged 1 commit into
developfrom
adamg/maptype-2

Conversation

@AdamGS

@AdamGS AdamGS commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

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?

  • Adds the vortex.map canonical encoding, backed by ListView<Struct<key, value>> storage while retaining the Map dtype and keys_sorted assertion.
  • Adds MapArray, validated construction, entry access, validity delegation, scalar access, serialization, and session registration.
  • Adds MapBuilder and integrates Map values with generic builder and canonicalization paths, including empty, constant, and chunked arrays.
  • Tests cover valid and malformed storage, nullable and empty values, duplicate and unsorted keys, builder append behavior, canonicalization, scalar access, and serialization round-trips.

What APIs are changed? Are there any user-facing changes?

This adds the public Map, MapArray, MapArrayExt, MapDataParts, and MapBuilder APIs. Canonical and CanonicalView gain 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.

@codspeed

codspeed Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 14.39%

⚡ 3 improved benchmarks
✅ 1839 untouched benchmarks
⏩ 44 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Simulation new_raw_prim_test_between[i32, 2048] 89.7 µs 77 µs +16.37%
⚡ Simulation execute_scalar_struct_simple 1.2 ms 1.1 ms +14.29%
⚡ Simulation execute_scalar_struct_wide 5.7 ms 5 ms +12.55%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing adamg/maptype-2 (9d1e363) with develop (fd43ebd)2

Open in CodSpeed

Footnotes

  1. 44 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on develop (bc9aa10) during the generation of this report, so fd43ebd was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@AdamGS AdamGS added the changelog/feature A new feature label Jul 31, 2026
@AdamGS
AdamGS force-pushed the adamg/maptype-2 branch from 448cba5 to 7d9ceb3 Compare July 31, 2026 11:40
@AdamGS
AdamGS force-pushed the adamg/maptype-2 branch from 7d9ceb3 to dce5a97 Compare July 31, 2026 11:52
@AdamGS
AdamGS force-pushed the adamg/maptype-2 branch 2 times, most recently from b158bfe to bc1872e Compare July 31, 2026 13:17
builder: &mut dyn ArrayBuilder,
ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
builder.append_map_array(array, ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't do this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downcast the builder here

Comment thread vortex-array/src/builders/mod.rs Outdated
///
/// 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you rebase the listview/list array methods are gone

@AdamGS
AdamGS force-pushed the adamg/maptype-2 branch 3 times, most recently from 1ff6f07 to 364b5d2 Compare August 4, 2026 12:38
@AdamGS
AdamGS marked this pull request as ready for review August 4, 2026 14:48
Base automatically changed from adamg/maptype-1 to develop August 4, 2026 14:49
AdamGS added a commit that referenced this pull request Aug 4, 2026
## 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>
@AdamGS
AdamGS merged commit 490dfac into develop Aug 4, 2026
83 of 84 checks passed
@AdamGS
AdamGS deleted the adamg/maptype-2 branch August 4, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants