yuqi1129 commented on code in PR #7476:
URL: https://github.com/apache/gravitino/pull/7476#discussion_r2212066881


##########
core/src/main/java/org/apache/gravitino/tag/TagManager.java:
##########
@@ -226,6 +227,41 @@ public MetadataObject[] listMetadataObjectsForTag(String 
metalake, String name)
         });
   }
 
+  public MetadataObject[] listMetadataObjectsForTags(String metalake, String[] 
names)
+      throws NoSuchTagException {
+    if (names == null || names.length == 0) {
+      return new MetadataObject[0];
+    }
+    NameIdentifier[] tagIds =
+        Arrays.stream(names)
+            .map(name -> NameIdentifierUtil.ofTag(metalake, name))
+            .toArray(NameIdentifier[]::new);
+    return TreeLockUtils.doWithTreeLock(
+        NameIdentifier.of(metalake),

Review Comment:
   Why do we need to lock the entire metalake? I believe we only need to lock 
the parent of tag, please refer to `listMetadataObjectsForTag`



##########
server/src/main/java/org/apache/gravitino/server/web/rest/TagOperations.java:
##########
@@ -248,6 +248,50 @@ public Response listMetadataObjectsForTag(
     }
   }
 
+  private String[] parseTagsParameter(String tagsParam) {
+    if (tagsParam == null || tagsParam.trim().isEmpty()) {
+      throw new IllegalArgumentException("Tags parameter cannot be null or 
empty");
+    }
+
+    return Arrays.stream(tagsParam.split(","))
+        .map(String::trim)
+        .filter(tag -> !tag.isEmpty())
+        .toArray(String[]::new);
+  }
+
+  @GET
+  @Path("objects")
+  @Produces("application/vnd.gravitino.v1+json")
+  @Timed(name = "list-objects-for-tags." + MetricNames.HTTP_PROCESS_DURATION, 
absolute = true)
+  @ResponseMetered(name = "list-objects-for-tags", absolute = true)
+  public Response listMetadataObjectsForTags(
+      @PathParam("metalake") String metalake, @QueryParam("tags") String 
tagsParam) {
+    LOG.info("Received list objects for tags: {} under metalake: {}", 
tagsParam, metalake);
+
+    try {
+      return Utils.doAs(
+          httpRequest,
+          () -> {
+            String[] tagNames = parseTagsParameter(tagsParam);
+
+            MetadataObject[] objects = 
tagDispatcher.listMetadataObjectsForTags(metalake, tagNames);
+            objects = objects == null ? new MetadataObject[0] : objects;

Review Comment:
   When will `objects` be null?  I suggest you add the check in 
`listMetadataObjectsForTags` instead of putting it here.



-- 
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]

Reply via email to