Skip to content

GH 1868 zero-length paths must not match absent nodes#4032

Open
ThomasThelen wants to merge 2 commits into
apache:mainfrom
ThomasThelen:issue_1868
Open

GH 1868 zero-length paths must not match absent nodes#4032
ThomasThelen wants to merge 2 commits into
apache:mainfrom
ThomasThelen:issue_1868

Conversation

@ThomasThelen

@ThomasThelen ThomasThelen commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

GitHub issue resolved #1868

Pull request Description:

This is a bit of an experimental path taken. Initially I had done this with a longer walking of the AST and realized that the performance hit would be too big because evalGroundedPath gets called on each binding.

Instead, the approach that I took here is to hardcode the zero length component state as part of the various path classes, culminating in the dispatch to evalGroundedPath. This should get called once rather than the n times for each row in my previous AST implementation.

Happy to provide performance tests, address feedback, or close this if it's a bit far fetched.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

@rvesse rvesse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix looks quite straightforward and elegant to me, it's been a while since I've been delving in the SPARQL engine internals so I will leave this open for now to give others with fresher eyes chance to review before merging

@afs

afs commented Jul 2, 2026

Copy link
Copy Markdown
Member

I'd like time to explore all the possibilities with complex paths to convince myself that pulling the test up to the evaluation is always correct. (Finding clear "think" time is hard.)

protected static final int hashShortest = 0x205 ;


// Return true if this path can match in zero steps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't necessary because it is a default method in the interface.
(and it generates a warning because there is no @Override.)

Comment thread jena-arq/src/main/java/org/apache/jena/sparql/path/Path.java Outdated
Co-authored-by: Andy Seaborne <andy@apache.org>
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.

Optimization error for zero property path.

3 participants