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 lazy computation to SERVICE #1514

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

UNEXENU
Copy link
Contributor

@UNEXENU UNEXENU commented Sep 24, 2024

Enables the SERVICE to compute it's result lazily, s.t. when requestLaziness is set in the call to Service::computeResult the result will contain a generator<IdTable> instead of fully materializing it.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.13%. Comparing base (85793e3) to head (8eb8785).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1514   +/-   ##
=======================================
  Coverage   88.12%   88.13%           
=======================================
  Files         357      357           
  Lines       26764    26779   +15     
  Branches     3606     3609    +3     
=======================================
+ Hits        23587    23602   +15     
+ Misses       1941     1940    -1     
- Partials     1236     1237    +1     

☔ 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.

Looks great, only minor suggestions remaining.

Comment on lines 193 to 198
// For the non-lazy case the generator is supposed to yield exactly one
// idTable.
auto iterator = generator.begin();
AD_CORRECTNESS_CHECK(iterator != generator.end());
IdTable idTable = std::move(*iterator);
AD_CORRECTNESS_CHECK(++iterator == generator.end());
Copy link
Member

Choose a reason for hiding this comment

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

We should have this as a (probably templated) helper function getSingleElement(generator<Irgendwas>) in Generator.h , then all the lazy operations can use this (you have copied this from filter or GroupBy,have you.

Copy link
Member

Choose a reason for hiding this comment

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

And of course don't forget to

  1. Add unit tests for this
  2. Also integrate it into Filter.cpp and GroupBy.cpp

src/engine/Service.cpp Show resolved Hide resolved
Comment on lines 423 to 424
for ([[maybe_unused]] auto& _ : lazyResult.idTables()) {
}
Copy link
Member

Choose a reason for hiding this comment

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

You should of course check the result. You can for example initialize an IdTable, and append all the partial results via insertAtEnd.

boost::beast::http::status::ok, "application/sparql-results+json")};

AD_EXPECT_THROW_WITH_MESSAGE(
service8.computeResultOnlyForTesting(),
Copy link
Member

Choose a reason for hiding this comment

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

This is not lazy, am i right?
When being lazy, you should probably see an error during the consumation of the generator (at least for the invalid Json kind of error.

Copy link

sonarcloud bot commented Sep 27, 2024

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