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

Better handling of several special cases for TransitivePaths. #284

Merged
merged 5 commits into from Sep 24, 2019

Conversation

floriankramer
Copy link
Member

This pr attempts to improve the speed of TransitivePath operations by limiting the number of source vertices. To this end:

  • TransitivePath operations with a fixed right end now invert the input edges and run a dfs from the single right node
  • A transitive path operation can replace a join between a transitive path and another operation to reduce the amount of tree explorations (dfs) that need to be run

@floriankramer
Copy link
Member Author

floriankramer commented Sep 13, 2019

The query

PREFIX p: <http://www.wikidata.org/prop/> 
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wdt: <http://www.wikidata.org/prop/direct/> 
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?person ?r WHERE {
  ?person (<http://www.wikidata.org/prop/direct/P166>)/((^<http://www.wikidata.org/prop/direct/P31>)?) ?r
}

Is incredibly slow, as the inverse of P31 has a lot of edges for every node on the left side. To handle that case better I switched from vectors to HashSets for the storage of a nodes edges in the latest commit.

Copy link
Member

@niklas88 niklas88 left a comment

Choose a reason for hiding this comment

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

This looks great, I found two copy and paste fix omissions but other than that the code looks solid as always.

std::shared_ptr<QueryExecutionTree> leftop, size_t inputCol) const;

/**
* Returns a new TransitivePath operation that uses the fact that leftop
Copy link
Member

Choose a reason for hiding this comment

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

s/left/right/

std::shared_ptr<QueryExecutionTree> _leftSideTree;
size_t _leftSideCol;

// If this is not nullptr then the left side of all paths is within the result
Copy link
Member

Choose a reason for hiding this comment

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

s/left/right

@floriankramer floriankramer merged commit f2ece56 into ad-freiburg:master Sep 24, 2019
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.

None yet

2 participants