mschmidt00 commented on a change in pull request #1553:
URL: https://github.com/apache/tinkerpop/pull/1553#discussion_r793249337



##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -316,59 +337,58 @@ gremlin> g.E().has("weight", gt(1))
 
 * For numbers,
 ** it should be aligned to equality conceptually as far as type promotion is 
concerned. e.g. `1.0 < 2 < 3L`
-* Comparison should not result in undefined behavior, but can return 
`nulltype` if and only if we are comparing
-incomparable data types. How this `nulltype` result is handled is Graph 
provider dependent.
+* Comparison should not result in undefined behavior, but can return `ERROR` 
if we are comparing
+different data types. How this `ERROR` result is handled is Graph provider 
dependent. The reference implementation

Review comment:
       nit: "if we are comparing different data types (and for comparisons with 
NaN values)".

##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -386,33 +406,62 @@ IDs are of any primitive types defined, so comparability 
for a corresponding typ
 
 Comparability of String applies.
 
+===== Iterable (Path, List, Set, Map)
+
+* Iterables must be of the same type, otherwise `ERROR`.
+* Iterables are compared via their natural iteration order.
+* Elements are compared element by element according to these semantics from 
the two iterations being compared.
+* Empty iterations are equal and are less than non-empty iterations.
+* If iteration `A` exhausts its elements before iteration `B` then `A < B`.
+
 ===== Path
 
-It is not comparable, throw an Exception.
+* Only comparable to other Paths, otherwise `ERROR`.
+* Iterable semantics apply.
+
+===== Set
+
+* Only comparable to other Sets, otherwise `ERROR`.
+* Iterable semantics apply.
 
 ===== List
 
-It is not comparable, throw an Exception.
+* Only comparable to other Lists, otherwise `ERROR`.
+* Iterable semantics apply.
 
 ===== Map
 
-It is not comparable, throw an Exception.
+* Only comparable to other Maps, otherwise `ERROR`.
+* Iterable semantics apply (using `Map.entrySet()`)
+* Map entries are compared first by key, then by value according to these 
semantics.
 
-===== Map.Entry
-
-It is not comparable, throw an Exception.
+=== Mapping for P
 
-===== Set
+The following table maps the notions proposed above to the various `P` 
operators:

Review comment:
       nice!

##########
File path: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Text.java
##########
@@ -37,6 +37,8 @@
     startingWith {
         @Override
         public boolean test(final String value, final String prefix) {

Review comment:
       So you're saying it would be a type error already at parsing time. 
Talking about some sort of "startingWith(1)" somewhere in the query.

##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -386,33 +406,62 @@ IDs are of any primitive types defined, so comparability 
for a corresponding typ
 
 Comparability of String applies.
 
+===== Iterable (Path, List, Set, Map)
+
+* Iterables must be of the same type, otherwise `ERROR`.
+* Iterables are compared via their natural iteration order.

Review comment:
       As per our discussion, you may want to add that the behavior for 
iterables without inherent order (such as maps) is implementation specific (and 
using the iteration order is what TP does)?

##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -423,7 +472,7 @@ For a different type, we have a dedicated order as 
described in the section belo
 To sort across any types of values, we define the order between each type as 
follows:
 (In this order, ID, label, property key and property value are considered as a 
part of primitive types)
 
-* `nulltype`
+* `null`

Review comment:
       nit: I would prefer reverting that and leaving "nulltype" -- null is 
really the (one and only) instance of nulltype, and this list is at type level 

##########
File path: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/FilterStep.java
##########
@@ -34,9 +36,22 @@ public FilterStep(final Traversal.Admin traversal) {
     @Override
     protected Traverser.Admin<S> processNextStart() {
         while (true) {
-            final Traverser.Admin<S> traverser = this.starts.next();
-            if (this.filter(traverser))
-                return traverser;
+            try {
+                final Traverser.Admin<S> traverser = this.starts.next();
+                if (this.filter(traverser))
+                    return traverser;
+            } catch (GremlinTypeErrorException ex) {
+                if (this instanceof BinaryReductionStep || 
getTraversal().getParent() == EmptyStep.instance()) {

Review comment:
       Understand. @spmallette please have a quick look at this one

##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -294,12 +294,33 @@ Equivalence is identical to Equality, except for the 
cases listed below.
 Comparability and orderability can be understood as the "dual" concepts of 
equality and equivalence for range
 comparisons (rather than exact comparison). For the two values of the same 
type (except for NaN), comparability is
 stronger than orderability in the sense that everything that every order 
between two values that holds `true` w.r.t.
-comparability also holds `true` w.r.t. orderability, but not vice versa. 
Comparability is what is being used in range
-predicates. It is restricted to comparison within the same type or, for 
numerics, class of types; comparability is
-complete within a given type, but returns `nulltype` if the two types are 
considered incomparable (e.g., an integer
-cannot be compared to a string). Orderability fills these gaps, by providing a 
stable sort order over mixed type
-results; it is consistent with comparability within a type, and complete both 
within and across types, i.e. it will
-never return `nulltype` or throw an exception.
+comparability also holds `true` w.r.t. orderability, but not vice versa.
+
+Comparability is what is being used in range predicates. It is restricted to 
comparison within the same type or,
+for numerics, class of types; comparability is complete within a given type, 
but returns `ERROR` if the two types are
+considered incomparable (e.g., an integer cannot be compared to a string). 
`ERROR` is the third option in a ternary
+boolean logics system for boolean value expression evaluation. `ERROR` is an 
internal representation only and will not
+be propagated back to the client as an exception - it will eventually hit a 
binary reduction operation and be reduced
+to `false`. Before that happens though, it will be treated as its own boolean 
value that can be used in other boolean
+value expressions, such as `AND`/`OR`:
+
+|===
+|A|B|=>|AND|OR

Review comment:
       Maybe add the XOR semantics as well?

##########
File path: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java
##########
@@ -52,9 +52,19 @@
     within {
         @Override
         public boolean test(final Object first, final Collection second) {
-            return first instanceof Number
-                    ? IteratorUtils.anyMatch(second.iterator(), o -> 
Compare.eq.test(first, o))
-                    : second.contains(first);
+            GremlinTypeErrorException typeError = null;

Review comment:
       ack

##########
File path: docs/src/dev/provider/gremlin-semantics.asciidoc
##########
@@ -294,12 +294,33 @@ Equivalence is identical to Equality, except for the 
cases listed below.
 Comparability and orderability can be understood as the "dual" concepts of 
equality and equivalence for range
 comparisons (rather than exact comparison). For the two values of the same 
type (except for NaN), comparability is
 stronger than orderability in the sense that everything that every order 
between two values that holds `true` w.r.t.
-comparability also holds `true` w.r.t. orderability, but not vice versa. 
Comparability is what is being used in range
-predicates. It is restricted to comparison within the same type or, for 
numerics, class of types; comparability is
-complete within a given type, but returns `nulltype` if the two types are 
considered incomparable (e.g., an integer
-cannot be compared to a string). Orderability fills these gaps, by providing a 
stable sort order over mixed type
-results; it is consistent with comparability within a type, and complete both 
within and across types, i.e. it will
-never return `nulltype` or throw an exception.
+comparability also holds `true` w.r.t. orderability, but not vice versa.

Review comment:
       In the equivalence section above (which you did not change), we should 
call out that NaN == NaN for equivalence (as a difference towards equality) -- 
may have missed it, but I couldn't find that stated explicitly.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to