Skip to content

native: float64 arrays keep their doubles; to_json_list epoch millis floor in integer arithmetic - #176

Merged
tae898 merged 1 commit into
mainfrom
fix/native-codec-values
Nov 1, 2026
Merged

tae898 merged 1 commit into
mainfrom
fix/native-codec-values

Conversation

@tae898

@tae898 tae898 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #175

  • src/arcadedb/_native/codec.py: only float32 arrays take the float32 side buffer (binary mode) or the F tag; any other float array is sent as its doubles (tolist(), as row_default already did for insert_many). A float array as a positional ? is still narrowed to float32 (new _query_vector()), the documented query-vector rule that the JVM build applies too. Epoch milliseconds in to_json_list use integer arithmetic that floors (_epoch_millis), like Instant.toEpochMilli on the JVM side, for DATETIME, DATE and tz-aware values.
  • docs/.../how-to/databases-and-queries.adoc: the query-vector bullet now says positional float64 is float32 on both builds, while named, CONTENT :row and record float64 keep their doubles on both builds (and that a float64 array bound by name goes as text, slower than float32).
  • Tests (shared): tests/test_numpy_support.py::test_float64_array_keeps_its_doubles[_write_named|_write_content_named|_write_record], float32 guards on the same paths, the positional rule; tests/test_resultset.py::test_to_json_list_datetime_is_the_floored_epoch_millis[DATETIME_MICROS|DATETIME].

Verification: against the 26.11.1.dev0 wheels of main the native wheel fails the three float64 tests (0.10000000149011612 != 0.1) and the DATETIME_MICROS epoch test (0 != -1) and passes the guards; the JVM wheel passes all nine. black, isort, pyflakes, bandit clean. The fixed native build is tested by this PR's test-native.yml run.

🤖 Generated with Claude Code

…arithmetic

A1: a float64 ndarray bound by name, inside CONTENT :row or set on a record went
through the float32 side buffer in binary mode (and the "F" tag, a float[] in
Java, in text mode), so 0.1 was stored as 0.10000000149011612 while the JVM build
stores the double. Only float32 arrays take the side buffer now; any other float
array is its tolist(). A float array among the positional parameters stays a
query vector sent as float32 (encode_params narrows it first, as
Database._convert_args does on the JVM build), as documented.

C1: json_native computed epoch milliseconds as int(total_seconds() * 1000), which
rounds toward zero before 1970, rolled 9999-12-31 23:59:59.999999 into year
10000 and could land 1 ms low on exact milliseconds. Integer days/seconds/
microseconds arithmetic, floored like Instant.toEpochMilli.

Tests are shared by both builds. Docs: the query vector note now says named,
CONTENT and record float64 arrays keep their doubles on both builds.

Against the main 26.11.1.dev0 wheels the native wheel fails the three float64 tests and the DATETIME_MICROS epoch test and the JVM wheel passes all nine.

Closes #175

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit a19397a into main Nov 1, 2026
37 checks passed
@tae898
tae898 deleted the fix/native-codec-values branch November 1, 2026 13:09
tae898 added a commit that referenced this pull request Nov 1, 2026
…after DROP INDEX (#186) (#187)

The query-vector list bullet said a float64 array crosses as one buffer on
the JVM build with no value change; since #176 a positional float64 array
is narrowed to float32 on both builds (the next bullet). The vectors page
now says what #166 made true on both builds: held index reads ask the
engine, raise with the index name after DROP INDEX, and report a
re-created index's own configuration.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

native: float64 arrays bound by name or saved on a record are stored as float32; to_json_list epoch millis 1 ms off

1 participant