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

Limit number of hops #1928

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

Limit number of hops #1928

wants to merge 59 commits into from

Conversation

DavIvek
Copy link
Contributor

@DavIvek DavIvek commented Apr 10, 2024

Description

Syntax:
USING HOPS LIMIT x

PR for hops counting: #1935.
Count (Measure and expose hops back to the user (BFS+DFS+Expand; if an edge is filtered out, it should count as a hop).
How to count hops → each time an edge is “crossed”, it’s counted as a HOP.

NOTE: Different cursor will return different paths due to different implementations. Hops are counted in the same way for every cursor.

[master < Task] PR

  • Provide the full content or a guide for the final git message
    • [FINAL GIT MESSAGE]

Documentation checklist

  • Add the documentation label tag
  • Add the bug / feature label tag
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • [Release note text]
  • Link the documentation PR here
    • [Documentation PR link]
  • Tag someone from docs team in the comments

closes #1374

@DavIvek DavIvek added feature feature customer customer labels Apr 10, 2024
@DavIvek DavIvek self-assigned this Apr 10, 2024
@DavIvek DavIvek added the Docs needed Docs needed label Apr 10, 2024
This reverts commit b074827.
@DavIvek DavIvek requested review from Josipmrden and Darych May 14, 2024 11:55
@DavIvek DavIvek marked this pull request as ready for review May 14, 2024 12:39
Copy link
Contributor

@Josipmrden Josipmrden left a comment

Choose a reason for hiding this comment

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

Overall -> does the feature functionally, good job. I have a few comments with regarding to passing the object, as well as testing this feature.

src/query/db_accessor.hpp Outdated Show resolved Hide resolved
src/query/frontend/opencypher/grammar/MemgraphCypher.g4 Outdated Show resolved Hide resolved
src/query/interpret/eval.cpp Outdated Show resolved Hide resolved
src/query/interpreter.cpp Outdated Show resolved Hide resolved
Comment on lines 2072 to 2075
if (!flags::run_time::GetHopsLimitPartialResults() && (ctx_.hops_limit.has_value() && ctx_.hops_limit.value() < 0)) {
throw QueryException("Query exceeded the maximum number of hops.");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better maybe to make an object in the context with the value that's maximum, and the current value, so we can ask the object if the hops limit is in place and if the hops limit is exhausted, rather than modifying this limit in place

Comment on lines 2401 to 2402
// TODO: how to expose metrics when we have hops limit?
const auto hops_limit = EvaluateHopsLimit(evaluator, cypher_query->hops_limit_);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you elaborate this question, I don't understand it at the moment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that comment isn't relevant anymore. Something that bothered me before -> should have delete it before review.

src/query/plan/operator.cpp Outdated Show resolved Hide resolved
src/storage/v2/disk/storage.cpp Outdated Show resolved Hide resolved
continue;
in_edges.emplace_back(edge_type, from_vertex, edge);
expanded_count = static_cast<int64_t>(vertex_->in_edges.size());
// TODO: a better filter copy
Copy link
Contributor

Choose a reason for hiding this comment

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

what is a better filter copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That comment isn't placed here by me. Was here before but since I changed this file it looks like I have put it.
I also don't get it, maybe we can delete it.

tests/e2e/hops_limit/limit_number_of_hops.py Outdated Show resolved Hide resolved
@DavIvek DavIvek modified the milestones: mg-v2.17.0, mg-v2.18.0 May 20, 2024
@DavIvek DavIvek marked this pull request as draft May 21, 2024 14:12
@DavIvek DavIvek marked this pull request as ready for review May 23, 2024 13:34
@DavIvek DavIvek requested a review from Josipmrden May 23, 2024 13:34
Copy link

sonarcloud bot commented May 24, 2024

Quality Gate Passed Quality Gate passed

Issues
13 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
6.8% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI -build=community -test=core Run community build and core tests on push CI -build=coverage -test=core Run coverage build and core tests on push CI -build=debug -test=core Run debug build and core tests on push CI -build=release -test=benchmark Run release build and benchmark on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push customer customer Docs needed Docs needed feature feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit query execution by work AKA hops query limit
2 participants