From 19efee0d16f7702e5f64a701f4f2213f790139ee Mon Sep 17 00:00:00 2001 From: chaitalithombare Date: Mon, 30 Mar 2026 21:38:57 +0530 Subject: [PATCH] ATLAS-5264: code cleanup: remove unused code --- .../org/apache/atlas/AtlasConfiguration.java | 1 - .../discovery/EntityDiscoveryService.java | 4 +- .../executors/ScriptEngineBasedExecutor.java | 152 ------------------ 3 files changed, 1 insertion(+), 156 deletions(-) delete mode 100644 repository/src/main/java/org/apache/atlas/query/executors/ScriptEngineBasedExecutor.java diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java index f8de7c524a9..51b8963c366 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 3f845019d20..617d2ee7def 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 @@ 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.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; @@ -154,7 +152,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 db8b7995db6..00000000000 --- 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 - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * 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 names = (List) results.get(0); - List> values = extractValues(results.subList(1, results.size())); - - ret.setName(names); - ret.setValues(values); - - return ret; - } - - private List> extractValues(List results) { - List> values = new ArrayList<>(); - - for (Object obj : results) { - if (obj instanceof Map) { - Map map = (Map) obj; - List 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 list = (List) obj; - - if (CollectionUtils.isNotEmpty(list)) { - values.add(list); - } - } - } - - return values; - } -}