[ 
https://issues.apache.org/jira/browse/HADOOP-19254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17904591#comment-17904591
 ] 

ASF GitHub Bot commented on HADOOP-19254:
-----------------------------------------

HarshitGupta11 commented on code in PR #7197:
URL: https://github.com/apache/hadoop/pull/7197#discussion_r1878512626


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/BulkDeleteCommand.java:
##########
@@ -73,12 +105,40 @@ protected void processArguments(LinkedList<PathData> args) 
throws IOException {
             BufferedReader br = new BufferedReader(new 
InputStreamReader(localFile.open(new Path(fileName))));
             String line;
             while((line = br.readLine()) != null) {
-                pathList.add(new Path(line));
+                if(!line.startsWith("#")) {
+                    pathList.add(new Path(line));
+                }
             }
         } else {
             
pathList.addAll(this.childArgs.stream().map(Path::new).collect(Collectors.toList()));
         }
         BulkDelete bulkDelete = basePath.fs.createBulkDelete(basePath.path);
-        bulkDelete.bulkDelete(pathList);
+        deleteInBatches(bulkDelete, pathList);
+    }
+
+    static class Batch<T> {

Review Comment:
   Done



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/BulkDeleteCommand.java:
##########
@@ -73,12 +105,40 @@ protected void processArguments(LinkedList<PathData> args) 
throws IOException {
             BufferedReader br = new BufferedReader(new 
InputStreamReader(localFile.open(new Path(fileName))));
             String line;
             while((line = br.readLine()) != null) {
-                pathList.add(new Path(line));
+                if(!line.startsWith("#")) {
+                    pathList.add(new Path(line));
+                }
             }
         } else {
             
pathList.addAll(this.childArgs.stream().map(Path::new).collect(Collectors.toList()));
         }
         BulkDelete bulkDelete = basePath.fs.createBulkDelete(basePath.path);
-        bulkDelete.bulkDelete(pathList);
+        deleteInBatches(bulkDelete, pathList);
+    }
+
+    static class Batch<T> {
+        List<T> data;
+        int batchSize;
+        int currentLocation;
+
+        Batch(List<T> data, int batchSize) {
+            this.data = Collections.unmodifiableList(data);
+            this.batchSize = batchSize;
+            this.currentLocation = 0;
+        }
+
+        boolean hasNext() {
+            return this.currentLocation < this.data.size();
+        }
+
+        List<T> next() {
+            List<T> ret = new ArrayList<>();
+            int i = currentLocation;
+            for(; i < Math.min(currentLocation + batchSize, data.size()); i++) 
{

Review Comment:
   Made the change





> Implement bulk delete command as hadoop fs command operation 
> -------------------------------------------------------------
>
>                 Key: HADOOP-19254
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19254
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: fs
>    Affects Versions: 3.4.1
>            Reporter: Mukund Thakur
>            Assignee: Harshit Gupta
>            Priority: Major
>              Labels: pull-request-available
>
> {code}
> hadoop fs -bulkdelete <base-url> <file> 
> {code}
> Key uses
> * QE: Testing from python and other scripting languages
> * cluster maintenance: actual bulk deletion operations from the store
> one thought there: we MUST qualify paths with / elements: if a passed in path 
> ends in /, it means "delete a marker", not "delete a dir"'. and if it doesn't 
> have one then it's an object.. This makes it possible to be used to delete 
> surplus markers or where there is a file above another file...cloudstore 
> listobjects finds this



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to