Fix double precision issues, improve serialized size of several repeating structures, removed automatic fields - #83
Merged
Conversation
…ayout Reworks the wire format so protobuf becomes a fully lossless binary mode that is smaller and faster than JSON on numeric-heavy data. Precision & fidelity - geometry.proto: all coordinate/scalar fields float -> double (PointData etc.), so float64 geometry round-trips exactly (coordinate error 0). - AnyData: explicit int64/double arms instead of routing numbers through google.protobuf.Value, so an integral float (0.0) no longer comes back as int. Makes Mesh/Graph fully lossless (canonical hash matches). Compact numeric layout - Mesh/Pointcloud/Polyline/Polygon/Bezier/Polyhedron: vertices/points stored as a flat packed `repeated double` (x,y,z triplets) instead of one PointData message per point (each of which also carried a per-point UUID + name). - MeshData faces in CSR form: flat `face_vertices` index array + `face_sizes` lengths, instead of one FaceList message per face. - Mesh/Graph attributes as inline `map<string, AnyData>` (dropped the DictData wrapper); empty/default maps are skipped so they cost zero bytes. - AnyData: explicit dict_value/list_value arms so plain nested dicts/lists no longer carry a google.protobuf.Any type_url (~44 bytes each). Cuts attribute- heavy meshes ~40% and helps Graph, fallback, and any nested container. Tests - Update test_json_structure_validation: a plain list now uses the listValue arm rather than an Any-wrapped message; round-trip tests unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replaces the per-vertex `map<string, AnyData> vertex_attributes` (a dict + repeated attribute-name string per vertex) with a `repeated AttributeColumn`: each attribute name is stored once alongside a packed value array. - Numeric columns use packed double / sint64 / bool arrays (no per-value message framing, bulk-decodable); mixed / non-numeric columns fall back to repeated AnyData. - Dense columns (every vertex carries the attribute) store no index array; sparse columns record the carrying vertex indices. Attribute-heavy meshes (mesh_attrs, 10k vertices, one float per vertex): wire 651 KB -> 398 KB and round-trip 130 ms -> 56 ms, now smaller AND faster to load than compact JSON. Sparse and mixed-type columns verified lossless. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Auto-generated guids and default names (the class name) are no longer written to the wire. An object serializes its guid only if `_guid` was explicitly set, and its name only if `_name` was set; on load, an absent guid means the receiver assigns its own lazily. This removes ~40 bytes of UUID + a name string from every object, including the Points/Vectors nested inside Lines, Frames, and shapes. Collections of shapes go from larger-than-JSON to smaller: boxes (10k) 3.4 MB -> 1.6 MB (JSON 2.7 MB); similar for spheres/circles/frames/lines. Canonical hash / __data__ are guid-independent, so round-trip fidelity is unchanged. Contract change: auto-generated guids no longer round-trip (they are session-local uuid4s and were never stable across save/load). Explicit guids still round-trip. Tests updated to assert the new contract (test_explicit_guid_is_preserved / test_auto_guid_is_not_serialized). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Generalizes the columnar attribute layout (previously mesh vertices only) and applies it to graphs. `_fill_attribute_columns` now takes an ordered list of attribute dicts plus an `exclude` set, so it serves mesh vertices (coordinates excluded, they live in a flat array) and graph nodes (nothing excluded, coordinates are node attributes). GraphData now stores: - node_keys once (as AnyData, preserving int/str/... keys), - node attributes column-wise (including x/y/z as packed double columns), - edges as index pairs into node_keys, with edge attributes column-wise. Grid graph (10k nodes): wire 931 KB -> 360 KB and round-trip 379 ms -> 83 ms, now ~2x smaller and ~2x faster to load than compact JSON. Arbitrary node keys, sparse and mixed-type node/edge attributes verified lossless. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Completes the columnar attribute layout for meshes: face and edge attributes now use `repeated AttributeColumn` like vertices, instead of `map<string, AnyData>`. Face columns are indexed by face position; edge columns are aligned to an `edge_keys` list (edges carry string keys). Empty/absent attribute sets cost nothing. With this, every per-element attribute collection in compas_pb is columnar: mesh vertices/faces/edges and graph nodes/edges. Populated face/edge attributes with mixed value types (float/str/bool) verified lossless. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deserialization now raises on a missing or incompatible wire version instead of warning and continuing. Because compas_pb reuses protobuf field numbers across format revisions, mismatched data can silently misparse rather than fail cleanly, so an unverifiable version must be refused. Compatibility is keyed on MAJOR.MINOR (under 0.x each minor may change the schema). The version string is unchanged here; bumping it at release time is what activates rejection of older data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RotationData encoded axis + angle, so the 4x4 matrix was recomputed on load and lost ~1e-16 (canonical hash mismatched). It now stores the flattened matrix directly, like every other transform (Scale/Shear/Reflection/Projection/Transformation), and reconstructs via Rotation.from_matrix. Rotations now round-trip bit-exact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The compat key was MAJOR.MINOR for all versions, which would wrongly reject a 1.0 -> 1.2 upgrade even though minor releases are backwards-compatible under SemVer. Now key on MAJOR.MINOR only under 0.x, and on MAJOR from 1.0 on, so 1.0 and 1.2 stay compatible while 2.0 is refused. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gonzalocasas
requested review from
chenkasirer and
Copilot
and removed request for
Copilot
July 11, 2026 12:25
Member
|
Amazing!!! 🚀 |
WeiTing1991
approved these changes
Jul 13, 2026
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.
This is a breaking change of the pb wire format, so, it will need a major release.
There's several things done in this PR, all of them driven by a benchmark to compare
compas_pbserialization size and speed against json and against other options. I will push the full benchmark code and results to core but here're the results so far:Full size samples

Full type coverage benchmark with smaller sizes

The summary of changes is:
repeated PointDatato use instead a flat-packgedrepeated doublelayoutrepeated AttributeColumnRotationto store lossless as a 4x4 matrix, I don't understand why it was done using axis angleWhat type of change is this?
Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.mdfile in theUnreleasedsection under the most fitting heading (e.g.Added,Changed,Removed).invoke test).invoke lint).compas.datastructures.Mesh.