Fetch int-64 values from h5grove as binary to maintain precision#1747
Merged
Fetch int-64 values from h5grove as binary to maintain precision#1747
Conversation
a5b822d to
121b5c1
Compare
loichuder
reviewed
Jan 31, 2025
| return Int32Array; | ||
| case 64: // No support for 64-bit integer values in JS | ||
| case 64: | ||
| return undefined; |
Member
There was a problem hiding this comment.
Why not returning BigInt64Array here ?
Contributor
Author
There was a problem hiding this comment.
Sorry, should have explained: for the same reason I have a separate type union, a separate type guard, etc. — when both kinds of typed arrays are mixed together in a union, TypeScript goes wild:
- You can't invoke the
Big(U)Int64Arrayconstructors withnumber[], only withbigint[](sonew IntOrBigIntTypedArray(arr as number [] | bigint[])doesn't type-check) - You can't loop through the array, since
number[]andbigint[]aren't compatible.
Having a single function worked fine in h5grove-api since we invoke the typed array constructor with a buffer. However, it failed in useIgnoreFillValue, where we pass a number[]:
const DTypedArray = typedArrayFromDType(dataset.type);
// Cast fillValue in the type of the dataset values to be able to use `===` for the comparison
const fillValue =
DTypedArray && typeof wrappedFillValue[0] === 'number'
? new DTypedArray(wrappedFillValue as number[])[0]
: undefined;Arguably, perhaps useIgnoreValue should be reworked to support bigints as well... Seemed like a can of worms, though, so I went with a compromise.
6852665 to
0748093
Compare
121b5c1 to
4fef55e
Compare
loichuder
approved these changes
Feb 3, 2025
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.
Follows #1745 and closes #1679