You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/26 05:33:26 UTC

[GitHub] [spark] melin commented on issue #24672: [SPARK-27801][SQL] Improve performance of InMemoryFileIndex.listLeafFiles for HDFS directories with many files

melin commented on issue #24672: [SPARK-27801][SQL] Improve performance of InMemoryFileIndex.listLeafFiles for HDFS directories with many files
URL: https://github.com/apache/spark/pull/24672#issuecomment-495970900
 
 
   ```
   @RequestMapping(value = "v1/hdfsPref", produces = "text/plain;charset=UTF-8")
       @ResponseBody
       public String hdfsPref(String path) throws Exception {
           DataCenter dataCenter = new DataCenter("hangzhou", "杭州");
           UserGroupInformation userGroupInformation = confLoader.loginUserFromKeytab(dataCenter);
           return userGroupInformation.doAs(new PrivilegedExceptionAction<String>() {
   
               @Override
               public String run() throws Exception {
                   FileSystem fileSystem = confLoader.getFileSystem(dataCenter);
                   org.apache.hadoop.fs.Path filePath = new org.apache.hadoop.fs.Path(path);
   
                   Stopwatch stopwatch = Stopwatch.createStarted();
                   FileStatus[] fileStatuses = fileSystem.listStatus(filePath);
                   stopwatch.stop();
                   String msg = "listStatus: " + fileStatuses.length + ", times: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms";
   
                   stopwatch.reset().start();
                   RemoteIterator<LocatedFileStatus> remoteIter = fileSystem.listLocatedStatus(filePath);
                   List<LocatedFileStatus> myList = Lists.newArrayList();
                   while (remoteIter.hasNext()) {
                       myList.add(remoteIter.next());
                   }
   
                   stopwatch.stop();
                   msg += "\nlistLocatedStatus: " + myList.size() + ", times: " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms";
   
                   return msg;
               }
           });
       }
   
   test data:
   listStatus: 8001, times: 114ms
   listLocatedStatus: 8001, times: 807ms
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org