-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
abcdff3
to
f552370
Compare
@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/> . |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
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
src/rdfjs.internal.ts
Outdated
There was a problem hiding this comment.
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.
src/resource/solidDataset.ts
Outdated
There was a problem hiding this comment.
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.
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