Skip to content

TUR-302: Storage: implement a point property type - #1333

Merged
rjb32 merged 1 commit into
mainfrom
remyboutonnet/tur-302-1-point-type
Nov 6, 2026
Merged

rjb32 merged 1 commit into
mainfrom
remyboutonnet/tur-302-1-point-type

Conversation

@rjb32

@rjb32 rjb32 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Implement a point property type.

@rjb32

rjb32 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Note

AI-generated summary.

Summary

Goal. Add Neo4j's point as a stored property type, so CREATE (:City {at: point({longitude: 2.3522, latitude: 48.8566})}) stores a point and RETURN n.at reads back point({x: 2.3522, y: 48.8566, crs: 'wgs-84'}).

Approach. ValueType::Point and CellTag::Point are appended before their sentinels. db::Point is 32 trivially copyable bytes: x, y, z as doubles, a one-byte PointCRS (cartesian, cartesian-3d, wgs-84, wgs-84-3d) and zeroed padding. The constructor makes equal points equal in every byte, so dumps, EncodedList comparisons and DISTINCT keys compare raw bytes. point(map) follows Neo4j's PointValue.fromInputFields. The type is threaded through storage, dump/load, the v3 dialects (!storage.point, db.to_point), the binary protocol (POINT = 22), Python and npm.

Where to look.

  • storage/metadata/Point.h:36 Point: the layout and its invariants
  • storage/metadata/Point.cpp:263 Point::Point: validation, longitude wrap, -0.0 normalisation
  • storage/metadata/Point.cpp:453 Point::fromMap: the point() key rules
  • storage/dump/PropertyContainerDumpConstants.h:23: the static_asserts pinning the on-disk layout
  • storage/CellOrder.cpp:33 CellOrderClass: points sort after paths and before datetimes, as in Neo4j
point({longitude, latitude[, height]})   wgs-84 / wgs-84-3d
point({x, y[, z]})                       cartesian / cartesian-3d
point({..., crs: 'wgs-84'}) | srid: 4326 explicit CRS; both raises
null map or null value                   null
non-finite, latitude past 90, wrong dimension, string coordinate   raises
longitude past 180                       wrapped

Evidence

  • Before: main has no point function and no point property type.
    After:
    test_query_ir_point_property          [  PASSED  ] 36 tests.
    test_query_ir_point_value_flow        [  PASSED  ] 17 tests.   CASE, coalesce, UNION, joins, MERGE, map projection
    test_storage_point                    [  PASSED  ] 9 tests.
    test_storage_dump_point_graph         [  PASSED  ] 3 tests.    nodes, edges, lists and maps of points
    test_storage_dump_propertydumpformat  pointDumpBytes hash pinned, deterministic over two runs
    test_storage_dump_celltagdumpformat   listAndMapHoldingAPointOfEveryCRS hash pinned
    test_net_turing_proto_roundtrip       [  PASSED  ] 40 tests.   RoundTripsPointColumnsAcrossChunkSizes
    wasm/npm client_smoke.mjs             passed: ..., points
    ctest                                 100% tests passed, 0 tests failed out of 1164
    
    Checked by hand against a server: BinaryClient returns Point(srid=7203, x=1.0, y=2.0, z=None), and the npm client returns {"srid":4979,"x":3,"y":4,"z":5}.

Merge Danger

Door: one-way

ValueType::Point = 11, CellTag::Point = 14, the PointCRS ordinals and the 32-byte layout go into every datapart written from now on, and POINT = 22 into the wire protocol.

Blast Radius: storage

Every switch over ValueType and CellTag gains a case. Clients older than this one cannot decode a POINT column.

@rjb32
rjb32 added this pull request to stack #1347 November 5, 2026 22:38
@rjb32
rjb32 force-pushed the remyboutonnet/tur-302-1-point-type branch 2 times, most recently from 2f7899c to f7d7f49 Compare November 6, 2026 15:59
@rjb32
rjb32 force-pushed the remyboutonnet/tur-302-1-point-type branch from f7d7f49 to 7c9742d Compare November 6, 2026 19:19
@rjb32
rjb32 removed this pull request from stack #1347 November 6, 2026 19:36
@rjb32
rjb32 merged commit 7c9742d into main Nov 6, 2026
2 checks passed
@rjb32
rjb32 deleted the remyboutonnet/tur-302-1-point-type branch November 6, 2026 19:37
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.

1 participant