You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/11/21 19:44:34 UTC

[atlas] branch branch-2.0 updated: ATLAS-3519: reuse script engine to improve lineage query performance

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

sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new ce6ca7d  ATLAS-3519: reuse script engine to improve lineage query performance
ce6ca7d is described below

commit ce6ca7dc4da8f006fe94556fbe6dafe1e2e820a9
Author: leslizhang <le...@tencent.com>
AuthorDate: Fri Nov 8 19:16:13 2019 +0800

    ATLAS-3519: reuse script engine to improve lineage query performance
    
    Signed-off-by: Madhan Neethiraj <ma...@apache.org>
    Signed-off-by: Sarath Subramanian <sa...@apache.org>
    (cherry picked from commit bdd110dfe7481815d3a19ebc6acb4fdefacc93ed)
---
 .../atlas/repository/graphdb/janus/AtlasJanusGraph.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
index bbc7630..4acb371 100644
--- a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
+++ b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraph.java
@@ -51,7 +51,6 @@ import org.janusgraph.core.PropertyKey;
 import org.janusgraph.core.SchemaViolationException;
 import org.janusgraph.core.schema.JanusGraphIndex;
 import org.janusgraph.core.schema.JanusGraphManagement;
-import org.janusgraph.core.schema.Mapping;
 import org.janusgraph.core.schema.Parameter;
 import org.janusgraph.diskstorage.BackendException;
 import org.janusgraph.graphdb.database.StandardJanusGraph;
@@ -84,6 +83,14 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
     private final ConvertGremlinValueFunction GREMLIN_VALUE_CONVERSION_FUNCTION = new ConvertGremlinValueFunction();
     private final Set<String>                 multiProperties                   = new HashSet<>();
     private final StandardJanusGraph          janusGraph;
+    private final ThreadLocal<GremlinGroovyScriptEngine> scriptEngine = ThreadLocal.withInitial(() -> {
+        DefaultImportCustomizer.Builder builder = DefaultImportCustomizer.build()
+                                                                         .addClassImports(java.util.function.Function.class)
+                                                                         .addMethodImports(__.class.getMethods())
+                                                                         .addMethodImports(P.class.getMethods());
+        return new GremlinGroovyScriptEngine(builder.create());
+    });
+
 
     public AtlasJanusGraph() {
         this(getGraphInstance());
@@ -330,13 +337,7 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
 
     @Override
     public GremlinGroovyScriptEngine getGremlinScriptEngine() {
-        DefaultImportCustomizer.Builder importBuilder = DefaultImportCustomizer.build()
-                                                                               .addClassImports(java.util.function.Function.class)
-                                                                               .addMethodImports(__.class.getMethods())
-                                                                               .addMethodImports(P.class.getMethods());
-        GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(importBuilder.create());
-
-        return scriptEngine;
+        return scriptEngine.get();
     }
 
     @Override