justinmclean commented on code in PR #8131:
URL: https://github.com/apache/gravitino/pull/8131#discussion_r2281050679
##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -187,18 +189,34 @@ public Response listTagsForMetadataObject(
parentObject = MetadataObjects.parent(parentObject);
}
+ // Deduplicate by tag name, prefer direct(inherited==false) over
inherited(true)
+ Map<String, TagDTO> byName = new LinkedHashMap<>();
+ for (TagDTO t : tags) {
+ TagDTO prev = byName.get(t.name());
+ if (prev == null) {
+ byName.put(t.name(), t);
+ } else {
+ boolean prevDirect = !prev.inherited().orElse(false);
+ boolean currDirect = !t.inherited().orElse(false);
+ if (!prevDirect && currDirect) {
+ byName.put(t.name(), t);
+ }
+ }
+ }
+
Review Comment:
There may be a simplified way to do this. e.g. Add all direct tags, then add
any inherited tags that have not all been added.
--
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]