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

Implement none() Filter Step #2352

Closed
wants to merge 5 commits into from
Closed

Conversation

ryn5
Copy link
Contributor

@ryn5 ryn5 commented Nov 17, 2023

Takes lists, predicate and filters out lists which have at least 1 element matching the predicate. Changes based on existing all() and any() list functions in TINKERPOP-2978 Implement all() and any() steps..

@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (515ff5b) 76.22% compared to head (227df83) 76.18%.
Report is 18 commits behind head on 3.7-dev.

❗ Current head 227df83 differs from pull request most recent head 585e9e7. Consider uploading reports for the commit 585e9e7 to get more accurate results

Files Patch % Lines
...egy/verification/StandardVerificationStrategy.java 0.00% 0 Missing and 2 partials ⚠️
...in/language/grammar/DefaultGremlinBaseVisitor.java 0.00% 1 Missing ⚠️
...in/process/traversal/step/filter/ListNoneStep.java 95.65% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             3.7-dev    #2352      +/-   ##
=============================================
- Coverage      76.22%   76.18%   -0.04%     
- Complexity     13117    13128      +11     
=============================================
  Files           1082     1084       +2     
  Lines          64967    65024      +57     
  Branches        7252     7264      +12     
=============================================
+ Hits           49521    49540      +19     
- Misses         12752    12791      +39     
+ Partials        2694     2693       -1     

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

@@ -2008,7 +2009,7 @@ public default GraphTraversal<S, E> filter(final Traversal<?, ?> filterTraversal
*
* @return the updated traversal with respective {@link NoneStep}.
*/
@Override
Copy link
Contributor

@kenhuuu kenhuuu Nov 17, 2023

Choose a reason for hiding this comment

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

Nit: You can probably leave this override annotation in there for now.

@@ -4078,6 +4092,7 @@ private Symbols() {
public static final String dateDiff = "dateDiff";
public static final String all = "all";
public static final String any = "any";
public static final String listNone = "none";
Copy link
Contributor

@kenhuuu kenhuuu Nov 17, 2023

Choose a reason for hiding this comment

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

Nit: Could you have just called dthis none instead of listNone?

Copy link
Contributor

Choose a reason for hiding this comment

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

The "none" token is already on Traversal.Symbols - shouldn't that just be used?

g.inject(xx1).none(TextP.startingWith("a"))
"""
When iterated to list
Then the result should be empty
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is the right result because

gremlin> g.inject([null,"bcd"]).all(TextP.startingWith("a"))
gremlin>

@kenhuuu
Copy link
Contributor

kenhuuu commented Nov 17, 2023

Missing provider semantics documentation and you could probably add an update to the upgrade documentation as well.

@@ -2008,7 +2009,7 @@ public default GraphTraversal<S, E> filter(final Traversal<?, ?> filterTraversal
*
* @return the updated traversal with respective {@link NoneStep}.
*/
@Override
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

This deprecation needs javadoc, especially in this case. Here's an example of the form:

https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java#L314-L323

@@ -40,7 +40,7 @@ This release also includes changes from <<release-3-6-6, 3.6.6>> and <<release-3
* Added new data type `DT` to represent periods of time.
* Added Gherkin support for Date.
* Extended `datetime()` function to produce a current server date.
* Added list filtering functions `all` and `any`.
* Added list filtering functions `all`, `any`, and `none`.
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a major deprecation to document here. there should also be provider upgrade docs as none() is an important part of server interactions.

*/
public default <S2> GraphTraversal<S, E> none(final P<S2> predicate) {
this.asAdmin().getBytecode().addStep(Symbols.listNone, predicate);
return this.asAdmin().addStep(new ListNoneStep<>(this.asAdmin(), predicate));
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize NoneStep is already taken and has special meaning that is not easily removed at this moment. Given that none() is just not(any()) and the code for this ListNoneStep and AnyStep, i think it would be better to just give AnyStep a negation configuration. Then you get rid of ListNoneStep.

@@ -2309,6 +2309,25 @@ link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gre
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#limit(org.apache.tinkerpop.gremlin.process.traversal.Scope,long)++[`limit(Scope,long)`]
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/Scope.html++[`Scope`]

[[list-none-step]]
=== List None Step
Copy link
Contributor

Choose a reason for hiding this comment

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

Users will still see this as none() so I think it's better to explain the two usages in the existing section for that step. Luckily none() is mostly an internal step. it's unlikely anyone is really using it directly.

@ryn5 ryn5 changed the title Implement none() Filter StepTINKERPOP-2978 Implement all() and any() steps. Implement none() Filter Step Nov 30, 2023
@ryn5 ryn5 closed this Dec 8, 2023
@ryn5 ryn5 reopened this Dec 8, 2023
@ryn5
Copy link
Contributor Author

ryn5 commented Dec 8, 2023

New PRs at #2371 #2377 #2385

@ryn5 ryn5 closed this Dec 8, 2023
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.

4 participants