Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLH-73 | Cassandra optimisation. Optimise edgeLabel fetching only to root level vertices #4352

Merged
merged 14 commits into from
Mar 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,11 @@ public AtlasObjectId toAtlasObjectId(AtlasVertex entityVertex) throws AtlasBaseE
Map<String, Object> uniqueAttributes = new HashMap<>();
Set<String> relationAttributes = RequestContext.get().getRelationAttrsForSearch();
if (enableJanusOptimisation) {
referenceVertexProperties = preloadProperties(entityVertex, entityType, relationAttributes);
//don't fetch edge labels for a relation attribute
referenceVertexProperties = preloadProperties(entityVertex, entityType, relationAttributes, false);
}
for (AtlasAttribute attribute : entityType.getUniqAttributes().values()) {
Object attrValue = getVertexAttribute(entityVertex, attribute);
Object attrValue = getVertexAttributePreFetchCache(entityVertex, attribute, referenceVertexProperties);

if (attrValue != null) {
uniqueAttributes.put(attribute.getName(), attrValue);
Expand Down Expand Up @@ -1011,7 +1012,7 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex)
return mapVertexToAtlasEntityHeader(entityVertex, Collections.<String>emptySet());
}

private Map<String, Object> preloadProperties(AtlasVertex entityVertex, AtlasEntityType entityType, Set<String> attributes) throws AtlasBaseException {
private Map<String, Object> preloadProperties(AtlasVertex entityVertex, AtlasEntityType entityType, Set<String> attributes, boolean fetchEdgeLabels) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("preloadProperties");

try {
Expand All @@ -1027,7 +1028,12 @@ private Map<String, Object> preloadProperties(AtlasVertex entityVertex, AtlasEnt
Map<String, Set<String>> relationshipsLookup = fetchEdgeNames(entityType);

// Fetch edges in both directions
retrieveEdgeLabels(entityVertex, attributes, relationshipsLookup, propertiesMap);

// if the vertex in scope is root then call below otherwise skip
// we don't support relation attributes of a relation
if (fetchEdgeLabels) {
retrieveEdgeLabels(entityVertex, attributes, relationshipsLookup, propertiesMap);
}

// Iterate through the resulting VertexProperty objects
while (traversal.hasNext()) {
Expand Down Expand Up @@ -1257,7 +1263,7 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeaderWithPrefetch(AtlasVertex e
//pre-fetching the properties
String typeName = entityVertex.getProperty(Constants.TYPE_NAME_PROPERTY_KEY, String.class); //properties.get returns null
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); // this is not costly
Map<String, Object> properties = preloadProperties(entityVertex, entityType, attributes);
Map<String, Object> properties = preloadProperties(entityVertex, entityType, attributes, true);

String guid = (String) properties.get(Constants.GUID_PROPERTY_KEY);

Expand Down
Loading