GitHub user liancheng opened a pull request:

    https://github.com/apache/spark/pull/12527

    [SPARK-14369][SQL] Locality support for FileScanRDD

    (This PR is a rebased version of PR #12153.)
    
    ## What changes were proposed in this pull request?
    
    This PR adds preliminary locality support for `FileFormat` data sources by 
overriding `FileScanRDD.preferredLocations()`. The strategy can be divided into 
two parts:
    
    1.  Block location lookup
    
        Unlike `HadoopRDD` or `NewHadoopRDD`, `FileScanRDD` doesn't have access 
to the underlying `InputFormat` or `InputSplit`, and thus can't rely on 
`InputSplit.getLocations()` to gather locality information. Instead, this PR 
queries block locations using `FileSystem.getBlockLocations()` after listing 
all `FileStatus`es in `HDFSFileCatalog` and convert all `FileStatus`es into 
`LocatedFileStatus`es.
    
        Note that although S3/S3A/S3N file systems don't provide valid locality 
information, their `getLocatedStatus()` implementations don't actually issue 
remote calls either. So there's no need to special case these file systems.
    
    2.  Selecting preferred locations
    
        For each `FilePartition`, we pick up top 3 locations that containing 
the most data to be retrieved. This isn't necessarily the best algorithm out 
there. Further improvements may be brought up in follow-up PRs.
    
    ## How was this patch tested?
    
    Tested by overriding default `FileSystem` implementation for `file:///` 
with a mocked one, which returns mocked block locations.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/liancheng/spark spark-14369-locality-rebased

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12527.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12527
    
----
commit 0358e33c1a796b7875f932c4d4aee28db505f696
Author: Cheng Lian <l...@databricks.com>
Date:   2016-04-20T13:25:51Z

    Rebased PR #12153

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to