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

Add concepts and concrete types for BlockZipperJoinImpl #1625

Merged
merged 5 commits into from
Nov 29, 2024

Conversation

RobinTF
Copy link
Collaborator

@RobinTF RobinTF commented Nov 18, 2024

This class (which is the central implementation of the lazy merge join) previously had a lot of const auto& etc. parameters, which made the (already rather complex) code harder to reason about. This PR adds concrete types wherever possible, and constrains the other parameters using concepts.

if (allBlocksWereFilled) {
blockStatus = BlockStatus::allFilled;
}
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here, self is swapped with this

AD_CORRECTNESS_CHECK(!lessThan_(lastProcessedElement,
std::as_const(blocks.front()).back()));
AD_CORRECTNESS_CHECK(
!lessThan_(lastProcessedElement, blocks.front().back()));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here as_const is dropped. This presumably works because of recent fixes to the IdTable class.

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.38%. Comparing base (add092a) to head (a9b7af7).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1625   +/-   ##
=======================================
  Coverage   89.37%   89.38%           
=======================================
  Files         375      375           
  Lines       36107    36107           
  Branches     4077     4077           
=======================================
+ Hits        32272    32274    +2     
+ Misses       2518     2516    -2     
  Partials     1317     1317           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

I have a rant about code duplication, read it, think about it, comment it, and then do something about it or don't depending on the outcome of the thought.
Probably there's nothing to do...

@@ -1228,7 +1253,8 @@ struct BlockZipperJoinImpl {
// `side.undefBlocks_` and skipped for subsequent processing. The first block
// containing defined values is split and the defined part is stored in
// `side.currentBlocks_`.
void findFirstBlockWithoutUndef(auto& side) {
void findFirstBlockWithoutUndef(
ad_utility::SameAsAny<LeftSide, RightSide> auto& side) {
Copy link
Member

Choose a reason for hiding this comment

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

The only concepts you are using are SameAsAny<LeftSide, RightSide> and SameAsAny<CurrentBlocksLeft, CurrentBlocksRight>.
Can we explore if we can remove some of the redundancy?
My first approach is: With concepts it doesn't work, they can't be local, you cant shorten their names, etc.

So a syntax could be to have a static constexpr bool and then write

template <typename T> requires LeftOrRightSide<T>

But that is not at all shorter....

If you want to....
Bad word Bad word Bad word...

** MACRO **

(don't forget to Undef it).

But maybe this all isn't worth it.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

A very minor suggestion, that should be easily implementable.

Comment on lines 761 to 763
// We can't define aliases for these concepts, so we use macros instead.
#define Side SameAsAny<LeftSide, RightSide> auto
#define Blocks SameAsAny<LeftBlocks, RightBlocks> auto
Copy link
Member

Choose a reason for hiding this comment

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

To be ultra safe,
pleas do an #if defined(Side) || defined(Blocks) ERROR(...) to guarantee that we don't accidentally overwrite any macros and introduce bugs that are impossibly to trace....

@sparql-conformance
Copy link

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Thank you very much, I will merge this once the checks have run through.

@joka921 joka921 changed the title Add concepts and concrete types where possible for BlockZipperJoinImpl Add concepts and concrete types for BlockZipperJoinImpl Nov 29, 2024
@joka921 joka921 merged commit 527f7bf into ad-freiburg:master Nov 29, 2024
22 checks passed
@RobinTF RobinTF deleted the join-algorithm-polishing branch November 29, 2024 09:18
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.

2 participants