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

madhan 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 8f0b54e  ATLAS-3338: avoid repeated calls to get index-field name 
during startup
8f0b54e is described below

commit 8f0b54e201420179099d45b7ece8a3879ae53201
Author: Madhan Neethiraj <mad...@apache.org>
AuthorDate: Tue Jul 16 23:43:50 2019 -0700

    ATLAS-3338: avoid repeated calls to get index-field name during startup
    
    (cherry picked from commit 36459c7829c02d92a2af76bc1ea7de31e34bbd67)
---
 .../repository/graph/GraphBackedSearchIndexer.java | 31 +++++++++++++---------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git 
a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
 
b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
index 6dd0ef6..df4356f 100755
--- 
a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
@@ -379,25 +379,30 @@ public class GraphBackedSearchIndexer implements 
SearchIndexer, ActiveStateChang
 
     private void resolveIndexFieldNames(AtlasGraphManagement managementSystem, 
AtlasEntityType entityType) {
         for(AtlasAttribute attribute: entityType.getAllAttributes().values()) {
-            if(needsIndexFieldNameResolution(attribute)) {
-                resolveIndexFieldName(managementSystem, attribute);
-            }
+            resolveIndexFieldName(managementSystem, attribute);
         }
     }
 
-    private void resolveIndexFieldName(AtlasGraphManagement managementSystem,
-                                       AtlasAttribute attribute) {
-        AtlasPropertyKey propertyKey = 
managementSystem.getPropertyKey(attribute.getQualifiedName());
-        String indexFieldName        = 
managementSystem.getIndexFieldName(Constants.VERTEX_INDEX, propertyKey);
+    private void resolveIndexFieldName(AtlasGraphManagement managementSystem, 
AtlasAttribute attribute) {
+        if (attribute.getIndexFieldName() == null && 
TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory())) {
+            AtlasStructType definedInType = attribute.getDefinedInType();
+            AtlasAttribute  baseInstance  = definedInType != null ? 
definedInType.getAttribute(attribute.getName()) : null;
 
-        attribute.setIndexFieldName(indexFieldName);
+            if (baseInstance != null && baseInstance.getIndexFieldName() != 
null) {
+                attribute.setIndexFieldName(baseInstance.getIndexFieldName());
+            } else {
+                AtlasPropertyKey propertyKey    = 
managementSystem.getPropertyKey(attribute.getVertexPropertyName());
+                String           indexFieldName = 
managementSystem.getIndexFieldName(Constants.VERTEX_INDEX, propertyKey);
 
-        LOG.info("Property {} is mapped to index field name {}", 
attribute.getQualifiedName(), attribute.getIndexFieldName());
-    }
+                attribute.setIndexFieldName(indexFieldName);
 
-    private boolean needsIndexFieldNameResolution(AtlasAttribute attribute) {
-        return attribute.getIndexFieldName() == null &&
-                
TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory());
+                if (baseInstance != null) {
+                    baseInstance.setIndexFieldName(indexFieldName);
+                }
+
+                LOG.info("Property {} is mapped to index field name {}", 
attribute.getQualifiedName(), attribute.getIndexFieldName());
+            }
+        }
     }
 
     private void createCommonVertexIndex(AtlasGraphManagement management,

Reply via email to