{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/12527","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/12527/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/12527/comments","events_url":"https://api.github.com/repos/apache/spark/issues/12527/events","html_url":"https://github.com/apache/spark/pull/12527","id":149767917,"number":12527,"title":"[SPARK-14369][SQL] Locality support for FileScanRDD","user":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-04-20T13:29:11Z","updated_at":"2016-04-22T02:32:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12527","html_url":"https://github.com/apache/spark/pull/12527","diff_url":"https://github.com/apache/spark/pull/12527.diff","patch_url":"https://github.com/apache/spark/pull/12527.patch"},"body":"(This PR is a rebased version of PR #12153.)\r\n\r\n## What changes were proposed in this pull request?\r\n\r\nThis PR adds preliminary locality support for `FileFormat` data sources by overriding `FileScanRDD.preferredLocations()`. The strategy can be divided into two parts:\r\n\r\n1.  Block location lookup\r\n\r\n    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.\r\n\r\n    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.\r\n\r\n2.  Selecting preferred locations\r\n\r\n    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.\r\n\r\n## How was this patch tested?\r\n\r\nTested by overriding default `FileSystem` implementation for `file:///` with a mocked one, which returns mocked block locations."},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/213214154","html_url":"https://github.com/apache/spark/pull/12527#issuecomment-213214154","issue_url":"https://api.github.com/repos/apache/spark/issues/12527","id":213214154,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T02:32:08Z","updated_at":"2016-04-22T02:32:08Z","body":"Test PASSed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/56615/\nTest PASSed."}}