bharos commented on code in PR #14364:
URL: https://github.com/apache/gravitino/pull/14364#discussion_r4461705021
##########
core/src/main/java/org/apache/gravitino/tag/EffectiveTagResolver.java:
##########
@@ -280,4 +265,41 @@ public Map<MetadataObject, ResolvedTag[]>
resolveWithSources(
});
return result;
}
+
+ private static ResolvedTag[] resolveWithSources(
+ MetadataObject metadataObject, Function<MetadataObject, List<TagEntity>>
reader) {
+ List<MetadataObject> resolutionOrder = new ArrayList<>();
+ resolutionOrder.add(metadataObject);
+
resolutionOrder.addAll(MetadataObjectUtil.getParentMetadataObjects(metadataObject));
+
+ Map<String, ResolvedTag> effectiveTags = new LinkedHashMap<>();
+ for (int index = 0; index < resolutionOrder.size(); index++) {
+ MetadataObject object = resolutionOrder.get(index);
+ boolean inherited = index > 0;
+ reader
+ .apply(object)
+ .forEach(
+ tag ->
+ effectiveTags.putIfAbsent(
+ tag.name(), new
ResolvedTag(tag.copyWithInherited(inherited), object)));
+ }
+ return effectiveTags.values().toArray(new ResolvedTag[0]);
+ }
+
+ private List<TagEntity> loadTags(String metalake, MetadataObject object) {
+ NameIdentifier identifier = MetadataObjectUtil.toEntityIdent(metalake,
object);
+ Entity.EntityType entityType = MetadataObjectUtil.toEntityType(object);
+ try {
+ return entityStore
+ .relationOperations()
+ .listEntitiesByRelation(
+ SupportsRelationOperations.Type.TAG_METADATA_OBJECT_REL,
identifier, entityType);
Review Comment:
If the target or an ancestor isn’t in the entity store yet, this throws
NoSuchEntityException, and that gets cached as a failure for the request.
Should a missing object just mean no tags? Please add a test either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]