You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by dkuppitz <gi...@git.apache.org> on 2018/10/01 14:19:29 UTC

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

GitHub user dkuppitz opened a pull request:

    https://github.com/apache/tinkerpop/pull/944

    TINKERPOP-2041 Text Predicates

    https://issues.apache.org/jira/browse/TINKERPOP-2041
    
    This PR adds a few text predicates (`TP`):
    
    * `startsWith`
    * `endsWith`
    * `contains`
    
    By the contract definition, every predicate needs an opposite predicate, hence I also added the following:
    
    * `startsNotWith`
    * `endsNotWith`
    * `absent`
    
    However, I don't like the naming too much. If anybody has better suggestions, I'm all ears.
    
    `docker/build.sh -t -i -n` passed.
    
    VOTE +1

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/tinkerpop TINKERPOP-2041

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/944.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #944
    
----
commit 242a9e399f4c73c02068dda73cc3bd52eeb7e00f
Author: Daniel Kuppitz <da...@...>
Date:   2018-09-26T22:44:35Z

    TINKERPOP-2041 Implemented text predicates

commit 1a0ca3ade124dcc34761085ee58db2f7e68e3d06
Author: Stephen Mallette <sp...@...>
Date:   2018-09-27T20:33:26Z

    TINKERPOP-2041 Fixed gremlin-javascript serializers for TP

commit 441cf6aa4769805215045e460e1daad8b46a1cfb
Author: Stephen Mallette <sp...@...>
Date:   2018-09-28T12:27:25Z

    TINKERPOP-2041 Fixed .NET tests around TP predicates

----


---

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/944#discussion_r222065189
  
    --- Diff: docs/src/reference/the-traversal.asciidoc ---
    @@ -3356,24 +3356,32 @@ interface. Steps that allow for this type of modulation will explicitly state so
     [[a-note-on-predicates]]
     == A Note on Predicates
     
    -A `P` is a predicate of the form `Function<Object,Boolean>`. That is, given some object, return true or false. The
    -provided predicates are outlined in the table below and are used in various steps such as <<has-step,`has()`>>-step,
    +A `P` is a predicate of the form `Function<Object,Boolean>`. That is, given some object, return true or false. As of
    +the relase of TinkerPop 3.4.0, Gremlin also supports simple text predicates, which only work on `String` values. The `TextP`
    +text predicates extend the `P` predicates, but are specialized in that they are of the form `Function<String,Boolean>`.
    +The provided predicates are outlined in the table below and are used in various steps such as <<has-step,`has()`>>-step,
     <<where-step,`where()`>>-step, <<is-step,`is()`>>-step, etc.
     
     [width="100%",cols="3,15",options="header"]
     |=========================================================
     | Predicate | Description
    -| `eq(object)` | Is the incoming object equal to the provided object?
    -| `neq(object)` | Is the incoming object not equal to the provided object?
    -| `lt(number)` | Is the incoming number less than the provided number?
    -| `lte(number)` | Is the incoming number less than or equal to the provided number?
    -| `gt(number)` | Is the incoming number greater than the provided number?
    -| `gte(number)` | Is the incoming number greater than or equal to the provided number?
    -| `inside(number,number)` | Is the incoming number greater than the first provided number and less than the second?
    -| `outside(number,number)` | Is the incoming number less than the first provided number or greater than the second?
    -| `between(number,number)` | Is the incoming number greater than or equal to the first provided number and less than the second?
    -| `within(objects...)` | Is the incoming object in the array of provided objects?
    -| `without(objects...)` | Is the incoming object not in the array of the provided objects?
    +| `P.eq(object)` | Is the incoming object equal to the provided object?
    +| `P.neq(object)` | Is the incoming object not equal to the provided object?
    +| `P.lt(number)` | Is the incoming number less than the provided number?
    +| `P.lte(number)` | Is the incoming number less than or equal to the provided number?
    +| `P.gt(number)` | Is the incoming number greater than the provided number?
    +| `P.gte(number)` | Is the incoming number greater than or equal to the provided number?
    +| `P.inside(number,number)` | Is the incoming number greater than the first provided number and less than the second?
    +| `P.outside(number,number)` | Is the incoming number less than the first provided number or greater than the second?
    +| `P.between(number,number)` | Is the incoming number greater than or equal to the first provided number and less than the second?
    +| `P.within(objects...)` | Is the incoming object in the array of provided objects?
    +| `P.without(objects...)` | Is the incoming object not in the array of the provided objects?
    +| `TextP.startsWith(string)` | Does the incoming `String` start with the provided `String`?
    +| `TextP.endsWith(string)` | Does the incoming `String` end with the provided `String`?
    +| `TextP.contains(string)` | Does the incoming `String` contain the provided `String`?
    +| `TextP.startsNotWith(string)` | TODO: find a better name
    --- End diff --
    
    Sounds good to me, much better than what it is now.


