refactor(core): canonical DType primitive constants#147
Merged
Conversation
Replace the no-arg non-nullable DType factories with shared immutable constants on the DType interface: - Primitives: DType.I8 … I64, U8 … U64, F16/F32/F64 - Others: DType.BOOL, UTF8, BINARY, NULL, VARIANT Removes the per-class private *_DTYPE fields in the encoders/decoders and the 130+ inline `new DType.X(false)` / factory call sites across all modules. Build a nullable column from a constant via asNullable(). Breaking (minor): the no-arg factories DType.i8()…f64(), bool_(), utf8(), binary(), null_(), variant() are removed. The decimal(..) / structBuilder() factories and the record constructors are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
a142285 to
06b1cc9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds shared, immutable non-nullable primitive
DTypeconstants and removes the per-class duplication.DType.I8 … I64,DType.U8 … U64,DType.F16/F32/F64— cached canonical instances on theDTypeinterface.DType.i8() … f64()→ use the constants (DType.i64()→DType.I64). Non-primitive factories (utf8(),bool_(),decimal(..)) and thePrimitiveconstructor are unchanged.DType.I64.asNullable()(the existingasNullable()/withNullable()method).Why
Six encoders/decoders each declared private
*_DTYPEfields and 30+ sites inlinednew DType.Primitive(PType.X, false)— the same handful of values, duplicated everywhere. One canonical set removes it.Kept as a one-method-per-variant public surface (constants +
asNullable()), not a 20-field holder, per the project's "small public APIs" rule. ADR 0009 is left as the historical record of the original factory design.Result
Primitiveleft in*/src/main.reference.md,tutorial.md) + CHANGELOG updated.🤖 Generated with Claude Code