You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2021/11/04 10:32:24 UTC

[tinkerpop] branch master updated (1d43c58 -> 11e8bb5)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 1d43c58  Removed optional "integrate" and "performance" test suites
     new f718795  Equality, Equivalence, Comparability, and Orderability Semantics proposal for TinkerPop
     new 6b91140  Add Apache license header
     new 5c7993a  Add UUID as an independent type
     new 8aa59d0  Update List equality definition
     new 7ec2210  Update Map/Set equality definition
     new eb2e20d  Update the type cast description for integer/float values
     new 11e8bb5  Change NULL to NULLTYPE to avoid confusion from Java null value

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/src/dev/future/equality_proposal.asciidoc | 726 +++++++++++++++++++++++++
 1 file changed, 726 insertions(+)
 create mode 100644 docs/src/dev/future/equality_proposal.asciidoc

[tinkerpop] 05/07: Update Map/Set equality definition

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 7ec2210b3c0633d5268bdc10d0ec3121e9a88731
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 14:02:12 2021 -0700

    Update Map/Set equality definition
---
 docs/src/dev/future/equality_proposal.asciidoc | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index 3abac1a..dee44d6 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -515,13 +515,11 @@ label is String type so Equality for String type applies.
 
 ===== Map
 
-* If either one of LHS or RHS is Map and another isn't, return FALSE
-* For 2 Maps M1 and M2 to be equal,
-    ** All keys in M1 should be within keys in M2
-    ** All keys in M2 should be within keys in M1
-    ** M1 and M2 should have the same number of  keys
-    ** For all keys k(1), k(2), ...k(n) in M1, M1[k] eq M2[k] should return TRUE
-    ** In Gremlin key order is not respected when determining equality
+* Two maps are equal when a Set of key-value pairs from those 2 maps are equal to each other. A key-value pair is equal to another pair if and only if both its key and value are equal to each other.
+
+===== Set
+
+* Two sets are equal if they contain the same (equal to each other) elements.
 
 === Equivalence
 

[tinkerpop] 01/07: Equality, Equivalence, Comparability, and Orderability Semantics proposal for TinkerPop

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit f7187958d8318bafab36a1da19517093b5540ad7
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Fri Oct 22 14:13:46 2021 -0700

    Equality, Equivalence, Comparability, and Orderability Semantics proposal for TinkerPop
---
 docs/src/dev/future/equality_proposal.asciidoc | 682 +++++++++++++++++++++++++
 1 file changed, 682 insertions(+)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
