You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by xi...@apache.org on 2023/04/03 22:45:27 UTC

[tinkerpop] branch 3.6-dev updated (d3a2e42cc2 -> 98da486ee5)

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

xiazcy pushed a change to branch 3.6-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


    from d3a2e42cc2 Merge branch '3.5-dev' into 3.6-dev
     new 44c888dec6 perf: improved performance of comparison between not compatible types and nulls
     new 98da486ee5 Add changelog entry for #1993 CTR

The 2 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:
 CHANGELOG.asciidoc                                       |  1 +
 .../tinkerpop/gremlin/util/GremlinValueComparator.java   | 16 +++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)


[tinkerpop] 02/02: Add changelog entry for #1993 CTR

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

xiazcy pushed a commit to branch 3.6-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 98da486ee56a04f01f926f15b62bfe4e3502e8da
Author: Yang Xia <55...@users.noreply.github.com>
AuthorDate: Mon Apr 3 15:44:12 2023 -0700

    Add changelog entry for #1993 CTR
---
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index c5d833be0f..0985162ddb 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 This release also includes changes from <<release-3-5-6, 3.5.6>>.
 
 * Fixed bug in grammar that prevented declaration of a `Map` key named `new` without quotes.
+* Improved performance of comparison (equals) between not compatible types and nulls
 
 [[release-3-6-2]]
 === TinkerPop 3.6.2 (Release Date: January 16, 2023)


[tinkerpop] 01/02: perf: improved performance of comparison between not compatible types and nulls

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

xiazcy pushed a commit to branch 3.6-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 44c888dec68d66e56fd2acc8dbf09d7d1eed2aa5
Author: lvca <lv...@users.noreply.github.com>
AuthorDate: Sat Mar 18 10:51:10 2023 -0400

    perf: improved performance of comparison between not compatible types and nulls
    
    This fix dramatically improves performance of traversing when different types are encountered or simply null values. This piece of code should be designed to be fast, because invoked millions of times with queries. It is a bad practice to throw Java exceptions instead of simply return false.
---
 .../tinkerpop/gremlin/util/GremlinValueComparator.java   | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java
index 345ecd8391..ea2566feee 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java
@@ -129,8 +129,18 @@ public abstract class GremlinValueComparator implements Comparator<Object> {
             if (containersOfDifferentSize(f, s))
                 return false;
 
+            // For Compare, NaN always produces ERROR
+            if (eitherAreNaN(f, s))
+                return false;
+
+            // For Compare we do not cross type boundaries, including null
+            if (!comparable(f, s))
+                return false;
+
             try {
-                return this.compare(f, s) == 0;
+              // comparable(f, s) assures that type(f) == type(s)
+              final Type type = Type.type(f);
+              return comparator(type).compare(f, s) == 0;
             } catch (GremlinTypeErrorException ex) {
                 /**
                  * By routing through the compare(f, s) path we expose ourselves to type errors, which should be
@@ -141,7 +151,7 @@ public abstract class GremlinValueComparator implements Comparator<Object> {
                  *
                  * Can also happen for elements nested inside of collections.
                  */
-                return false;
+               return false;
             }
         }
 
@@ -345,7 +355,7 @@ public abstract class GremlinValueComparator implements Comparator<Object> {
         put(Type.MapEntry,       entryComparator);
         put(Type.Unknown,        unknownTypeComparator);
     }};
-    
+
     private GremlinValueComparator() {}
 
     protected Comparator comparator(final Type type) {