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
private void resolveIndexFieldNames(AtlasGraphManagement managementSystem, AtlasEntityType entityType) {
for(AtlasAttribute attribute: entityType.getAllAttributes().values()) {
if(needsIndexFieldNameResolution(attribute)) {
resolveIndexFieldName(managementSystem, attribute);
}
}
}
private void resolveIndexFieldName(AtlasGraphManagement managementSystem,
AtlasAttribute attribute) {
AtlasPropertyKey propertyKey = managementSystem.getPropertyKey(attribute.getQualifiedName());
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;
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);
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) {
return attribute.getIndexFieldName() == null &&
TypeCategory.PRIMITIVE.equals(attribute.getAttributeType().getTypeCategory());
LOG.info("Property {} is mapped to index field name {}", attribute.getQualifiedName(), attribute.getIndexFieldName());
}
}
}
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