Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop nesting blank nodes in internal structure #2368

Merged
merged 5 commits into from
Apr 9, 2024

Conversation

NSeydoux
Copy link
Contributor

@NSeydoux NSeydoux commented Mar 27, 2024

This changes the internal representation of RDF datasets so that Blank Nodes subjects are no longer nested, even if they are part of a single predicate chain. This approach was initially chosen to avoid generating unstable identifiers for these Blank Nodes, but it prevents browsing the potential Blank Nodes subjects that are part of a single chain when querying a Dataset. In particular, the library relying on immutability, a BN without an identifier cannot be used as the subject of a new quad.

As a result, more blank nodes may be returned by getThingAll(..., { acceptBlankNodes: true }), if they only appear as a link in a chain of blank nodes.

This is work that will help resolving #2339.

Checklist

  • All acceptance criteria are met.
  • Relevant documentation, if any, has been written/updated. N/A, this is an internal change
  • The changelog has been updated, if applicable.
  • Commits in this PR are minimal and have descriptive commit messages.

@NSeydoux NSeydoux force-pushed the fix/SDK-3296/nesting-blank-nodes branch from abcdff3 to f552370 Compare March 27, 2024 09:13
@prefix ex: <https://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@base <https://example.org/> .
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces the @base directive, because the URl resolution was incorrect.

@@ -212,7 +214,7 @@ describe("fromRdfJsDataset", () => {
expect(fromRdfJsDataset(rdfJsDataset)).toStrictEqual({
type: "Dataset",
graphs: {
default: {
default: expect.objectContaining({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer do exact matches on the internal representation, because of the unstable blank nodes identifiers.

Comment on lines +253 to +264
const subjectsExcludingBlankNodes = getThingAll(
fromRdfJsDataset(rdfJsDataset),
{ scope: acrGraphIriString },
);
const subjectsIncludingBlankNodes = getThingAll(
fromRdfJsDataset(rdfJsDataset),
{ scope: acrGraphIriString, acceptBlankNodes: true },
);
// There should be two blank nodes in the resulting dataset.
expect(
subjectsIncludingBlankNodes.length - subjectsExcludingBlankNodes.length,
).toBe(2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces the previous exact match of the internal structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are centered around removing the code that nested blank nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There used to be two separate implementations of the conversion of an RDFJS dataset into a SolidDataset. This refactors the code so that it is implemented only once.

@NSeydoux NSeydoux merged commit 4dbd3b7 into main Apr 9, 2024
30 checks passed
@NSeydoux NSeydoux deleted the fix/SDK-3296/nesting-blank-nodes branch April 9, 2024 15:18
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.

2 participants