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

Refactoring the ParsedQuery class #323

Merged
merged 12 commits into from Apr 24, 2020

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Apr 16, 2020

  • The suboperations previously contained a union for the different types (Subquery, Optional, Union + some we have yet to implement) plus a separate tag, which type was in use. This is now refactored as a std::variant which is more modern and more explicit, since the "data storage" and the name of the Suboperation type are much closer connected.

  • The ParsedQuery class previously used std::shared_ptr all over the place when there was neither

    • shared ownership
    • Polymorphism
    • a performance need to do so (the ParsedQuery is built exactly once during the Parsing
      and is typically never copied and relatively cheap to copy and basically free to move.
      Even worse, typically the copy constructors of types were manually specified to ignore the shared_ownership and copy the held data which really defeats the purpose and signals, that is was the wrong tool here.

These places are now all refactored to hold the data directly + The use of typically mechanisms to pass them to functions (const T& for const access, T* for readWrite access).

  • This makes the code much simpler, as Copy and Move constructors can now be defaulted and
    since many calls to shared_ptr<T>.get() and to make_shared can be removed.

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.

LGTM and I really like how clean this is now!

} else if constexpr (std::is_same_v<T,
GraphPatternOperation::TransPath>) {
AD_CHECK(false);
// we may never be in an transitive path here or a
Copy link
Member

Choose a reason for hiding this comment

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

The property paths are not yet expanded into trees of operations, thats done in the QueryPlanner. Due to that they are currently all contained in a triple, and the TransPath GraphPatternOperation cannot appear here. Instead, the prefix expansion is done as part of the prefix expansion of triples, a few lines below this one.

@floriankramer floriankramer merged commit 03777b6 into ad-freiburg:master Apr 24, 2020
@joka921 joka921 deleted the f.parsedQueryRefactor branch September 13, 2022 12:24
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

3 participants