Commit 36459c78 by Madhan Neethiraj

ATLAS-3338: avoid repeated calls to get index-field name during startup

parent 85f9b502
...@@ -379,25 +379,30 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang ...@@ -379,25 +379,30 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
private void resolveIndexFieldNames(AtlasGraphManagement managementSystem, AtlasEntityType entityType) { private void resolveIndexFieldNames(AtlasGraphManagement managementSystem, AtlasEntityType entityType) {
for(AtlasAttribute attribute: entityType.getAllAttributes().values()) { for(AtlasAttribute attribute: entityType.getAllAttributes().values()) {
if(needsIndexFieldNameResolution(attribute)) { resolveIndexFieldName(managementSystem, attribute);
resolveIndexFieldName(managementSystem, attribute);
}
} }
} }
private void resolveIndexFieldName(AtlasGraphManagement managementSystem, private void resolveIndexFieldName(AtlasGraphManagement managementSystem, AtlasAttribute attribute) {
AtlasAttribute attribute) { if (attribute.getIndexFieldName() == null && TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory())) {
AtlasPropertyKey propertyKey = managementSystem.getPropertyKey(attribute.getQualifiedName()); AtlasStructType definedInType = attribute.getDefinedInType();
String indexFieldName = managementSystem.getIndexFieldName(Constants.VERTEX_INDEX, propertyKey); 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) { if (baseInstance != null) {
return attribute.getIndexFieldName() == null && baseInstance.setIndexFieldName(indexFieldName);
TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory()); }
LOG.info("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName());
}
}
} }
private void createCommonVertexIndex(AtlasGraphManagement management, private void createCommonVertexIndex(AtlasGraphManagement management,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment