TINKERPOP-1871: improve performace by elimating exception creation in 
ComputerAdjacentVertex


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

Branch: refs/heads/TINKERPOP-1447
Commit: b22d78be2633eaf2ad5de1d22539563d17db4d9a
Parents: 231bbb6
Author: artemaliev <artem.aliev@gmail,com>
Authored: Fri Dec 29 12:49:28 2017 +0300
Committer: artemaliev <artem.aliev@gmail,com>
Committed: Fri Jan 19 14:16:21 2018 +0300

----------------------------------------------------------------------
 .../gremlin/structure/util/reference/ReferenceElement.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b22d78be/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
index 2e45903..1da8144 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.util.reference;
 
+import org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -44,7 +45,12 @@ public abstract class ReferenceElement<E extends Element> 
implements Element, Se
     public ReferenceElement(final Element element) {
         this.id = element.id();
         try {
-            this.label = element.label();
+            //Exception creation takes too much time, return default values 
for known types
+            if (element instanceof ComputerGraph.ComputerAdjacentVertex) {
+                this.label = VertexProperty.DEFAULT_LABEL;
+            } else {
+                this.label = element.label();
+            }
         } catch (final UnsupportedOperationException e) {
             if (element instanceof Vertex)
                 this.label = Vertex.DEFAULT_LABEL;

Reply via email to