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 63 commits into
base: master
Choose a base branch
from
Open

Limit number of hops #1928

wants to merge 63 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 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
src/flags/run_time_configurable.cpp Outdated Show resolved Hide resolved
src/query/hops_limit.hpp Outdated Show resolved Hide resolved
src/query/frontend/ast/ast.hpp Outdated Show resolved Hide resolved
src/query/interpret/eval.cpp Show resolved Hide resolved
src/storage/v2/vertex_accessor.cpp Outdated Show resolved Hide resolved
src/storage/v2/vertex_accessor.cpp Outdated Show resolved Hide resolved
src/storage/v2/vertex_accessor.cpp Outdated Show resolved Hide resolved
@DavIvek DavIvek marked this pull request as draft May 29, 2024 08:34
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.

one small comment from me in tests and vertex_accessor

int64_t expanded_count = 0;
const auto &edges = direction == EdgeDirection::IN ? vertex_->in_edges : vertex_->out_edges;
if (hops_limit && hops_limit->IsUsed()) {
if (hops_limit->LeftHops() == 0 && static_cast<int64_t>(edges.size()) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this ever be < 0 and fool the condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

since we can increment by more than 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If everything is correct in the operators, this should not happen. That would mean that the limit has already been reached and we shouldn't end up in the vertex accessor, instead part of the query where expansions are done should have ended.

Copy link

sonarcloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

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

See analysis details on SonarCloud

@DavIvek DavIvek requested review from Josipmrden and Darych June 5, 2024 13:50
@DavIvek DavIvek marked this pull request as ready for review June 5, 2024 13:51
@@ -35,6 +35,13 @@ class VertexAccessor final {
private:
friend class Storage;

int64_t HandleExpansionsWithoutEdgeTypes(edge_store &edges, query::HopsLimit *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.

Let's rename edges to result_edges to be in sync with implementation and emphasize that this is returned value

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
3 participants