new file mode 100644
index 0000000..4119dfa
--- /dev/null
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -0,0 +1,682 @@
+= Proposal for equality, equivalance, comparability and orderability semantics for TinkerPop
+
+== Motivation
+
+How values compare to each other is crucial to the behavior of a query language. While comparison semantics may sound like a trivial question at first, when looking under the surface many interesting questions arise, including aspects around equality and comparability in the context of type casting (e.g., over numerics of different types), slightly different variants of equality being used in different context (e.g. predicates vs. deduplication), questions around comparability and orderi [...]
+
+TinkerPop / Gremlin is written in and (partially) relies upon Java / JVM, and there is no clear semantics defined and published for the different types of equality and comparison operations as of today. Rather, what equals what and how values compare is often implicitly defined by the semantics of the underlying Java data structures that are being used, and hence may vary from context to context. We believe that a concise definition of these concepts is critical for both TinkerPop custom [...]
+
+This documentation is a proposal that shall serve as a basis for a community discussion on how TinkerPop should handle equality / comparison in different contexts. Motivated by different examples of the status today, we formalize different notions of equality and comparability and describe the contexts in which they apply. While the semantics that we propose is largely aligned with the semantics that is implemented in TinkerPop today, this proposal aims to fill in some existing gaps (suc [...]
+
+=== Examples
+
+Below are a couple of example scenarios where defining semantics can help clarify and mitigate inconsistent / undefined behavior in TinkerPop today:
+
+==== The underspecified/undocumented behavior
+
+Consider an equality check such as 
+
+[source]
+----
+gremlin> g.V().has(id, 19)
+----
+
+Without a precise definition, both users and Graph providers don't know whether this query matches only nodes with an ID that is exactly equal to the integer value 19 or, for instance, all numerical values that cast to an Integer value 19. To see that, right now, they need to dig into the TinkerPop code base. While, in the above example, type casting rules apply, in other cases such as
+
+[source]
+----
+gremlin> g.V().property(numericValue).dedup()
+----
+
+the two values above would always be treated as different entities.
+
+==== The behavior that is inherently driven by Java:
+
+Another example is equality over composite type.
+
+[source]
+----
+gremlin> g.V().aggregate("a").out().aggregate("b").cap("a").where(eq("b"))
+----
+
+This query compares two BulkSet objects produced by cap-Step. But the comparison is Java dependent and we don’t have a clear definition of how the comparison works for this kind of types.
+Same as Map, e.g.
+
+[source]
+----
+gremlin> g.V().group().unfold().as("a").V().group().unfold().as("b").where(eq("a", "b"))
+----
+
+and even we have comparison over Map.Entry which is Java dependent type.
+
+[source]
+----
+gremlin> g.V().group().unfold().order() 
+class java.util.HashMap$Node cannot be cast to class java.lang.Comparable (java.util.HashMap$Node and java.lang.Comparable are in module java.base of loader 'bootstrap')
+----
+
+==== Potentially unexpected results due to incompleteness
+
+A query which tries to determine the order across multiple types fails today. 
+
+[source]
+----
+// Propertis have values of Integer and String.
+gremlin> g.V().values("some property").order()
+
+class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
+
+// This query aims to order a heterogeneous result set
+gremlin> g.V().union(out(), outE()).order()
+class org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex cannot be cast to class java.lang.Comparable (org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
+----
+
+It would be more helpful for users to define the complete order across types and returns a result instead of throwing an Exception.
+
+==== Inconsistencies results
+
+Handling for `NaN`, `NULL`, `+0.0`, `-0.0`, `+INF`, `-INF` is tricky, and TinkerPop does not cover all cases consistently at this moment.
+
+[source]
+----
+gremlin> g.V("1").properties("key")
+==>vp[key→0]
+
+// NaN == 0 holds true for this equality check.  
+gremlin> g.V("1").has("key", Double.NaN)
+==>v[1]
+
+gremlin> g.V("1").properties()
+==>vp[key→Infinity]
+
+// 0.0 is interepreted as BigDecial in Groovy and it tries to promote Infinity to BigDecimal as well,
+// then the type casting fails. This is observed when using Java11.
+gremlin> g.V("1").has("key", gt(0.0))
+Character I is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
+----
+
+In the next section, we provide a conceptual proposal to define concepts around how values compare and are ordered, which aims to provide an answer to these and other questions. We seek the feedback from the community to discuss and reach a consensus around the proposal and are open to all other ideas around how these concepts should be defined in TinkerPop / Gremlin.
+
+== Conceptualization of Equality and Comparison
+
+In the above section we used the notions of "equality" and "comparison" in a generalized way. Inspired by the formalization in https://s3.amazonaws.com/artifacts.opencypher.org/openCypher9.pdf[the openCypher specification], we now refine these two notions into four, where we distinguish between equality vs. equivalence and comparability vs. orderability, which constitute two flavors of these concepts tailored to their usage in different concepts.  We summarize and contrast these concepts [...]
+
+=== Proposed semantics
+
+==== Equality vs. Equivalence
+
+Equality defines when two values are considered equal in the context of database lookups and predicates, while  equivalence defines value collation semantics in the context of, for instance, deduplication. For instance, equivalence over two values `a := Double.NaN` and `b:= Double.NaN` is true, but equality would (in our proposal) be defined as false; the rational here (which is commonly found in query and programming languages) is that comparing two "unknown" numbers — which is a freque [...]
+
+Both equality and equivalence can be understood as complete, i.e. the result of equality and equivalence checks is always either TRUE or FALSE (in particular, it never returns NULL or throws an exception). The details on equality and equivalence are sketched in the following two subsections, respectively.
+
+===== Equality 
+
+* Used by equality and membership predicates (such as https://github.com/apache/tinkerpop/blob/734f4a8745e797f794c4860962912b04313f312a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java#L130[P.eq], https://github.com/apache/tinkerpop/blob/734f4a8745e797f794c4860962912b04313f312a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java#L139[P.neq], and the list membership https://github.com/apache/tinkerpop/blob/72be3549a5e4f99115e9d4 [...]
+
+* If graph providers need join semantics in query execution, equality should be used to join data over join keys. +
+Example:
+
+[code]
+----
+// equality over 2 ids
+gremlin> g.V().has(id, "some id")
+// equality over vertices
+gremlin> g.V().as("v").out().out().where(eq("v"))
+----
+
+* Equality adheres to type promotion semantics for numerical values, i.e. equality holds for values of different numerical type if they cast into the exactly same same value of the lowest common super type.
+* Other than the type promotion between Numbers, 2 values of different type are always regarded as not equal.
+* Equality checks always return TRUE or FALSE. They never result in NULL output, undefined behavior, nor do they ever throw an error. Detailed behavior is described in
+
+===== Equivalence
+
+* Equivalence defines how TinkerPop deals with 2 values to be grouped or de-duplicated. Specifically it is necessary for the dedup and group steps in Gremlin. +
+Example:
+
+[code]
+----
+// deduplication needs equivalence over 2 property values
+gremlin> g.V().dedup().by("name")
+// grouping by equivalence over 2 property values
+gremlin> g.V().group().by("age") 
+----
+
+* Equivalence ignores type promotion semantics, i.e. two values of different types (e.g. 2^^int vs. 2.0^^float) are always considered to be non-equivalent. (There is an open question whether equivalence takes type promotion into account). +
+
+* For Number, 
+** Because type promotion is not effective, if the types are different then two numbers are never equivalent
+** NaN is not equal to NaN, but equivalent to each other
+
+* Other than the edge case around NaN (and, as of today, Numbers), equivalence in TinkerPop is identical to equality.
+* Like equality, equivalence checks always return TRUE or FALSE. They never result in NULL output, undefined behavior, nor do they ever throw an error.
+
+==== Comparability vs. Orderability
+
+Comparability and orderability can be understood as the "dual" concepts of equality and equivalence for range comparisons (rather than exact comparison). For the 2 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 compar [...]
+More details on comparability and orderability are sketched in the following two subsections, respectively.
+
+===== Comparability
+
+* Used by the comparison operators (https://github.com/apache/tinkerpop/blob/050f66a956ae36ceede55613097cc86e19b8a737/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java#L88[P.gt], https://github.com/apache/tinkerpop/blob/050f66a956ae36ceede55613097cc86e19b8a737/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Compare.java#L138[P.lt], https://github.com/apache/tinkerpop/blob/050f66a956ae36ceede55613097cc86e19b8a737/gremlin-core/ [...]
+Example:
+
+[code]
+----
+// comparison over 2 property values
+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 NULL if and only if we are comparing incomparable data types. How this NULL result is handled is Graph provider dependent.
+* Otherwise Comparison does return TRUE or FALSE
+
+===== Orderability
+
+* Used to determine the order. In TinkerPop, the order step follows the notion of orderability.
+* Orderability must not result in NULL / undefined behavior.
+* Orderability must not throw an error. In other words, even if 2 values are incomparable we should still be able to determine the order of those two. This inevitably leads to the requirement to define the order across different data types. For the detailed order across types, see appendix.
+* Orderability determines if 2 values are ordered at the same position or one value is positioned earlier than another.
+* The concept of equivalence is used to determine if the 2 values are at the same position
+* When the position is identical, which value comes first (in other words, whether it should perform stable sort) depends on graph providers' implementation.
+* For values of the same type, comparability can be used to determine which comes first except for NaN in Number. For a different type, we have a dedicated order as described in the section below.
+
+===== Mapping table for TinkerPop operators
+
+Shown as below is a table for which notion proposed above each TinkerPop construct used.
+
+[%header]
+|================
+|Construct|Concept                
+|P.eq     |Equality               
+|P.neq    |Equality               
+|P.within |Equality               
+|P.without|Equality               
+|P.lt     |Comparability          
+|P.gt     |Comparability          
+|P.lte    |Equality, Comparability
+|P.gte    |Equality, Comparability
+|P.inside |Comparability          
+|P.outside|Comparability          
+|P.between|Equality, Comparability
+|================
+
+== What would change ?
+
+=== Semantics
+
+In terms of Semantics, right now TinkerPop does not have formal semantics to define these characteristics introduced in this proposal. Therefore this semantics should be published on the official TinkerPop doc.
+
+=== Behavioral changes
+==== Equality
+
+* NaN +
+JDK11 seems to produce a different error from JDK8 when it comes to BigDecimal comparisons that hit NaN and such. For JDK8 they seem to produce NumberFormatException but for JDK11 you get stuff like:
+
+[code]
+----
+gremlin> g.V().has("key", Float.NaN)
+Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
+----
+When Double / Float Number is stored, it always throws. With the proposed change, it wouldn't throw but because NaN is not equal to any numbers this returns empty result.
+
+* BigDecimal +
+Equality around BigDecimal and special values which cannot be parsed as Integer such as NaN, INF should not produce exceptions and should filter.
+
+[code]
+----
+gremlin> g.addV().property('key',Float.NaN)
+==>v[0]
+gremlin> g.addV().property('key',1.0f)
+==>v[2]
+gremlin> g.V().has('key',Float.NaN)
+==>v[0]
+gremlin> g.V().has('key',1.0f)
+==>v[2]
+gremlin> g.V().values("key").is(eq(1.0f)) // 3.5.x
+==>1.0
+gremlin> g.V().has('key',1.0) // 3.5.x - likely due to Groovy going to BigDecimal for "1.0"
+java.lang.NumberFormatException
+Type ':help' or ':h' for help.
+Display stack trace? [yN]n
+gremlin> g.V().values("key").is(eq(new BigDecimal(1.0f))) // 3.5.x
+java.lang.NumberFormatException
+Type ':help' or ':h' for help.
+Display stack trace? [yN]
+gremlin> g.V().has('key',1.0) // proposed
+==>v[2]
+gremlin> g.V().values("key").is(eq(1.0)) // proposed
+==>1.0
+----
+
+==== Comparability
+
+* NaN +
+Comparing on NaN should return no results.
+
+[code]
+----
+gremlin> g.addV().property('key',-5)
+==>v[0]
+gremlin> g.addV().property('key',0)
+==>v[2]
+gremlin> g.addV().property('key',5)
+==>v[4]
+gremlin> g.addV().property('key',Double.NaN)
+==>v[6]
+gremlin> g.V().values("key").is(lte(Double.NaN)) // 3.5.x
+==>-5
+==>0
+==>NaN
+gremlin> g.V().values("key").is(gte(Double.NaN)) // 3.5.x
+==>0
+==>5
+==>NaN
+gremlin> g.V().values("key").is(lt(Double.NaN)) // 3.5.x
+==>-5
+gremlin> g.V().values("key").is(gt(Double.NaN)) // 3.5.x
+==>5
+gremlin> g.V().values("key").is(lte(Double.NaN)) // proposed
+==>NaN
+gremlin> g.V().values("key").is(gte(Double.NaN)) // proposed
+==>NaN
+gremlin> g.V().values("key").is(lte(Double.NaN)) // proposed
+gremlin> g.V().values("key").is(gte(Double.NaN)) // proposed
+----
+
+* Comparability throws exception today but based on the proposal, it returns NULL when comparing incompatibile types.
+  ** When Vertex / Edge / VertexProperty  is compared, today it throws but it should return NULL.
+  ** When NULL is compared, today it throws an exception but it should return NULL. 
+
+==== Equivalence
+
+TinkerPop today uses a hash value for original values for grouping and the behavior is unchanged.
+
+==== Orderability
+
+- Currently, TinkerPop follows comparability for orderability, thus non-comparable and mixed-type values will fail in ordering. The proposed change is to be able to order any types.
+
+[code]
+----
+gremlin> g.V().order(). // 3.5.x
+org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex cannot be cast to java.lang.Comparable
+Type ':help' or ':h' for help.
+Display stack trace? [yN]
+gremlin> g.V(1).values('name').union(identity(),V(2)).order() // 3.5.x
+org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex cannot be cast to java.lang.Comparable
+Type ':help' or ':h' for help.
+Display stack trace? [yN]n
+gremlin> g.V().order()  // proposed
+==>v[1]
+==>v[2]
+==>v[3]
+==>v[4]
+==>v[5]
+==>v[6]
+gremlin> g.V(1).values('name').union(identity(),V(2)).order() // proposed
+==>v[2]
+==>marko
+gremlin> g.addV().property("key", 100)
+==>v[0]
+gremlin> g.addV().property("key", "100000")
+==>v[2]
+gremlin> g.V().values('key').order() // 3.5.x
+java.lang.Integer cannot be cast to java.lang.String
+Type ':help' or ':h' for help.
+Display stack trace? [yN]
+gremlin> g.V().values('key').order() // proposed
+==>100
+==>100000
+----
+
+== Open Questions
+
+* Should we take type-promotion into account in terms of equivalence ? +
+[code]
+----
+// In this case below,
+gremlin> g.V().property()
+==>[key:1.0]
+==>[key:1]
+
+// which is more natural, whether we don't de-duplicate them
+gremlin> g.V().property().dedup()
+==>[key:1.0]
+==>[key:1]
+
+// or de-dup them
+gremlin> g.V().property().dedup()
+==>[key:1.0]
+----
+        
+If de-duping, there is another question which value we should filter out. We need to define priority over types in Number. 
+Also note that TinkerPop is Java based and we have Double.NaN and Float.NaN, ±Double.INF and ±Float.INF. Not adhering type casting means, for example, Double.NaN and Float.NaN is not de-duplicated / grouped according to the semantics.
+        
+* Map.Entry is Java dependent type. Instead of defining semantics for Map.Entry, do we introduce a concept of like key-value tuple for it to generalize ?
+* Today we have Date type but don’t we need timezone aware DateTime type as well ?
+* Some graph providers may not support BigDecimal. Do we leave how TP deals with BigDecimal to Graph providers ?
+* Which should be more reasonable, NULL eq NULL is true or false ?
+  ** If it is true, it may be respected in JOIN operation
+* There are a number of situations where the Gremlin grammar won’t support some of the examples - to what extent do these sorts of constructs need to exist in the grammar? Not having them would impact the ability to supply tests that enforce the behaviors that we’ve outlined. 
+* Should UUID be a different type to be taken into account ?
+
+== Technical Appendix
+
+=== Types
+First we need to define which data types the TinkerPop query execution runtime needs to handle. It is JVM based so as a primitive type, we are using the following types:
+
+* Byte: 8-bit signed two's complement integer
+* Boolean: true or false
+* Short: 16-bit signed two's complement integer
+* Integer: 32-bit signed two's complement integer.
+* Long: 64-bit signed two's complement integer.
+* Float: https://en.wikipedia.org/wiki/Single-precision_floating-point_format[single-precision 32-bit IEEE 754 floating point]
+* Double: https://en.wikipedia.org/wiki/Double-precision_floating-point_format[double-precision 64-bit IEEE 754 floating point]
+* BigInteger
+* BigDecimal
+* String / Char
+* UUID (String based equality / comparison, so identical to String)
+* Date
+
+Note that in Double or Float, we have a concept of INFINITY / https://en.wikipedia.org/wiki/Signed_zero[signed-zero], and NaN.
+In addition to these, there are composite types as follows:
+
+* Vertex
+* Edge
+* VertexProperty
+* Property
+    ** Edge property
+    ** Vertex meta property
+* PropertyKey
+* PropertyValue
+* Label
+* ID
+* Path
+* List
+* Map
+* Set / BulkSet
+* Map.Entry (obtained from unfolding a Map)
+
+=== Type Casting
+
+We do type casting a.k.a type promotion for Numbers. Numbers are  Byte, Short, Integer, Long, Float, Double, BigInteger, and BigDecimal. Here is the rule how types are promoted:
+
+* If at least one is BigDecimal then compare as BigDecimal
+* If at least one is BigInteger then compare as BigInteger
+* If at least one is Double then compare as Double
+* If one of them is a Float, then convert both to floating type of highest common bit denomination
+  ** If another value is Long or Double, we need 64bit so convert both to Double 
+  ** Otherwise convert both to Float
+* If at least one is Long then compare as Long
+* If at least one is Integer then compare as Integer
+* If at least one is Short then compare as Short
+* If at least one is Byte then compare as Byte
+
+BigDecimal and BigInteger may not be supported depending on the language and Storage, therefore the behavior of type casting for these 2 types can vary depending on a Graph provider. 
+
+=== Equality
+
+==== Primitive types
+===== Number
+
+Number consists of Byte, Short, Integer, Long, Float, Double, BigInteger, and BigDecimal.
+
+* If either one of LHS or RHS is Number and another isn't, eq returns FALSE.
+* If both LHS and RHS are Number, it follows the type casting described above and then check the equality.
+* Example for edge cases:
+    ** -0.0 eq 0.0  = TRUE
+    ** +0.0 eq 0.0 = TRUE
+    **  -0.0 eq +0.0 = TRUE
+    ** NaN eq NaN  = FALSE
+    ** +INF eq +INF = TRUE
+    **  -INF eq -INF = TRUE
+    **  -INF eq +INF = FALSE
+* TinkerPop is JVM based so there can be ±INF^^float and ±INF^^double, NaN^^float and NaN^^double. They also adhere the type promotion.
+
+===== Boolean
+
+* If either one of LHS or RHS is Boolean and another isn't, return FALSE
+* True != False, True == True, False == False
+
+===== String
+
+* If either one of LHS or RHS is String and another isn't, return FALSE
+* We assume the common graphical order over unicode strings.
+* LHS and RHS needs to be lexicographically equal for LHS eq RHS == TRUE for String.
+
+===== Date
+
+* If either one of LHS or RHS is Date and another isn't, return FALSE
+* LHS eq RHS == TRUE when both LHS and RHS value are numerically identical in Unix Epoch time.
+
+===== NULL
+
+* If either one of LHS or RHS is null and another isn't, return FALSE
+* If both LHS and RHS are null, return TRUE 
+
+==== Composite types
+
+For all of them, if LHS and RHS is not of the same data type, equality returns FALSE. The following semantics applied when both LHS and RHS has the data type.
+
+===== Vertex / Edge / VertexProperty
+
+They are considered as Element family in TinkerPop and if 2 elements have the same type and have the same ID, they are considered as equal.
+
+===== Property
+
+If key and value are same, 2 properties are equal.
+
+===== PropertyKey
+
+key is String type so Equality for String type applies.
+
+===== PropertyValue
+
+Any type, so Equality for a corresponding type applies.
+
+===== ID
+
+Any type, so Equality for a corresponding type applies.
+
+===== Label
+
+label is String type so Equality for String type applies.
+
+===== Path
+
+2 Paths are equal when their path elements are equal (using equality of List), and the corresponding path labels are also equal. 
+
+===== List
+
+* If either one of LHS or RHS is List and another isn't, return FALSE
+* When both are List, then
+    ** if the size of them are different, return FALSE
+    ** L(n) denotes n-th element in list L. 
+        *** For 2 lists L1 and L2 to be equal (L1 is equal to L2), for all 0 <= x < n (n is length of L1 and L2) L1(n) eq L2(n) must return TRUE.
+        *** For 2 lists L1 and L2 to be not equal (L1 eq L2 returns FALSE), for any 0 <= x < n (n is length of L1 and L2) L1(n) eq L2(n) must return FALSE.
+
+===== Map
+
+* If either one of LHS or RHS is Map and another isn't, return FALSE
+* For 2 Maps M1 and M2 to be equal,
+    ** All keys in M1 should be within keys in M2
+    ** All keys in M2 should be within keys in M1
+    ** M1 and M2 should have the same number of  keys
+    ** For all keys k(1), k(2), ...k(n) in M1, M1[k] eq M2[k] should return TRUE
+    ** In Gremlin key order is not respected when determining equality
+
+=== Equivalence
+
+Equivalence is identical to Equality, except for the cases listed below.
+
+==== Primitive types
+===== Number
+
+* Unlike Equality, we *don't do* type casting for Equivalence.
+    ** If the type is different, they are not equivalent.
+        *** +INF^^double is not equivalent to +INF^^float
+        *** NaN^^double is not equivalent to NaN^^float
+    ** 123 and 123.0 are equal but not equivalent to each other
+* -0.0, 0.0, and +0.0 are not equivalent to each other
+    ** -0.0 is equivalent to -0.0
+    ** 0.0 is equivalent to 0.0
+    ** +0.0 is equivalent to +0.0
+* -INF and +INF are not equivalent to each other
+    ** -INF is equivalent to -INF
+    ** +INF is equivalent to +INF
+    ** They are equialavlent to each other irrespective to its underlying type, so in Java, for example, Double.POSITIVE_INFINITY is equivalent to Float.POSITIVE_INFINITY.
+* NaN is not equivalent to any other numbers
+    ** NaN *is equivalent to* NaN irrespective to its underlying type, so in Java, for example, Double.NaN is equivalent to Float.NaN.
+
+===== NULL
+* NULL is not equivalent to any other values
+* NULL is equivalent to NULL
+
+=== Comparability
+
+==== Primitive types
+===== Number
+
+* If either one of LHS or RHS is Numbers and another isn’t, throw an Exception. This comes first before the handling for each type.
+* If both LHS and RHS are Numbers, try the type casting, and then compare 2 values.
+* For -0.0, 0.0, +0.0, lt and gt returns FALSE and lte, gte returns TRUE because they are "equal" in this semantics.
+* -INF < +INF
+* Any comparison between NaN and any numbers (including NaN) should return FALSE +
+https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.2.3
+* IF null and NaN is compared it should throw as their “type” is different
+
+===== Boolean
+* If either one of LHS or RHS is Boolean and another isn’t, throws an Exception
+* False < True
+
+===== String
+* If either one of LHS or RHS is String and another isn’t, returns NULL.
+* We assume the common lexicographical order over unicode strings
+* LHS and RHS are compared lexicographically
+
+===== Date
+* If either one of LHS or RHS is Date and another isn’t, throw an Exception
+* Compare LHS and RHS based on chronological order, i.e. numerical order in timestamp.
+
+===== NULL
+* NULL is not comparable, if the LHS or RHS is NULL then the comparison result is NULL.
+
+==== Composite types
+
+For all of them, if LHS and RHS is not of the same data type, equality returns FALSE. The following semantics applied when both LHS and RHS has the data type.
+
+===== Vertex / Edge / VertexProperty
+They are not comparable, return NULL.
+
+===== Property
+It it not comparable, return NULL.
+
+===== PropertyKey
+Comparability of String applies.
+
+===== PropertyValue
+Property values are of any primitive types defined, so Comparability for a corresponding type applies.
+
+===== ID
+IDs are of any primitive types defined, so Comparability for a corresponding type applies.
+
+===== Label
+Comparability of String applies.
+
+===== Path
+It it not comparable, throw an Exception.
+
+===== List
+It it not comparable, throw an Exception.
+
+===== Map
+It it not comparable, throw an Exception.
+
+===== Map.Entry
+It it not comparable, throw an Exception.
+
+===== Set
+It it not comparable, throw an Exception.
+
+=== Orderability
+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)
+
+* NULL
+* Boolean
+* Number
+* Date
+* String
+* Vertex
+* Edge
+* VertexProperty
+* Property
+* Path
+* List
+* Map
+
+==== Primitive types
+===== Number
+* Same applies as Comparability. Exceptions are as below:
+    ** NaN is ordered at a larger index among all Numbers. i.e. after +INF.
+* We do type promotion for orderability as we do for comparability.
+
+===== Boolean
+* False < True
+
+===== String
+* String value is ordered lexicographically
+
+===== Date
+* Date value is ordered chronologically
+
+===== NULL
+* NULL is after all value types
+
+==== Composite types
+===== Vertex / Edge / VertexProperty
+
+They are ordered by their ID. The ID is chosen internally by the implementation, so ordering is implementation specific, but is guaranteed to be stable.
+
+===== Property
+They are ordered by property key. If the key is equal, then property value is used as the 2nd key.
+
+===== PropertyKey
+Comparability of String applies.
+
+===== PropertyValue
+Property values are of any primitive types defined, so orderability for a corresponding type applies.
+
+===== ID
+IDs are of any primitive types defined, so orderability for a corresponding type applies.
+
+===== Label
+Comparability of String applies.
+
+===== Path
+* Orderability of the 1st element in the Path applies. Empty Path should come first.
+* If the 1st element is tie, then check the next element, and so on.
+* If one Path exhausts the element fast then it comes earlier in the order.
+
+===== List
+* Orderability of the 1st element in the List applies.
+* Empty List should come first.
+* If the 1st element is tie, then check the next element, and so on.
+* If one List exhausts the element fast then it comes earlier in the order.
+
+===== Map
+
+* For 2 maps, get the 1st entry (a key-value pair) from both, the orderability between them decides the order of the maps.
+* If the 1st entry is tie, then we pick the 2nd one and repeat the process until we determine the order.
+    ** So the orderability of Map depends on in which order they return an entry. It is implementation dependent and undefined in this semantics.
+* If one Map exhausts an entry earlier than another, then it comes earlier in the order.
+
+===== Map.Entry
+* First check the orderability of their key.
+* If the key ties, then check the orderability of their value.
+
+===== Set
+* For 2 sets, get the 1st item from both, the orderbaility between them decides the order of the sets.
+* If the 1st item is tie, we pick the 2nd one and so on until we determine the order.
+    ** So the orderability of Set depends on in which order they return an item. It is implementation dependent and undefined in this semantics.
+* If one Set exhausts an item earlier than another, then it comes earlier in the order.

[tinkerpop] 04/07: Update List equality definition

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 8aa59d06a7dfc113c2636441479efd9a0f629df4
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 13:37:55 2021 -0700

    Update List equality definition
---
 docs/src/dev/future/equality_proposal.asciidoc | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index 24e68a5..3abac1a 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -511,12 +511,7 @@ label is String type so Equality for String type applies.
 
 ===== List
 
-* If either one of LHS or RHS is List and another isn't, return FALSE
-* When both are List, then
-    ** if the size of them are different, return FALSE
-    ** L(n) denotes n-th element in list L. 
-        *** For 2 lists L1 and L2 to be equal (L1 is equal to L2), for all 0 <= x < n (n is length of L1 and L2) L1(n) eq L2(n) must return TRUE.
-        *** For 2 lists L1 and L2 to be not equal (L1 eq L2 returns FALSE), for any 0 <= x < n (n is length of L1 and L2) L1(n) eq L2(n) must return FALSE.
+* Two lists are equal if they contain the same (equal to each other) elements in the same order.
 
 ===== Map
 

[tinkerpop] 06/07: Update the type cast description for integer/float values

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit eb2e20d2be2463b6776c07e3312b4a843638228e
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 14:36:43 2021 -0700

    Update the type cast description for integer/float values
---
 docs/src/dev/future/equality_proposal.asciidoc | 36 +++++++++++++++++++-------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index dee44d6..16d5808 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -384,20 +384,38 @@ Also note that TinkerPop is Java based and we have Double.NaN and Float.NaN, ±D
 === Types
 First we need to define which data types the TinkerPop query execution runtime needs to handle. It is JVM based so as a primitive type, we are using the following types:
 
-* Byte: 8-bit signed two's complement integer
 * Boolean: true or false
-* Short: 16-bit signed two's complement integer
-* Integer: 32-bit signed two's complement integer.
-* Long: 64-bit signed two's complement integer.
-* Float: https://en.wikipedia.org/wiki/Single-precision_floating-point_format[single-precision 32-bit IEEE 754 floating point]
-* Double: https://en.wikipedia.org/wiki/Double-precision_floating-point_format[double-precision 64-bit IEEE 754 floating point]
-* BigInteger
-* BigDecimal
+* Integer
+  ** int8
+  ** int16 (short)
+  ** int32
+  ** int64 (long)
+  ** uint8 (byte)
+  ** uint16
+  ** uint32
+  ** uint64
+  ** BigInt
+* Float
+  ** float32
+  ** float64 (double)
+  *** In Double and Float, we have a concept of INFINITY / https://en.wikipedia.org/wiki/Signed_zero[signed-zero], and NaN.
+  ** BigFloat
 * String / Char
 * UUID
 * Date
 
-Note that in Double or Float, we have a concept of INFINITY / https://en.wikipedia.org/wiki/Signed_zero[signed-zero], and NaN.
+Graph providers may not support all of these types depending on the architecture and implementation. Therefore TinkerPop must provide a way for Graph providers to override the behavior while it has its own default behavior. Also when some types are not supported Graph providers needs to map unsupported types into supported types internally. This mapping can be done in either information-preserving manner or non-preserving manner. Graph providers must tell which mapping they support throu [...]
+
+* Which atomic types are supported
+  ** Boolean, Integer, Float, String, UUID and Date
+  ** TinkerPop by default supports all of them
+* Which integer types are supported
+  ** int8, int16, int32, int64, uint8, uint16, uint32, uint64, BigInt
+  ** TinkerPop by default supports uint8 (byte), int16 (short), int32 (int), int64 (long) and BigInt
+* Which float types are supported
+  ** float32, float64 and BigFloat
+  ** TinkerPop by defualt supports all as float, double, and BigDecimal in Java
+
 In addition to these, there are composite types as follows:
 
 * Vertex

[tinkerpop] 02/07: Add Apache license header

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 6b9114070046fe50d6a2b41cdc13f0761102caff
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 12:04:43 2021 -0700

    Add Apache license header
---
 docs/src/dev/future/equality_proposal.asciidoc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index 4119dfa..ef317d7 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -1,3 +1,23 @@
+////
+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.
+////
+image::apache-tinkerpop-logo.png[width=500,link="https://tinkerpop.apache.org"]
+
+*1.0.0*
+
 = Proposal for equality, equivalance, comparability and orderability semantics for TinkerPop
 
 == Motivation

[tinkerpop] 07/07: Change NULL to NULLTYPE to avoid confusion from Java null value

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 11e8bb5bca33e5ee22a30ac38a7cc9478798bc14
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 14:47:33 2021 -0700

    Change NULL to NULLTYPE to avoid confusion from Java null value
---
 docs/src/dev/future/equality_proposal.asciidoc | 54 +++++++++++++-------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index 16d5808..36585d2 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -127,7 +127,7 @@ In the above section we used the notions of "equality" and "comparison" in a gen
 
 Equality defines when two values are considered equal in the context of database lookups and predicates, while  equivalence defines value collation semantics in the context of, for instance, deduplication. For instance, equivalence over two values `a := Double.NaN` and `b:= Double.NaN` is true, but equality would (in our proposal) be defined as false; the rational here (which is commonly found in query and programming languages) is that comparing two "unknown" numbers — which is a freque [...]
 
-Both equality and equivalence can be understood as complete, i.e. the result of equality and equivalence checks is always either TRUE or FALSE (in particular, it never returns NULL or throws an exception). The details on equality and equivalence are sketched in the following two subsections, respectively.
+Both equality and equivalence can be understood as complete, i.e. the result of equality and equivalence checks is always either TRUE or FALSE (in particular, it never returns NULLTYPE or throws an exception). The details on equality and equivalence are sketched in the following two subsections, respectively.
 
 ===== Equality 
 
@@ -146,7 +146,7 @@ gremlin> g.V().as("v").out().out().where(eq("v"))
 
 * Equality adheres to type promotion semantics for numerical values, i.e. equality holds for values of different numerical type if they cast into the exactly same same value of the lowest common super type.
 * Other than the type promotion between Numbers, 2 values of different type are always regarded as not equal.
-* Equality checks always return TRUE or FALSE. They never result in NULL output, undefined behavior, nor do they ever throw an error. Detailed behavior is described in
+* Equality checks always return TRUE or FALSE. They never result in NULLTYPE output, undefined behavior, nor do they ever throw an error. Detailed behavior is described in
 
 ===== Equivalence
 
@@ -168,11 +168,11 @@ gremlin> g.V().group().by("age")
 ** NaN is not equal to NaN, but equivalent to each other
 
 * Other than the edge case around NaN (and, as of today, Numbers), equivalence in TinkerPop is identical to equality.
-* Like equality, equivalence checks always return TRUE or FALSE. They never result in NULL output, undefined behavior, nor do they ever throw an error.
+* Like equality, equivalence checks always return TRUE or FALSE. They never result in NULLTYPE output, undefined behavior, nor do they ever throw an error.
 
 ==== Comparability vs. Orderability
 
-Comparability and orderability can be understood as the "dual" concepts of equality and equivalence for range comparisons (rather than exact comparison). For the 2 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 compar [...]
+Comparability and orderability can be understood as the "dual" concepts of equality and equivalence for range comparisons (rather than exact comparison). For the 2 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 compar [...]
 More details on comparability and orderability are sketched in the following two subsections, respectively.
 
 ===== Comparability
@@ -188,13 +188,13 @@ 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 NULL if and only if we are comparing incomparable data types. How this NULL result is handled is Graph provider dependent.
+* 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.
 * Otherwise Comparison does return TRUE or FALSE
 
 ===== Orderability
 
 * Used to determine the order. In TinkerPop, the order step follows the notion of orderability.
-* Orderability must not result in NULL / undefined behavior.
+* Orderability must not result in NULLTYPE / undefined behavior.
 * Orderability must not throw an error. In other words, even if 2 values are incomparable we should still be able to determine the order of those two. This inevitably leads to the requirement to define the order across different data types. For the detailed order across types, see appendix.
 * Orderability determines if 2 values are ordered at the same position or one value is positioned earlier than another.
 * The concept of equivalence is used to determine if the 2 values are at the same position
@@ -304,9 +304,9 @@ gremlin> g.V().values("key").is(lte(Double.NaN)) // proposed
 gremlin> g.V().values("key").is(gte(Double.NaN)) // proposed
 ----
 
-* Comparability throws exception today but based on the proposal, it returns NULL when comparing incompatibile types.
-  ** When Vertex / Edge / VertexProperty  is compared, today it throws but it should return NULL.
-  ** When NULL is compared, today it throws an exception but it should return NULL. 
+* Comparability throws exception today but based on the proposal, it returns NULLTYPE when comparing incompatibile types.
+  ** When Vertex / Edge / VertexProperty  is compared, today it throws but it should return NULLTYPE.
+  ** When NULLTYPE is compared, today it throws an exception but it should return NULLTYPE. 
 
 ==== Equivalence
 
@@ -375,7 +375,7 @@ Also note that TinkerPop is Java based and we have Double.NaN and Float.NaN, ±D
 * Map.Entry is Java dependent type. Instead of defining semantics for Map.Entry, do we introduce a concept of like key-value tuple for it to generalize ?
 * Today we have Date type but don’t we need timezone aware DateTime type as well ?
 * Some graph providers may not support BigDecimal. Do we leave how TP deals with BigDecimal to Graph providers ?
-* Which should be more reasonable, NULL eq NULL is true or false ?
+* Which should be more reasonable, NULLTYPE eq NULLTYPE is true or false ?
   ** If it is true, it may be respected in JOIN operation
 * There are a number of situations where the Gremlin grammar won’t support some of the examples - to what extent do these sorts of constructs need to exist in the grammar? Not having them would impact the ability to supply tests that enforce the behaviors that we’ve outlined. 
 
@@ -403,6 +403,8 @@ First we need to define which data types the TinkerPop query execution runtime n
 * String / Char
 * UUID
 * Date
+* NULLTYPE
+  ** It denotes the "undefined" value.
 
 Graph providers may not support all of these types depending on the architecture and implementation. Therefore TinkerPop must provide a way for Graph providers to override the behavior while it has its own default behavior. Also when some types are not supported Graph providers needs to map unsupported types into supported types internally. This mapping can be done in either information-preserving manner or non-preserving manner. Graph providers must tell which mapping they support throu [...]
 
@@ -490,10 +492,10 @@ Number consists of Byte, Short, Integer, Long, Float, Double, BigInteger, and Bi
 * If either one of LHS or RHS is Date and another isn't, return FALSE
 * LHS eq RHS == TRUE when both LHS and RHS value are numerically identical in Unix Epoch time.
 
-===== NULL
+===== NULLTYPE
 
-* If either one of LHS or RHS is null and another isn't, return FALSE
-* If both LHS and RHS are null, return TRUE 
+* If either one of LHS or RHS is NULLTYPE and another isn't, return FALSE
+* If both LHS and RHS are NULLTYPE, return TRUE 
 
 ==== Composite types
 
@@ -562,9 +564,9 @@ Equivalence is identical to Equality, except for the cases listed below.
 * NaN is not equivalent to any other numbers
     ** NaN *is equivalent to* NaN irrespective to its underlying type, so in Java, for example, Double.NaN is equivalent to Float.NaN.
 
-===== NULL
-* NULL is not equivalent to any other values
-* NULL is equivalent to NULL
+===== NULLTYPE
+* NULLTYPE is not equivalent to any other values
+* NULLTYPE is equivalent to NULLTYPE
 
 === Comparability
 
@@ -577,38 +579,38 @@ Equivalence is identical to Equality, except for the cases listed below.
 * -INF < +INF
 * Any comparison between NaN and any numbers (including NaN) should return FALSE +
 https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.2.3
-* IF null and NaN is compared it should throw as their “type” is different
+* IF NULLTYPE and NaN is compared it should return NULLTYPE as their "type" is different and they are not comparable.
 
 ===== Boolean
 * If either one of LHS or RHS is Boolean and another isn’t, throws an Exception
 * False < True
 
 ===== String
-* If either one of LHS or RHS is String and another isn’t, returns NULL.
+* If either one of LHS or RHS is String and another isn’t, returns NULLTYPE.
 * We assume the common lexicographical order over unicode strings
 * LHS and RHS are compared lexicographically
 * UUID is evaluated based on its String representation.
 
 ===== UUID
 * UUID is evaluated based on its String representation.
-* However, for example, UUID("b46d37e9-755c-477e-9ab6-44aabea51d50") and String "b46d37e9-755c-477e-9ab6-44aabea51d50" cannot be compared with each other, hence comparing them returns NULL.
+* However, for example, UUID("b46d37e9-755c-477e-9ab6-44aabea51d50") and String "b46d37e9-755c-477e-9ab6-44aabea51d50" cannot be compared with each other, hence comparing them returns NULLTYPE.
 
 ===== Date
 * If either one of LHS or RHS is Date and another isn’t, throw an Exception
 * Compare LHS and RHS based on chronological order, i.e. numerical order in timestamp.
 
-===== NULL
-* NULL is not comparable, if the LHS or RHS is NULL then the comparison result is NULL.
+===== NULLTYPE
+* NULLTYPE is not comparable, if the LHS or RHS is NULLTYPE then the comparison result is NULLTYPE.
 
 ==== Composite types
 
 For all of them, if LHS and RHS is not of the same data type, equality returns FALSE. The following semantics applied when both LHS and RHS has the data type.
 
 ===== Vertex / Edge / VertexProperty
-They are not comparable, return NULL.
+They are not comparable, return NULLTYPE.
 
 ===== Property
-It it not comparable, return NULL.
+It it not comparable, return NULLTYPE.
 
 ===== PropertyKey
 Comparability of String applies.
@@ -641,7 +643,7 @@ It it not comparable, throw an Exception.
 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)
 
-* NULL
+* NULLTYPE
 * Boolean
 * Number
 * Date
@@ -672,8 +674,8 @@ To sort across any types of values, we define the order between each type as fol
 ===== Date
 * Date value is ordered chronologically
 
-===== NULL
-* NULL is after all value types
+===== NULLTYPE
+* NULLTYPE is before all value types
 
 ==== Composite types
 ===== Vertex / Edge / VertexProperty

[tinkerpop] 03/07: Add UUID as an independent type

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 5c7993acee7fea2555b8017fc1fbfcbc6b83da8f
Author: Norio Akagi (norakagi) <no...@amazon.com>
AuthorDate: Thu Oct 28 13:31:01 2021 -0700

    Add UUID as an independent type
---
 docs/src/dev/future/equality_proposal.asciidoc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/docs/src/dev/future/equality_proposal.asciidoc b/docs/src/dev/future/equality_proposal.asciidoc
index ef317d7..24e68a5 100644
--- a/docs/src/dev/future/equality_proposal.asciidoc
+++ b/docs/src/dev/future/equality_proposal.asciidoc
@@ -378,7 +378,6 @@ Also note that TinkerPop is Java based and we have Double.NaN and Float.NaN, ±D
 * Which should be more reasonable, NULL eq NULL is true or false ?
   ** If it is true, it may be respected in JOIN operation
 * There are a number of situations where the Gremlin grammar won’t support some of the examples - to what extent do these sorts of constructs need to exist in the grammar? Not having them would impact the ability to supply tests that enforce the behaviors that we’ve outlined. 
-* Should UUID be a different type to be taken into account ?
 
 == Technical Appendix
 
@@ -395,7 +394,7 @@ First we need to define which data types the TinkerPop query execution runtime n
 * BigInteger
 * BigDecimal
 * String / Char
-* UUID (String based equality / comparison, so identical to String)
+* UUID
 * Date
 
 Note that in Double or Float, we have a concept of INFINITY / https://en.wikipedia.org/wiki/Signed_zero[signed-zero], and NaN.
@@ -464,6 +463,10 @@ Number consists of Byte, Short, Integer, Long, Float, Double, BigInteger, and Bi
 * We assume the common graphical order over unicode strings.
 * LHS and RHS needs to be lexicographically equal for LHS eq RHS == TRUE for String.
 
+===== UUID
+* UUID is evaluated based on its String representation.
+* However, for example, UUID("b46d37e9-755c-477e-9ab6-44aabea51d50") and String "b46d37e9-755c-477e-9ab6-44aabea51d50" are not equal to oeach other.
+
 ===== Date
 
 * If either one of LHS or RHS is Date and another isn't, return FALSE
@@ -573,6 +576,11 @@ https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.2.3
 * If either one of LHS or RHS is String and another isn’t, returns NULL.
 * We assume the common lexicographical order over unicode strings
 * LHS and RHS are compared lexicographically
+* UUID is evaluated based on its String representation.
+
+===== UUID
+* UUID is evaluated based on its String representation.
+* However, for example, UUID("b46d37e9-755c-477e-9ab6-44aabea51d50") and String "b46d37e9-755c-477e-9ab6-44aabea51d50" cannot be compared with each other, hence comparing them returns NULL.
 
 ===== Date
 * If either one of LHS or RHS is Date and another isn’t, throw an Exception
@@ -647,6 +655,9 @@ To sort across any types of values, we define the order between each type as fol
 ===== String
 * String value is ordered lexicographically
 
+===== UUID
+* UUID is ordered lexicographically based on its String representation
+
 ===== Date
 * Date value is ordered chronologically