Implement stable blank node ordering#66
Merged
Merged
Conversation
Blank node ordering had been consistent if formatting a preexisting ordering, but not predictable for an in-memory graph. This commit introduces partial ordering of blank nodes - those that are to be serialized as siblings. Their ordering is based on a key calculated from the triples they appear in. If needed for disambiguation, this is done recursively 3 times. After that, blank nodes compare as equal and will be ordered randomly. Bnode comparison keys are cached in a bounded map holding 100 x max 3 keys (one for each recursion layer).
fkleedorfer
force-pushed
the
stable-blanknode-ordering
branch
2 times, most recently
from
July 8, 2026 13:10
fa98e04 to
b69aac0
Compare
Contributor
Author
|
@atextor The PR for diffplug/spotless is already underway, but I don't want to merge before we get this PR here into a cool-rdf release (if you want it), so spotless can use the stable blank node order when the PR there is merged. |
The formatting style option `preserveBlankNodeLabelsAndOrdering` (default `true`) is added that governs whether the ordering and labels of blank nodes found in the source document is to be used or overriden according to the result of the stable blank node ordering algorithm. When `false` rdf parsing is done without using the blank node aware parser necessary for preserving ordering and labels.
3 tasks
fkleedorfer
force-pushed
the
stable-blanknode-ordering
branch
from
July 8, 2026 13:31
b69aac0 to
489b377
Compare
Contributor
Author
|
Done |
atextor
approved these changes
Jul 11, 2026
atextor
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! Thanks for your contribution @fkleedorfer !
Collaborator
For completness' sake: Yes, I'd like to do a release with the fix as soon as I have time for it. |
Collaborator
|
@fkleedorfer cool-rdf 2.0.1 including the fix has been released. |
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.
Blank node ordering had been stable if formatting a preexisting serialization, but not stable for an in-memory graph. This commit introduces partial ordering of blank nodes - those that are to be serialized as siblings. Their ordering is based on a key calculated from the triples they appear in. If needed for disambiguation, this is done recursively 3 times. After that, blank nodes compare as equal and will be ordered randomly. Bnode comparison keys are cached in a bounded map holding 100 x max 3 keys (one for each recursion layer).