Repository navigation
Add an in-memory Widen encoding for integers - #10864
Conversation
A registered VTable also gets a reader entry under its wire ID. For Narrow, which has no wire form yet, that entry can only fail, so it hides the allow_unknown foreign fallback and lists vortex.narrow in footers written without editions. NR1 (#10864) therefore leaves Narrow out of ArraySession, lowers every Narrow before the serializer lookup, and makes Narrow::serialize panic with a TODO. WR1 adds the registration together with the working deserializer. D26, the NR1 brief and the wire brief now say so. The NR1 brief also gets the final deprecation note of encode_values. Signed-off-by: Connor Tsui <[email protected]>
0f4366f to
479232c
Compare
NR1 (#10864) no longer lowers a Narrow in ArraySerializationTree. In NR1 nothing outside the tests creates a Narrow, so the branch protected no real path, and a branch specific to Narrow does not belong in the generic serializer while nothing needs it. Serializing a Narrow now fails like it does for any other unregistered in-memory encoding. D26 is now deferred to CD4, the first PR where a Narrow reaches writers in ordinary use. CD4 chooses between a lowering specific to Narrow, a generic lowering for arrays that cannot be written, and no lowering. The NR1 brief, the CD4 and WR1 briefs, the design and the plan now say so. Signed-off-by: Connor Tsui <[email protected]>
Merging this PR will regress 4 benchmarks3 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
| { | ||
| (*values_ptype, *logical_ptype) | ||
| } | ||
| _ => vortex_bail!("Narrow requires integer dtypes, got {values} values for {logical}"), |
There was a problem hiding this comment.
Note that in the future this will also check for Decimal
NR1 (#10864) gave vortex-array/src/arrays/narrow/ the layout of the other encodings: one file per operation in compute/, and the vtable in vtable/. The integer Narrow brief now describes that layout, and the NR3, NR4 and NR5 file tables put their code there. The CD4 and wire briefs point to the same section. Signed-off-by: Connor Tsui <[email protected]>
479232c to
76a4cce
Compare
| //! Take executes its gather instead of leaving a lazy [`Dict`] under a `Narrow`, because code such | ||
| //! as the DuckDB exporter and the dict layout writer looks for a `Dict` at the root of an array. |
Widen stores an integer array in a strictly narrower integer type with the same signedness and nullability. The values child holds the validity and can have any encoding. try_new and a reduce rule keep Widen arrays from nesting. Execution casts the values to the logical dtype, and probe_scalar casts each child scalar. WidenArray::encode stores a PrimitiveArray at the smallest integer type of the same signedness that holds its valid values. The deprecated encode_values returns the same narrower values without the Widen, for internal children whose parent chooses their dtype, so that each future caller is marked for its own decision. Widen has no wire form yet, so ArraySession does not register it, and serializing an array that holds a Widen fails as it does for any other encoding that is not registered. A registered Widen would add a reader entry that can only fail, which hides the allow_unknown foreign fallback and lists vortex.widen in footers written without editions. Signed-off-by: Connor Tsui <[email protected]>
Slice, filter, mask, cast and fill null run on the values and wrap the result in a Widen again, with the nullability of the result. A cast to a wider integer target of the same signedness keeps the values at their own type, so a cast to a non-nullable target still fails on a null. A cast to a float or to the other signedness, and a fill value outside the range of the values, fall back to canonical execution. Take is an execution kernel for the Dict parent. It executes the gather of the values, so that no lazy Dict sits under a Widen, where the DuckDB exporter and the dict layout writer would not find it. The compare kernel compares two Widen operands at the wider value type, and a constant inside the range of the values with the values. A constant outside that range gives the same answer for every valid row, so the kernel returns that answer with the validity of the values, as a ConstantArray when there are no nulls. The compute conformance suites run on each shared fixture. Signed-off-by: Connor Tsui <[email protected]>
76a4cce to
81f227f
Compare
A check of the briefs against NR1 (#10864) found nine mismatches. The NR3 kernels need a pub(crate) compute module, and the decode function moves to array.rs, because the vtable modules are private. The fastlanes test directory does not exist yet. There is no ZipFalseReduce trait, so NR4 writes that rule by hand, and it reuses integer_value instead of copying it. Narrow is not registered in ArraySession. The other fixes update moved line numbers and the NR2 session recipe. Signed-off-by: Connor Tsui <[email protected]>
The cast conformance suite casts an integer array only to integer types, so this test is the only one that covers the cast rule declining a float target, including the integer guard for unsigned values. It keeps one signed and one unsigned case. Signed-off-by: Connor Tsui <[email protected]>
robert3005
left a comment
There was a problem hiding this comment.
This should be called Widen and should be a ScalarFn
|
once someone fixes everything in here we can make this a scalar fn too: #9156 |
Replaced by a newer auto-merge request
fcb0046 to
75c7f4a
Compare
Narrow encoding for integersWiden encoding for integers
75c7f4a to
a56a48e
Compare
Auto-merge was disabled for another pull request in the stack
Summary
Widenencoding for integers and decimals #10733Read the tracking issue for context.
Note that this does not add Decimal support yet, though it will later.
Replaces #10223 and #10332, which are closed.
Changes
WidenArray::encodestores an integer array at the smallest width with the same signedness that holds its valid values. Slice, filter, mask, cast, fill null, take and compare run on the narrow values. Everything else, including aggregates and arithmetic until the next PRs in the stack, decodes through a cast, so results match the canonical array. Take executes eagerly instead of rewriting lazily, so that aDictstays at the root, where the DuckDB exporter and the dictionary layout writer look for it.Widenhas no wire form yet, soArraySessiondoes not register it until the wire format lands, and serializing an array that holds aWidenfails like it does for any other unregistered encoding. Registering it now would also add a reader entry that could only fail.WidenArray::encode_valuesis the deprecated variant that changes the dtype, for internal children such as list offsets and dictionary codes. The deprecation marks each future caller for its own decision.For review, read the commits one at a time.