-
Notifications
You must be signed in to change notification settings - Fork 560
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
Add optional graph argument to Graph.cbd, use for DESCRIBE queries #2322
Add optional graph argument to Graph.cbd, use for DESCRIBE queries #2322
Conversation
@mgberg this seems pretty useful. Another way to approach this may be to extract something which computes CBDs into a separate function freestanding, function, and then have that operate on a source and target graph. The benefit there would be that the graph interface remains smaller. I will think about it a bit. @westurner @niklasl any feedback from you would be appreciated here. |
Maybe |
2af262f
to
138e4f2
Compare
138e4f2
to
aa266bc
Compare
@mgberg it is slightly better to make pull requests from your personal account if you are making them across organizations, that way we can update your PR branch directly with suggestions. The pull requests mostly looks fine, but I think making I will make a PR against your branch doing that and adding some unit tests. |
Also added some tests for `Graph.cbd` with `target_graph`
PR here: corning-incorporated#2 |
…-to-cbd Make `target_graph` a keyword only arg
I'll do that in the future! |
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.
Change looks good to me, thanks @mgberg
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.
👍
Summary of changes
I often find myself wanting to create subgraphs including descriptions of multiple resources, so I end up doing some pattern like this:
While this works fine, there is overhead every time
cbd
is called:Graph
object is created each time.out_graph
, i.e. added to a graph a second time.This PR adds an optional
target_graph
argument to thecbd
method. If aGraph
is provided for that argument, the computed CBD is added directly to that provided graph instead of creating a new graph. Consequently, the above snippet could be written like this to avoid that extra overhead:If the
target_graph
argument is not provided, then it behaves the same as it currently does- it should not break any existing code.One place where this situation occurs is in the SPARQL DESCRIBE implementation. This PR tweaks that implementation to use this new argument to improve performance.
Checklist
the same change.
./examples
for new features.CHANGELOG.md
).so maintainers can fix minor issues and keep your PR up to date.