ayushtkn commented on code in PR #5582:
URL: https://github.com/apache/hadoop/pull/5582#discussion_r1174509467


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java:
##########
@@ -262,13 +262,24 @@ private static DirectoryListing getListing(FSDirectory 
fsd, INodesInPath iip,
             needLocation, false);
         listingCnt++;
         if (listing[i] instanceof HdfsLocatedFileStatus) {
-            // Once we  hit lsLimit locations, stop.
+            // Once we hit lsLimit locations, stop.
             // This helps to prevent excessively large response payloads.
-            // Approximate #locations with locatedBlockCount() * repl_factor
             LocatedBlocks blks =
                 ((HdfsLocatedFileStatus)listing[i]).getLocatedBlocks();
-            locationBudget -= (blks == null) ? 0 :
-               blks.locatedBlockCount() * listing[i].getReplication();
+            if (blks != null) {
+              ErasureCodingPolicy ecPolicy =
+                  listing[i].getErasureCodingPolicy();
+              if (ecPolicy != null && !ecPolicy.isReplicationPolicy()) {
+                // Approximate #locations with locatedBlockCount() *
+                // internalBlocksNum.
+                locationBudget -= blks.locatedBlockCount() *
+                    (ecPolicy.getNumDataUnits() + 
ecPolicy.getNumParityUnits());
+              } else {
+                // Approximate #locations with locatedBlockCount() * 
repl_factor

Review Comment:
   Should be fine, good to change and use replicationFactor in the comment as 
you suggested 



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


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

Reply via email to