You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ra...@apache.org on 2026/04/01 22:42:49 UTC

(atlas) 02/02: ATLAS-5264: code cleanup: remove unused code (#586)

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

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

commit bbd4fbab77ef0898eb05bd4cf52f5a1a4346b731
Author: chaitalicod <36...@users.noreply.github.com>
AuthorDate: Wed Apr 1 22:36:41 2026 +0530

    ATLAS-5264: code cleanup: remove unused code (#586)
    
    (cherry picked from commit d355acd720ae81f3f4ff18d70136f3ca443005fc)
---
 .../java/org/apache/atlas/AtlasConfiguration.java  |   1 -
 .../atlas/discovery/EntityDiscoveryService.java    |   4 +-
 .../query/executors/ScriptEngineBasedExecutor.java | 152 ---------------------
 3 files changed, 1 insertion(+), 156 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
index f8de7c524..51b8963c3 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
@@ -87,7 +87,6 @@ public enum AtlasConfiguration {
     PROCESS_NAME_UPDATE_PATCH("atlas.process.name.update.patch", false),
     PROCESS_IMPALA_NAME_UPDATE_PATCH("atlas.process.impala.name.update.patch", false),
     STORE_DIFFERENTIAL_AUDITS("atlas.entity.audit.differential", false),
-    DSL_EXECUTOR_TRAVERSAL("atlas.dsl.executor.traversal", true),
     DSL_CACHED_TRANSLATOR("atlas.dsl.cached.translator", true),
     DEBUG_METRICS_ENABLED("atlas.debug.metrics.enabled", false),
     TASKS_USE_ENABLED("atlas.tasks.enabled", true),
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index ae0ccc1bc..410a42f1c 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -19,7 +19,6 @@ package org.apache.atlas.discovery;
 
 import com.google.common.annotations.VisibleForTesting;
 import org.apache.atlas.ApplicationProperties;
-import org.apache.atlas.AtlasConfiguration;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.RequestContext;
@@ -47,7 +46,6 @@ import org.apache.atlas.model.profile.AtlasUserSavedSearch;
 import org.apache.atlas.model.tasks.AtlasTask;
 import org.apache.atlas.query.QueryParams;
 import org.apache.atlas.query.executors.DSLQueryExecutor;
-import org.apache.atlas.query.executors.ScriptEngineBasedExecutor;
 import org.apache.atlas.query.executors.TraversalBasedExecutor;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.Constants.AtlasAuditAgingType;
@@ -155,7 +153,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
         this.indexSearchPrefix        = AtlasGraphUtilsV2.getIndexSearchPrefix();
         this.userProfileService       = userProfileService;
         this.suggestionsProvider      = new SuggestionsProviderImpl(graph, typeRegistry);
-        this.dslQueryExecutor         = AtlasConfiguration.DSL_EXECUTOR_TRAVERSAL.getBoolean() ? new TraversalBasedExecutor(typeRegistry, graph, entityRetriever) : new ScriptEngineBasedExecutor(typeRegistry, graph, entityRetriever);
+        this.dslQueryExecutor         = new TraversalBasedExecutor(typeRegistry, graph, entityRetriever);
         this.taskManagement           = taskManagement;
 
         LOG.info("DSL Executor: {}", this.dslQueryExecutor.getClass().getSimpleName());
diff --git a/repository/src/main/java/org/apache/atlas/query/executors/ScriptEngineBasedExecutor.java b/repository/src/main/java/org/apache/atlas/query/executors/ScriptEngineBasedExecutor.java
deleted file mode 100644
index db8b7995d..000000000
--- a/repository/src/main/java/org/apache/atlas/query/executors/ScriptEngineBasedExecutor.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.query.executors;
-
-import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.model.discovery.AtlasSearchResult;
-import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasQueryType;
-import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
-import org.apache.atlas.query.AtlasDSL;
-import org.apache.atlas.query.GremlinQuery;
-import org.apache.atlas.query.QueryParams;
-import org.apache.atlas.repository.graphdb.AtlasGraph;
-import org.apache.atlas.repository.graphdb.AtlasVertex;
-import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
-import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class ScriptEngineBasedExecutor implements DSLQueryExecutor {
-    private static final Logger LOG = LoggerFactory.getLogger(ScriptEngineBasedExecutor.class);
-
-    private final AtlasTypeRegistry    typeRegistry;
-    private final AtlasGraph           graph;
-    private final EntityGraphRetriever entityRetriever;
-
-    public ScriptEngineBasedExecutor(AtlasTypeRegistry typeRegistry, AtlasGraph graph, EntityGraphRetriever entityRetriever) {
-        this.typeRegistry    = typeRegistry;
-        this.graph           = graph;
-        this.entityRetriever = entityRetriever;
-    }
-
-    @Override
-    public AtlasSearchResult execute(String dslQuery, int limit, int offset) throws AtlasBaseException {
-        AtlasSearchResult ret          = new AtlasSearchResult(dslQuery, AtlasQueryType.DSL);
-        GremlinQuery      gremlinQuery = toGremlinQuery(dslQuery, limit, offset);
-        String            queryStr     = gremlinQuery.queryStr();
-        Object            result       = graph.executeGremlinScript(queryStr, false);
-
-        if (result instanceof List && CollectionUtils.isNotEmpty((List<?>) result)) {
-            List<?> queryResult  = (List<?>) result;
-            Object  firstElement = queryResult.get(0);
-
-            if (firstElement instanceof AtlasVertex) {
-                for (Object element : queryResult) {
-                    if (element instanceof AtlasVertex) {
-                        ret.addEntity(entityRetriever.toAtlasEntityHeaderWithClassifications((AtlasVertex) element));
-                    } else {
-                        LOG.warn("searchUsingDslQuery({}): expected an AtlasVertex; found unexpected entry in result {}", dslQuery, element);
-                    }
-                }
-            } else if (gremlinQuery.hasSelectList()) {
-                ret.setAttributes(toAttributesResult(queryResult, gremlinQuery));
-            } else if (firstElement instanceof Map) {
-                for (Object element : queryResult) {
-                    if (element instanceof Map) {
-                        Map<?, ?> map = (Map<?, ?>) element;
-
-                        for (Object key : map.keySet()) {
-                            Object value = map.get(key);
-
-                            if (value instanceof List && CollectionUtils.isNotEmpty((List<?>) value)) {
-                                for (Object o : (List<?>) value) {
-                                    if (o instanceof AtlasVertex) {
-                                        ret.addEntity(entityRetriever.toAtlasEntityHeader((AtlasVertex) o));
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            } else {
-                LOG.warn("searchUsingDslQuery({}/{}): found unexpected entry in result {}", dslQuery, dslQuery, gremlinQuery.queryStr());
-            }
-        }
-
-        return ret;
-    }
-
-    private GremlinQuery toGremlinQuery(String query, int limit, int offset) throws AtlasBaseException {
-        QueryParams  params       = QueryParams.getNormalizedParams(limit, offset);
-        GremlinQuery gremlinQuery = new AtlasDSL.Translator(query, typeRegistry, params.offset(), params.limit()).translate();
-
-        LOG.debug("Translated Gremlin Query: {}", gremlinQuery.queryStr());
-
-        return gremlinQuery;
-    }
-
-    private AttributeSearchResult toAttributesResult(List<?> results, GremlinQuery query) {
-        AttributeSearchResult ret    = new AttributeSearchResult();
-        List<String>          names  = (List<String>) results.get(0);
-        List<List<Object>>    values = extractValues(results.subList(1, results.size()));
-
-        ret.setName(names);
-        ret.setValues(values);
-
-        return ret;
-    }
-
-    private List<List<Object>> extractValues(List<?> results) {
-        List<List<Object>> values = new ArrayList<>();
-
-        for (Object obj : results) {
-            if (obj instanceof Map) {
-                Map<?, ?>    map  = (Map<?, ?>) obj;
-                List<Object> list = new ArrayList<>();
-
-                if (MapUtils.isNotEmpty(map)) {
-                    for (Object key : map.keySet()) {
-                        Object vals = map.get(key);
-
-                        if (vals instanceof List) {
-                            List<?> l = (List<?>) vals;
-
-                            list.addAll(l);
-                        }
-                    }
-
-                    values.add(list);
-                }
-            } else if (obj instanceof List) {
-                List<Object> list = (List<Object>) obj;
-
-                if (CollectionUtils.isNotEmpty(list)) {
-                    values.add(list);
-                }
-            }
-        }
-
-        return values;
-    }
-}