Skip to content

add cast_value - #83

Open
konstibob wants to merge 4 commits into
zarr-developers:mainfrom
konstibob:feat/cast_value_codec
Open

add cast_value#83
konstibob wants to merge 4 commits into
zarr-developers:mainfrom
konstibob:feat/cast_value_codec

Conversation

@konstibob

Copy link
Copy Markdown
Contributor

implemented cast_value codec, split the value converter into seperate file to make code more clear / structured

konstibob and others added 4 commits July 24, 2026 14:18
…t_value

Fix zarr-developers#1 (correctness): CastValueConverter.roundToFloat/roundToDouble treated
nearest-away as nearest-even for floating-point targets, so exact ties rounded
to even instead of away from zero (spec violation for float->float narrowing).
Both now round ties away from zero and fall back to nearest for non-ties.

Fix zarr-developers#2 (performance): castArray now dispatches common casts (identity,
float<->float, integer->integer) to primitive-arithmetic paths, avoiding the
per-element Scalar/BigDecimal/BigInteger allocation of the exact path. Casts
with scalar_map, uint64, or float directed-rounding fall back to the exact path,
which remains the correctness reference.

Adds tests for the float nearest-away tie and the integer/identity fast paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Drop the unused DataType target parameter from the roundTrip test helper
  (the target already lives in the Configuration).
- Reference parseFillValue via its defining class dev.zarr.zarrjava.core.ArrayMetadata
  instead of the v3 subclass.
- Add uint64-above-Long.MAX_VALUE coverage, exercising the exact unsigned cast
  path (large fill value) and the identity fast path (array data).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@normanrz normanrz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.
Claude added a fast-path for common conversions and fixed an issue with nearest-away float rounding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants