{"action":"created","comment":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/24628797","id":24628797,"diff_hunk":"@@ -24,7 +24,13 @@\n public class AvroUtils {\n     /** Returns a Schema RDD for the given avro path. */\n     public static JavaSchemaRDD avroFile(JavaSQLContext sqlContext, String path) {\n-        AvroRelation relation = new AvroRelation(path, sqlContext.sqlContext());\n+        AvroRelation relation = new AvroRelation(path, 0, sqlContext.sqlContext());\n+        return sqlContext.baseRelationToSchemaRDD(relation);","path":"src/main/java/com/databricks/spark/avro/AvroUtils.java","position":6,"original_position":6,"commit_id":"5e5394689c01ea6d93981f53a02ba6cadb6b735a","original_commit_id":"5e5394689c01ea6d93981f53a02ba6cadb6b735a","user":{"login":"vlyubin","id":3303322,"avatar_url":"https://avatars.githubusercontent.com/u/3303322?v=3","gravatar_id":"","url":"https://api.github.com/users/vlyubin","html_url":"https://github.com/vlyubin","followers_url":"https://api.github.com/users/vlyubin/followers","following_url":"https://api.github.com/users/vlyubin/following{/other_user}","gists_url":"https://api.github.com/users/vlyubin/gists{/gist_id}","starred_url":"https://api.github.com/users/vlyubin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlyubin/subscriptions","organizations_url":"https://api.github.com/users/vlyubin/orgs","repos_url":"https://api.github.com/users/vlyubin/repos","events_url":"https://api.github.com/users/vlyubin/events{/privacy}","received_events_url":"https://api.github.com/users/vlyubin/received_events","type":"User","site_admin":false},"body":"Maybe just use `return AvroUtils.avroFile (sqlContext, path, 0);` to avoid duplication.","created_at":"2015-02-12T22:50:13Z","updated_at":"2015-02-12T22:50:13Z","html_url":"https://github.com/databricks/spark-avro/pull/28#discussion_r24628797","pull_request_url":"https://api.github.com/repos/databricks/spark-avro/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/24628797"},"html":{"href":"https://github.com/databricks/spark-avro/pull/28#discussion_r24628797"},"pull_request":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/28","id":28944569,"html_url":"https://github.com/databricks/spark-avro/pull/28","diff_url":"https://github.com/databricks/spark-avro/pull/28.diff","patch_url":"https://github.com/databricks/spark-avro/pull/28.patch","issue_url":"https://api.github.com/repos/databricks/spark-avro/issues/28","number":28,"state":"open","locked":false,"title":"Make avroFile reader has the option of choosing a partition number instead of using the default one","user":{"login":"timyitong","id":1464240,"avatar_url":"https://avatars.githubusercontent.com/u/1464240?v=3","gravatar_id":"","url":"https://api.github.com/users/timyitong","html_url":"https://github.com/timyitong","followers_url":"https://api.github.com/users/timyitong/followers","following_url":"https://api.github.com/users/timyitong/following{/other_user}","gists_url":"https://api.github.com/users/timyitong/gists{/gist_id}","starred_url":"https://api.github.com/users/timyitong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timyitong/subscriptions","organizations_url":"https://api.github.com/users/timyitong/orgs","repos_url":"https://api.github.com/users/timyitong/repos","events_url":"https://api.github.com/users/timyitong/events{/privacy}","received_events_url":"https://api.github.com/users/timyitong/received_events","type":"User","site_admin":false},"body":"I hesitate a bit in which pattern to use for adding the option:\r\n```\r\n// Use Option\r\nAvroRelation(location: String, minPartitions: Option[Int] = None)\r\n\r\n// Just use a default value\r\nAvroRelation(location: String, minPartitions: Int = 0)\r\n```\r\n\r\nI choose the latter one because we also have Java codes calling AvroRelation, and I feel it a less elegant to import scala None,Option classes into java codes to make it compile. Please suggest whether this choice makes sense.\r\n\r\nI tested my change with an added unit tests and also in a Spark 1.2 shell where I was reading larger number of partitions of files in HDFS. The set-ups seem to be working but the final partitions number won't equal to the exact value of the parameter, but something a bit larger. For example, when I am reading 22 partitioned files, and choose the minPartitions to be 120. The final partitions size I get won't be 120, but will be k*22 where k is an integer making 22k just larger than 120 (in this example, k=6). I think this is expected as it behaves the same in Hadoop. But our unit tests only test one partition case, should I add a folder of small partitioned files and test this case? ","created_at":"2015-02-09T18:31:00Z","updated_at":"2015-02-12T22:50:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ebe206fa4b8106e8e3b8fbb82b9f1fa00a01b7a4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/databricks/spark-avro/pulls/28/commits","review_comments_url":"https://api.github.com/repos/databricks/spark-avro/pulls/28/comments","review_comment_url":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/{number}","comments_url":"https://api.github.com/repos/databricks/spark-avro/issues/28/comments","statuses_url":"https://api.github.com/repos/databricks/spark-avro/statuses/5e5394689c01ea6d93981f53a02ba6cadb6b735a","head":{"label":"timyitong:master","ref":"master","sha":"5e5394689c01ea6d93981f53a02ba6cadb6b735a","user":{"login":"timyitong","id":1464240,"avatar_url":"https://avatars.githubusercontent.com/u/1464240?v=3","gravatar_id":"","url":"https://api.github.com/users/timyitong","html_url":"https://github.com/timyitong","followers_url":"https://api.github.com/users/timyitong/followers","following_url":"https://api.github.com/users/timyitong/following{/other_user}","gists_url":"https://api.github.com/users/timyitong/gists{/gist_id}","starred_url":"https://api.github.com/users/timyitong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timyitong/subscriptions","organizations_url":"https://api.github.com/users/timyitong/orgs","repos_url":"https://api.github.com/users/timyitong/repos","events_url":"https://api.github.com/users/timyitong/events{/privacy}","received_events_url":"https://api.github.com/users/timyitong/received_events","type":"User","site_admin":false},"repo":{"id":29207292,"name":"spark-avro","full_name":"timyitong/spark-avro","owner":{"login":"timyitong","id":1464240,"avatar_url":"https://avatars.githubusercontent.com/u/1464240?v=3","gravatar_id":"","url":"https://api.github.com/users/timyitong","html_url":"https://github.com/timyitong","followers_url":"https://api.github.com/users/timyitong/followers","following_url":"https://api.github.com/users/timyitong/following{/other_user}","gists_url":"https://api.github.com/users/timyitong/gists{/gist_id}","starred_url":"https://api.github.com/users/timyitong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timyitong/subscriptions","organizations_url":"https://api.github.com/users/timyitong/orgs","repos_url":"https://api.github.com/users/timyitong/repos","events_url":"https://api.github.com/users/timyitong/events{/privacy}","received_events_url":"https://api.github.com/users/timyitong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timyitong/spark-avro","description":"Integration utilities for using Spark with Apache Avro data","fork":true,"url":"https://api.github.com/repos/timyitong/spark-avro","forks_url":"https://api.github.com/repos/timyitong/spark-avro/forks","keys_url":"https://api.github.com/repos/timyitong/spark-avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timyitong/spark-avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timyitong/spark-avro/teams","hooks_url":"https://api.github.com/repos/timyitong/spark-avro/hooks","issue_events_url":"https://api.github.com/repos/timyitong/spark-avro/issues/events{/number}","events_url":"https://api.github.com/repos/timyitong/spark-avro/events","assignees_url":"https://api.github.com/repos/timyitong/spark-avro/assignees{/user}","branches_url":"https://api.github.com/repos/timyitong/spark-avro/branches{/branch}","tags_url":"https://api.github.com/repos/timyitong/spark-avro/tags","blobs_url":"https://api.github.com/repos/timyitong/spark-avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timyitong/spark-avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timyitong/spark-avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/timyitong/spark-avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timyitong/spark-avro/statuses/{sha}","languages_url":"https://api.github.com/repos/timyitong/spark-avro/languages","stargazers_url":"https://api.github.com/repos/timyitong/spark-avro/stargazers","contributors_url":"https://api.github.com/repos/timyitong/spark-avro/contributors","subscribers_url":"https://api.github.com/repos/timyitong/spark-avro/subscribers","subscription_url":"https://api.github.com/repos/timyitong/spark-avro/subscription","commits_url":"https://api.github.com/repos/timyitong/spark-avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/timyitong/spark-avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/timyitong/spark-avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/timyitong/spark-avro/issues/comments/{number}","contents_url":"https://api.github.com/repos/timyitong/spark-avro/contents/{+path}","compare_url":"https://api.github.com/repos/timyitong/spark-avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timyitong/spark-avro/merges","archive_url":"https://api.github.com/repos/timyitong/spark-avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timyitong/spark-avro/downloads","issues_url":"https://api.github.com/repos/timyitong/spark-avro/issues{/number}","pulls_url":"https://api.github.com/repos/timyitong/spark-avro/pulls{/number}","milestones_url":"https://api.github.com/repos/timyitong/spark-avro/milestones{/number}","notifications_url":"https://api.github.com/repos/timyitong/spark-avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timyitong/spark-avro/labels{/name}","releases_url":"https://api.github.com/repos/timyitong/spark-avro/releases{/id}","created_at":"2015-01-13T19:37:25Z","updated_at":"2015-02-09T19:26:33Z","pushed_at":"2015-02-09T19:26:33Z","git_url":"git://github.com/timyitong/spark-avro.git","ssh_url":"git@github.com:timyitong/spark-avro.git","clone_url":"https://github.com/timyitong/spark-avro.git","svn_url":"https://github.com/timyitong/spark-avro","homepage":null,"size":248,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"databricks:master","ref":"master","sha":"3558c02e5b527c2e248d983a403b02454e6ab44e","user":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"repo":{"id":24648767,"name":"spark-avro","full_name":"databricks/spark-avro","owner":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/databricks/spark-avro","description":"Integration utilities for using Spark with Apache Avro data","fork":false,"url":"https://api.github.com/repos/databricks/spark-avro","forks_url":"https://api.github.com/repos/databricks/spark-avro/forks","keys_url":"https://api.github.com/repos/databricks/spark-avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/databricks/spark-avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/databricks/spark-avro/teams","hooks_url":"https://api.github.com/repos/databricks/spark-avro/hooks","issue_events_url":"https://api.github.com/repos/databricks/spark-avro/issues/events{/number}","events_url":"https://api.github.com/repos/databricks/spark-avro/events","assignees_url":"https://api.github.com/repos/databricks/spark-avro/assignees{/user}","branches_url":"https://api.github.com/repos/databricks/spark-avro/branches{/branch}","tags_url":"https://api.github.com/repos/databricks/spark-avro/tags","blobs_url":"https://api.github.com/repos/databricks/spark-avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/databricks/spark-avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/databricks/spark-avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/databricks/spark-avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/databricks/spark-avro/statuses/{sha}","languages_url":"https://api.github.com/repos/databricks/spark-avro/languages","stargazers_url":"https://api.github.com/repos/databricks/spark-avro/stargazers","contributors_url":"https://api.github.com/repos/databricks/spark-avro/contributors","subscribers_url":"https://api.github.com/repos/databricks/spark-avro/subscribers","subscription_url":"https://api.github.com/repos/databricks/spark-avro/subscription","commits_url":"https://api.github.com/repos/databricks/spark-avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/databricks/spark-avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/databricks/spark-avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/databricks/spark-avro/issues/comments/{number}","contents_url":"https://api.github.com/repos/databricks/spark-avro/contents/{+path}","compare_url":"https://api.github.com/repos/databricks/spark-avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/databricks/spark-avro/merges","archive_url":"https://api.github.com/repos/databricks/spark-avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/databricks/spark-avro/downloads","issues_url":"https://api.github.com/repos/databricks/spark-avro/issues{/number}","pulls_url":"https://api.github.com/repos/databricks/spark-avro/pulls{/number}","milestones_url":"https://api.github.com/repos/databricks/spark-avro/milestones{/number}","notifications_url":"https://api.github.com/repos/databricks/spark-avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/databricks/spark-avro/labels{/name}","releases_url":"https://api.github.com/repos/databricks/spark-avro/releases{/id}","created_at":"2014-09-30T17:50:58Z","updated_at":"2015-02-12T21:14:53Z","pushed_at":"2015-02-11T19:38:06Z","git_url":"git://github.com/databricks/spark-avro.git","ssh_url":"git@github.com:databricks/spark-avro.git","clone_url":"https://github.com/databricks/spark-avro.git","svn_url":"https://github.com/databricks/spark-avro","homepage":null,"size":651,"stargazers_count":34,"watchers_count":34,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":4,"forks":23,"open_issues":4,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/28"},"html":{"href":"https://github.com/databricks/spark-avro/pull/28"},"issue":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/28"},"comments":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/databricks/spark-avro/statuses/5e5394689c01ea6d93981f53a02ba6cadb6b735a"}}}}