Skip to content

Commit

Permalink
Merge pull request #3893 from atlanhq/dev/cassandraPhase2
Browse files Browse the repository at this point in the history
Janus Optimization
  • Loading branch information
aarshi0301 authored Dec 13, 2024
2 parents 619f518 + 224cce5 commit 69d41ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public enum AtlasConfiguration {
ENABLE_ASYNC_INDEXSEARCH("atlas.indexsearch.async.enable", false),
ATLAS_INDEXSEARCH_QUERY_SIZE_MAX_LIMIT("atlas.indexsearch.query.size.max.limit", 100000),
ATLAS_INDEXSEARCH_LIMIT_UTM_TAGS("atlas.indexsearch.limit.ignore.utm.tags", ""),
FETCH_COLLAPSED_RESULT("atlas.indexsearch.fetch.collapsed.result", true),
ATLAS_INDEXSEARCH_ENABLE_API_LIMIT("atlas.indexsearch.enable.api.limit", false),

/**
Expand All @@ -132,6 +131,7 @@ public enum AtlasConfiguration {
* This configuration is used to enable fetching non primitive attributes in index search
*/
ATLAS_INDEXSEARCH_ENABLE_FETCHING_NON_PRIMITIVE_ATTRIBUTES("atlas.indexsearch.enable.fetching.non.primitive.attributes", true),

ATLAS_MAINTENANCE_MODE("atlas.maintenance.mode", false),

DELTA_BASED_REFRESH_ENABLED("atlas.authorizer.enable.delta_based_refresh", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2025,28 +2025,6 @@ public static Iterator<AtlasEdge> getActiveEdges(AtlasVertex vertex, String chil
RequestContext.get().endMetricRecord(metricRecorder);
}
}

/**
* Get all the active edges
* @param vertex entity vertex
* @return Iterator of children edges
*/
public static Iterator<AtlasJanusEdge> getOnlyActiveEdges(AtlasVertex vertex, AtlasEdgeDirection direction) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("GraphHelper.getOnlyActiveEdges");

try {
return vertex.query()
.direction(direction)
.has(STATE_PROPERTY_KEY, ACTIVE_STATE_VALUE)
.edges()
.iterator();
} catch (Exception e) {
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e);
}
finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
}
public static Iterator<AtlasVertex> getActiveVertices(AtlasVertex vertex, String childrenEdgeLabel, AtlasEdgeDirection direction) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("CategoryPreProcessor.getEdges");

Expand Down Expand Up @@ -2096,4 +2074,26 @@ private static Set<String> parseLabelsString(String labels) {

return ret;
}

/**
* Get all the active edges
* @param vertex entity vertex
* @return Iterator of children edges
*/
public static Iterator<AtlasJanusEdge> getOnlyActiveEdges(AtlasVertex vertex, AtlasEdgeDirection direction) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("GraphHelper.getOnlyActiveEdges");

try {
return vertex.query()
.direction(direction)
.has(STATE_PROPERTY_KEY, ACTIVE_STATE_VALUE)
.edges()
.iterator();
} catch (Exception e) {
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e);
}
finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ public AtlasObjectId toAtlasObjectId(AtlasVertex entityVertex) throws AtlasBaseE

if (entityType != null) {
Map<String, Object> uniqueAttributes = new HashMap<>();
Map<String, Object> attributes = new HashMap<>();
Set<String> relationAttributes = RequestContext.get().getRelationAttrsForSearch();

for (AtlasAttribute attribute : entityType.getUniqAttributes().values()) {
Object attrValue = getVertexAttribute(entityVertex, attribute);
Expand All @@ -296,8 +294,9 @@ public AtlasObjectId toAtlasObjectId(AtlasVertex entityVertex) throws AtlasBaseE
}
}

Map<String, Object> attributes = new HashMap<>();
Set<String> relationAttributes = RequestContext.get().getRelationAttrsForSearch();
if (CollectionUtils.isNotEmpty(relationAttributes)) {

for (String attributeName : relationAttributes) {
AtlasAttribute attribute = entityType.getAttribute(attributeName);
if (attribute != null
Expand Down Expand Up @@ -1059,7 +1058,6 @@ private void retrieveEdgeLabels(AtlasVertex entityVertex, AtlasEdgeDirection edg

edgeLabels.stream().forEach(e -> propertiesMap.put(e, StringUtils.SPACE));
}

private void updateAttrValue( Map<String, Object> propertiesMap, VertexProperty<Object> property){
Object value = propertiesMap.get(property.key());
if (value instanceof List) {
Expand All @@ -1071,7 +1069,6 @@ private void updateAttrValue( Map<String, Object> propertiesMap, VertexProperty<
}
}


private boolean isPolicyAttribute(Set<String> attributes) {
Set<String> exclusionSet = new HashSet<>(Arrays.asList(AccessControlUtils.ATTR_POLICY_TYPE,
AccessControlUtils.ATTR_POLICY_USERS,
Expand Down Expand Up @@ -1931,9 +1928,9 @@ public Object getVertexAttributePreFetchCache(AtlasVertex vertex, AtlasAttribute
return null;
}

// value is present as marker or is inward relation, fetch the value from the vertex
// value is present as marker or is inward/outward relation, fetch the value from the vertex
if (properties.get(attribute.getName()) == StringUtils.SPACE || AtlasRelationshipEdgeDirection.IN.equals(attribute.getRelationshipEdgeDirection())
|| AtlasRelationshipEdgeDirection.OUT.equals(attribute.getRelationshipEdgeDirection())) {
|| AtlasRelationshipEdgeDirection.OUT.equals(attribute.getRelationshipEdgeDirection())) {
return mapVertexToAttribute(vertex, attribute, null, false);
}

Expand Down

0 comments on commit 69d41ec

Please sign in to comment.