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

Support limit for predicates #237

Open
ghost opened this issue Feb 10, 2022 · 3 comments
Open

Support limit for predicates #237

ghost opened this issue Feb 10, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ghost
Copy link

ghost commented Feb 10, 2022

limit() is available for RangeVertexQuery, PipeVertexQuery and PipeEdgeQuery. Is it possible for limit() to be supported for predicates such as PipePropertyValueEdgeQuery, PipePropertyValueVertexQuery, PipePropertyPresenseEdgeQuery and PipePropertyPresenseVertexQuery too? Here is an example of where it may be useful:

// get all vertices of type "my_type" then get the first one with the property "Name" of value "John".
let q = RangeVertexQuery::new()
        .t(my_type)
        .with_property_equal_to(Identifier::new("Name").unwrap(), "John".into())
        .limit(1) // <- get only the first vertex with the property above
        .outbound() // traverse onwards...
        ...

While I'm not familiar with rocksdb or the TAO approach, while using Tinkerpop Gremlin performance could be gained by limiting traversals where they were no longer needed. In an example such as the one above, if I'm sure that only a single vertex matches the predicate, or my query only needs a single result, then the query need not look for more vertices, and it can continue to the next step, outbound().

Another example:

// Does the property "Salary" exist on any vertex within the database?
let q = PropertyPresenceVertexQuery::new(Identifier::new("Salary").unwrap()).limit(1);
@ysimonson
Copy link
Member

Yup this makes sense

@ysimonson ysimonson added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed good first issue Good for newcomers labels Feb 10, 2022
@FibreFoX
Copy link
Contributor

Maybe this should be split into two separate things.

  1. .limit() for limits more than just 1; always returns a list (coming from Java, sorry if "list" is not the correct terminology for Rust)
  2. .exists() as a better way to check for anything being there (always returns boolean)

What do you think about this? Probably would avoid the situation having .limit(1) returning a different thing than .limit(2).

@ysimonson
Copy link
Member

Yeah, an exists() also makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants