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();
AtlasAttribute baseInstance = definedInType != null ? definedInType.getAttribute(attribute.getName()) : null;
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); String indexFieldName = managementSystem.getIndexFieldName(Constants.VERTEX_INDEX, propertyKey);
attribute.setIndexFieldName(indexFieldName); attribute.setIndexFieldName(indexFieldName);
LOG.info("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName()); if (baseInstance != null) {
baseInstance.setIndexFieldName(indexFieldName);
} }
private boolean needsIndexFieldNameResolution(AtlasAttribute attribute) { LOG.info("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName());
return attribute.getIndexFieldName() == null && }
TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory()); }
} }
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