---

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/944#discussion_r222062939
  
    --- Diff: docs/src/reference/the-traversal.asciidoc ---
    @@ -3356,24 +3356,32 @@ interface. Steps that allow for this type of modulation will explicitly state so
     [[a-note-on-predicates]]
     == A Note on Predicates
     
    -A `P` is a predicate of the form `Function<Object,Boolean>`. That is, given some object, return true or false. The
    -provided predicates are outlined in the table below and are used in various steps such as <<has-step,`has()`>>-step,
    +A `P` is a predicate of the form `Function<Object,Boolean>`. That is, given some object, return true or false. As of
    +the relase of TinkerPop 3.4.0, Gremlin also supports simple text predicates, which only work on `String` values. The `TextP`
    +text predicates extend the `P` predicates, but are specialized in that they are of the form `Function<String,Boolean>`.
    +The provided predicates are outlined in the table below and are used in various steps such as <<has-step,`has()`>>-step,
     <<where-step,`where()`>>-step, <<is-step,`is()`>>-step, etc.
     
     [width="100%",cols="3,15",options="header"]
     |=========================================================
     | Predicate | Description
    -| `eq(object)` | Is the incoming object equal to the provided object?
    -| `neq(object)` | Is the incoming object not equal to the provided object?
    -| `lt(number)` | Is the incoming number less than the provided number?
    -| `lte(number)` | Is the incoming number less than or equal to the provided number?
    -| `gt(number)` | Is the incoming number greater than the provided number?
    -| `gte(number)` | Is the incoming number greater than or equal to the provided number?
    -| `inside(number,number)` | Is the incoming number greater than the first provided number and less than the second?
    -| `outside(number,number)` | Is the incoming number less than the first provided number or greater than the second?
    -| `between(number,number)` | Is the incoming number greater than or equal to the first provided number and less than the second?
    -| `within(objects...)` | Is the incoming object in the array of provided objects?
    -| `without(objects...)` | Is the incoming object not in the array of the provided objects?
    +| `P.eq(object)` | Is the incoming object equal to the provided object?
    +| `P.neq(object)` | Is the incoming object not equal to the provided object?
    +| `P.lt(number)` | Is the incoming number less than the provided number?
    +| `P.lte(number)` | Is the incoming number less than or equal to the provided number?
    +| `P.gt(number)` | Is the incoming number greater than the provided number?
    +| `P.gte(number)` | Is the incoming number greater than or equal to the provided number?
    +| `P.inside(number,number)` | Is the incoming number greater than the first provided number and less than the second?
    +| `P.outside(number,number)` | Is the incoming number less than the first provided number or greater than the second?
    +| `P.between(number,number)` | Is the incoming number greater than or equal to the first provided number and less than the second?
    +| `P.within(objects...)` | Is the incoming object in the array of provided objects?
    +| `P.without(objects...)` | Is the incoming object not in the array of the provided objects?
    +| `TextP.startsWith(string)` | Does the incoming `String` start with the provided `String`?
    +| `TextP.endsWith(string)` | Does the incoming `String` end with the provided `String`?
    +| `TextP.contains(string)` | Does the incoming `String` contain the provided `String`?
    +| `TextP.startsNotWith(string)` | TODO: find a better name
    --- End diff --
    
    maybe we should put all the "nots" together so that:
    
    * `notStartingWith()`
    * `notEndingWith()`
    * `notContaining()`
    
    They seem to read a bit less awkwardly when I say them out loud. if we wanted we could make it all consistent and be like:
    
    * `startingWith()`
    * `endingWith()`
    * `containing()`
    * `notStartingWith()`
    * `notEndingWith()`
    * `notContaining()`
    
    but maybe not necessary???


---

[GitHub] tinkerpop issue #944: TINKERPOP-2041 Text Predicates

Posted by robertdale <gi...@git.apache.org>.
Github user robertdale commented on the issue:

    https://github.com/apache/tinkerpop/pull/944
  
    I would like to see `TP` renamed to `TextP`.


---

[GitHub] tinkerpop issue #944: TINKERPOP-2041 Text Predicates

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on the issue:

    https://github.com/apache/tinkerpop/pull/944
  
    I think we need to add `TextP` to the IO tests and provide an example in the related IO docs. I can do that tomorrow.


---

[GitHub] tinkerpop issue #944: TINKERPOP-2041 Text Predicates

Posted by robertdale <gi...@git.apache.org>.
Github user robertdale commented on the issue:

    https://github.com/apache/tinkerpop/pull/944
  
    VOTE +1


---

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/944#discussion_r222063944
  
    --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TextP.java ---
    @@ -0,0 +1,107 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.tinkerpop.gremlin.process.traversal;
    +
    +import java.util.function.BiPredicate;
    +
    +/**
    + * @author Daniel Kuppitz (http://gremlin.guru)
    --- End diff --
    
    Just needs some class javadoc - looks like you covered the methods pretty well.


---

[GitHub] tinkerpop issue #944: TINKERPOP-2041 Text Predicates

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on the issue:

    https://github.com/apache/tinkerpop/pull/944
  
    All tests pass with `docker/build.sh -t -n -i`
    
    VOTE +1


---

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/944#discussion_r222063562
  
    --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Text.java ---
    @@ -0,0 +1,123 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.tinkerpop.gremlin.process.traversal;
    +
    +import java.util.function.BiPredicate;
    +
    +/**
    + * @author Daniel Kuppitz (http://gremlin.guru)
    + */
    +public enum Text implements BiPredicate<String, String> {
    --- End diff --
    
    Could you please complete all the javadoc on this class since it's public facing like `Compare` - I think you need all the `@since` tags on everything in here.


---

[GitHub] tinkerpop pull request #944: TINKERPOP-2041 Text Predicates

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/tinkerpop/pull/944


---