Repository navigation
fix(node): give every element of a struct-built array its own id - #202
Open
ehennestad wants to merge 1 commit into
Open
ehennestad wants to merge 1 commit into
ehennestad wants to merge 1 commit into
Conversation
The Node constructor preallocates the object array for a struct array with obj(1, n) = feval(class(obj)). MATLAB fills the elements between the first and the last with copies of one default object, so those copies carry the same generated blank-node id. fromStruct assigns an id only from at_id or x_id, which embedded values do not have, and the final loop regenerates only empty ids. From four embedded values of one type onwards, two or more therefore shared an id, the property holding them failed mustBeListOfUniqueItems, and the deserializer dropped the owning node with "Value must be an array of unique instances". Generate an id for every element right after preallocation. fromStruct still replaces it when the struct carries an identifier. Tests: a File with four embedded Hash values survives a JSON-LD round trip, and a Hash array built from four id-less structs has four distinct blank-node ids. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Test Results (R2022a)860 tests - 260 856 ✅ - 246 5m 16s ⏱️ -25s Results for commit 6626280. ± Comparison against base commit ba78412. This pull request removes 262 and adds 2 tests. Note that renamed tests count towards both. |
Contributor
Test Results (R2026a)860 tests - 260 858 ✅ - 245 5m 43s ⏱️ - 3m 11s Results for commit 6626280. ± Comparison against base commit ba78412. This pull request removes 262 and adds 2 tests. Note that renamed tests count towards both. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
==========================================
- Coverage 80.37% 80.11% -0.27%
==========================================
Files 424 424
Lines 4403 4425 +22
==========================================
+ Hits 3539 3545 +6
- Misses 864 880 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
When
openminds.Nodebuilds an object array from a struct array it preallocates withobj(1, numel(instance)) = feval(class(obj)). MATLAB fills the elements in between with copies of one default object, so they are distinct handles that all carry the id that one object generated.fromStructreplaces the id only when the struct carries one, and the constructor's final loop only generates ids that are empty, so embedded nodes, which have no@idin a document, keep the shared id.With four or more embedded values of one type, the parent property's
mustBeListOfUniqueItemsvalidator rejects the array and the deserializer drops the parent node with "Value must be an array of unique instances". Three or fewer values leave a single gap element and load; mixed-type arrays take a different path and load. Seen with aDatasetVersionholding seven embeddedContributionvalues, which openMINDS_MATLAB 0.12.0 dropped on load.Right after the preallocation, every element now gets its own blank-node id.
fromStructstill replaces it when the struct carries an identifier.Two tests cover it.
InstanceTest/testStructArrayWithoutIdsGetsDistinctIdsbuilds fourHashvalues from id-less structs and checks four distinct ids in struct order.CollectionTest/testEmbeddedArrayOfFourSurvivesRoundTripsaves aFilewith four embeddedHashvalues and reloads it with four distinct ids and the digests in order.FileandHashare used because they are the same in v4 and v5, while theDatasetVersionproperty isotherContributionin v4 andcontributionin v5.🤖 Generated with Claude Code