smengcl commented on a change in pull request #1286:
URL: https://github.com/apache/hadoop-ozone/pull/1286#discussion_r468181796



##########
File path: 
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
##########
@@ -457,45 +463,83 @@ public boolean deleteObject(String path) {
     }
   }
 
+  /**
+   * Helper function to check if the list of key paths are in the same volume
+   * and same bucket.
+   */
+  private boolean areInSameBucket(List<String> keyNameList) {
+    if (keyNameList.size() == 0) {
+      return true;
+    }
+    String firstKeyPath = keyNameList.get(0);
+    final String volAndBucket = new OFSPath(firstKeyPath).getNonKeyPath();
+    // If any key path's volume and bucket from the second element and on
+    // in the list doesn't match the first element's, hasDifferentVolAndBucket
+    // would be true
+    boolean hasDifferentVolAndBucket = keyNameList.stream().skip(1)
+        .anyMatch(p -> !(new OFSPath(p).getNonKeyPath().equals(volAndBucket)));
+    return !hasDifferentVolAndBucket;

Review comment:
       Good catch!




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to