You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/01/11 17:40:01 UTC

incubator-tinkerpop git commit: Made a safer comparator for non-comparable objects where if they are equal, then the comparison is 0. CTR.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 4ad66170a -> 1e989b78b


Made a safer comparator for non-comparable objects where if they are equal, then the comparison is 0. CTR.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/1e989b78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/1e989b78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/1e989b78

Branch: refs/heads/master
Commit: 1e989b78b36cb9bc6a1ea8c1e7e720048fd1d00f
Parents: 4ad6617
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Jan 11 09:39:57 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Jan 11 09:39:57 2016 -0700

----------------------------------------------------------------------
 .../tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1e989b78/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
index 765b6d5..a371bc3 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
@@ -97,7 +97,12 @@ public final class ObjectWritable<T> implements WritableComparable<ObjectWritabl
 
     @Override
     public int compareTo(final ObjectWritable objectWritable) {
-        return this.t instanceof Comparable ? ((Comparable) this.t).compareTo(objectWritable.get()) : -1;
+        if (this.t instanceof Comparable)
+            return ((Comparable) this.t).compareTo(objectWritable.get());
+        else if (this.t.equals(objectWritable.get()))
+            return 0;
+        else
+            return -1;
     }
 
     public boolean isEmpty() {