You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2021/11/04 12:34:00 UTC

[jira] [Created] (TINKERPOP-2641) Allow orderability on any type

Stephen Mallette created TINKERPOP-2641:
-------------------------------------------

             Summary: Allow orderability on any type
                 Key: TINKERPOP-2641
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2641
             Project: TinkerPop
          Issue Type: Improvement
          Components: process
    Affects Versions: 3.5.1
            Reporter: Stephen Mallette


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
{code}

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`
* Boolean
* Number
* Date
* String
* Vertex
* Edge
* VertexProperty
* Property
* Path
* List
* Map



--
This message was sent by Atlassian Jira
(v8.3.4#803005)