[
https://issues.apache.org/jira/browse/HADOOP-19543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945244#comment-17945244
]
ASF GitHub Bot commented on HADOOP-19543:
-----------------------------------------
anmolanmol1234 commented on code in PR #7614:
URL: https://github.com/apache/hadoop/pull/7614#discussion_r2048310464
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/ListUtils.java:
##########
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs.azurebfs.utils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeMap;
+
+import org.apache.hadoop.fs.FileStatus;
+
+public class ListUtils {
+
+ public static List<FileStatus> getUniqueListResult(List<FileStatus>
originalList) {
Review Comment:
Logic looks a bit complex to read, can be refactored. One possible solution
could be
public static List<FileStatus> getUniqueListResult(List<FileStatus>
originalList) {
if (originalList == null || originalList.isEmpty()) {
return originalList;
}
List<FileStatus> uniqueList = new ArrayList<>();
TreeMap<String, FileStatus> currentGroupMap = new TreeMap<>();
String currentPrefix = null;
for (FileStatus fileStatus : originalList) {
String fileName = fileStatus.getPath().getName();
if (currentPrefix == null || !fileName.startsWith(currentPrefix)) {
// Start of a new group
currentPrefix = fileName;
currentGroupMap.clear();
}
if (!currentGroupMap.containsKey(fileName)) {
currentGroupMap.put(fileName, fileStatus);
uniqueList.add(fileStatus);
}
}
return uniqueList;
}
> ABFS: [FnsOverBlob] Remove Duplicates from Blob Endpoint Listing Across
> Iterations
> ----------------------------------------------------------------------------------
>
> Key: HADOOP-19543
> URL: https://issues.apache.org/jira/browse/HADOOP-19543
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs/azure
> Affects Versions: 3.5.0, 3.4.1
> Reporter: Anuj Modi
> Assignee: Anuj Modi
> Priority: Blocker
> Labels: pull-request-available
>
> On FNS-Blob, List Blobs API is known to return duplicate entries for the
> non-empty explicit directories. One entry corresponds to the directory itself
> and another entry corresponding to the marker blob that driver internally
> creates and maintains to mark that path as a directory. We already know about
> this behaviour and it was handled to remove such duplicate entries from the
> set of entries that were returned as part current list iterations.
> Due to possible partition split if such duplicate entries happen to be
> returned in separate iteration, there is no handling on this and caller might
> get back the result with duplicate entries as happening in this case. The
> logic to remove duplicate was designed before the realization of partition
> split came.
> This PR fixes this bug
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]