Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/arcadedb/graph_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,24 +489,16 @@ def new_edges(
row[key] = value
rows.append(row)

if not tagged:
import json

for start in range(0, len(rows), self._BULK_CHUNK):
edge_batcher.newEdgesJson(
self._java_graph_batch,
edge_type,
json.dumps(rows[start : start + self._BULK_CHUNK]),
)
return self

# Every chunk is written before the first one crosses, so a value the
# text cannot carry (a NaN, an integer beyond 64 bits or a date-time
# inside a list or map, a subnormal) can still start the per-edge
# path over with nothing buffered.
# path over with nothing buffered. The engine's JSON parser reads the
# text of a subnormal as a DECIMAL, so the untagged text is checked
# for one as well.
dumps = json_bulk_dumps_tagged if tagged else json_bulk_dumps
try:
texts = [
json_bulk_dumps_tagged(rows[start : start + self._BULK_CHUNK])
dumps(rows[start : start + self._BULK_CHUNK])
for start in range(0, len(rows), self._BULK_CHUNK)
]
except (TypeError, ValueError):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_bulk_json_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,14 @@ def test_text_that_only_looks_like_an_exponent_skips_the_subnormal_walk(monkeypa
type_conversion.json_bulk_dumps([{"x": 5e-324}])
with pytest.raises(ValueError):
type_conversion.json_bulk_dumps([{"x": 2.2250738585072009e-308}])


@pytest.mark.parametrize("entry", ENTRY_POINTS)
@pytest.mark.parametrize("value", [5e-324, -5e-324, 1e-310])
def test_subnormal_doubles_stay_doubles(temp_db_path, entry, value):
# the engine's JSON parser reads the text of a subnormal (5e-324) as a BigDecimal, so a bulk path that
# writes it unchecked stores a DECIMAL where every per-value path stores a double
with arcadedb.create_database(temp_db_path) as db:
_create_types(db)
(stored,) = _write(db, entry, value)
assert type(stored) is float and stored == value
Loading