{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/55413797","id":55413797,"diff_hunk":"@@ -351,7 +351,16 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {\n   def getAppId: String = get(\"spark.app.id\")\n \n   /** Does the configuration contain a given parameter? */\n-  def contains(key: String): Boolean = settings.containsKey(key)\n+  def contains(key: String): Boolean = {\n+    if (settings.containsKey(key)) {\n+      true\n+    } else {\n+      // try to find the settings in the alternatives\n+      configsWithAlternatives.get(key).flatMap { alts =>\n+        alts.collectFirst { case alt if contains(alt.key) => true }\n+      }.isDefined","path":"core/src/main/scala/org/apache/spark/SparkConf.scala","position":null,"original_position":12,"commit_id":"0243d326461406ff02ff8218af725eb7179b357d","original_commit_id":"91333f9b1c267a41b71b843b40ebaefc5e60e215","user":{"login":"bomeng","id":295781,"avatar_url":"https://avatars.githubusercontent.com/u/295781?v=3","gravatar_id":"","url":"https://api.github.com/users/bomeng","html_url":"https://github.com/bomeng","followers_url":"https://api.github.com/users/bomeng/followers","following_url":"https://api.github.com/users/bomeng/following{/other_user}","gists_url":"https://api.github.com/users/bomeng/gists{/gist_id}","starred_url":"https://api.github.com/users/bomeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bomeng/subscriptions","organizations_url":"https://api.github.com/users/bomeng/orgs","repos_url":"https://api.github.com/users/bomeng/repos","events_url":"https://api.github.com/users/bomeng/events{/privacy}","received_events_url":"https://api.github.com/users/bomeng/received_events","type":"User","site_admin":false},"body":"1. It will find the alternatives using the key: configsWithAlternatives.get(key), it will return an Option of Seq, since alternative could be multiple;\r\n2. It will then try to use the key of each alternative to see if it is already defined in the conf, here contains(alt.key) is a recursive call;\r\n3. collectFirst will just get the first matching\r\n4. the final step isDefined() is to see whether we find such a match or not. \r\nRemember configsWithAlternatives.get(\"one\") returns Option of Seq[], any suggestion to simplify?  ","created_at":"2016-03-08T19:32:07Z","updated_at":"2016-03-08T19:32:07Z","html_url":"https://github.com/apache/spark/pull/11568#discussion_r55413797","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/11568","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/55413797"},"html":{"href":"https://github.com/apache/spark/pull/11568#discussion_r55413797"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/11568"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11568","id":62006079,"html_url":"https://github.com/apache/spark/pull/11568","diff_url":"https://github.com/apache/spark/pull/11568.diff","patch_url":"https://github.com/apache/spark/pull/11568.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/11568","number":11568,"state":"open","locked":false,"title":"[SPARK-13727] [SQL] SparkConf.contains does not consider deprecated keys","user":{"login":"bomeng","id":295781,"avatar_url":"https://avatars.githubusercontent.com/u/295781?v=3","gravatar_id":"","url":"https://api.github.com/users/bomeng","html_url":"https://github.com/bomeng","followers_url":"https://api.github.com/users/bomeng/followers","following_url":"https://api.github.com/users/bomeng/following{/other_user}","gists_url":"https://api.github.com/users/bomeng/gists{/gist_id}","starred_url":"https://api.github.com/users/bomeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bomeng/subscriptions","organizations_url":"https://api.github.com/users/bomeng/orgs","repos_url":"https://api.github.com/users/bomeng/repos","events_url":"https://api.github.com/users/bomeng/events{/privacy}","received_events_url":"https://api.github.com/users/bomeng/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\nThe contains() method does not return consistently with get() if the key is deprecated. For example,\r\nimport org.apache.spark.SparkConf\r\nval conf = new SparkConf()\r\nconf.set(\"spark.io.compression.lz4.block.size\", \"12345\")  # display some deprecated warning message \r\nconf.get(\"spark.io.compression.lz4.block.size\") # return 12345\r\nconf.get(\"spark.io.compression.lz4.blockSize\") # return 12345\r\nconf.contains(\"spark.io.compression.lz4.block.size\") # return true\r\nconf.contains(\"spark.io.compression.lz4.blockSize\") # return false\r\n\r\nThe fix will make the contains() and get() more consistent.\r\n\r\n## How was this patch tested?\r\nI've added a test case for this.\r\n\r\n(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)\r\nUnit tests should be sufficient.\r\n","created_at":"2016-03-08T00:36:48Z","updated_at":"2016-03-08T19:32:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c7dd841e42ea7ede5258970f708b66a46124fb8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/11568/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/11568/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/11568/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/0243d326461406ff02ff8218af725eb7179b357d","head":{"label":"bomeng:SPARK-13727","ref":"SPARK-13727","sha":"0243d326461406ff02ff8218af725eb7179b357d","user":{"login":"bomeng","id":295781,"avatar_url":"https://avatars.githubusercontent.com/u/295781?v=3","gravatar_id":"","url":"https://api.github.com/users/bomeng","html_url":"https://github.com/bomeng","followers_url":"https://api.github.com/users/bomeng/followers","following_url":"https://api.github.com/users/bomeng/following{/other_user}","gists_url":"https://api.github.com/users/bomeng/gists{/gist_id}","starred_url":"https://api.github.com/users/bomeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bomeng/subscriptions","organizations_url":"https://api.github.com/users/bomeng/orgs","repos_url":"https://api.github.com/users/bomeng/repos","events_url":"https://api.github.com/users/bomeng/events{/privacy}","received_events_url":"https://api.github.com/users/bomeng/received_events","type":"User","site_admin":false},"repo":{"id":47588044,"name":"spark","full_name":"bomeng/spark","owner":{"login":"bomeng","id":295781,"avatar_url":"https://avatars.githubusercontent.com/u/295781?v=3","gravatar_id":"","url":"https://api.github.com/users/bomeng","html_url":"https://github.com/bomeng","followers_url":"https://api.github.com/users/bomeng/followers","following_url":"https://api.github.com/users/bomeng/following{/other_user}","gists_url":"https://api.github.com/users/bomeng/gists{/gist_id}","starred_url":"https://api.github.com/users/bomeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bomeng/subscriptions","organizations_url":"https://api.github.com/users/bomeng/orgs","repos_url":"https://api.github.com/users/bomeng/repos","events_url":"https://api.github.com/users/bomeng/events{/privacy}","received_events_url":"https://api.github.com/users/bomeng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bomeng/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/bomeng/spark","forks_url":"https://api.github.com/repos/bomeng/spark/forks","keys_url":"https://api.github.com/repos/bomeng/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bomeng/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bomeng/spark/teams","hooks_url":"https://api.github.com/repos/bomeng/spark/hooks","issue_events_url":"https://api.github.com/repos/bomeng/spark/issues/events{/number}","events_url":"https://api.github.com/repos/bomeng/spark/events","assignees_url":"https://api.github.com/repos/bomeng/spark/assignees{/user}","branches_url":"https://api.github.com/repos/bomeng/spark/branches{/branch}","tags_url":"https://api.github.com/repos/bomeng/spark/tags","blobs_url":"https://api.github.com/repos/bomeng/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bomeng/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bomeng/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/bomeng/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bomeng/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/bomeng/spark/languages","stargazers_url":"https://api.github.com/repos/bomeng/spark/stargazers","contributors_url":"https://api.github.com/repos/bomeng/spark/contributors","subscribers_url":"https://api.github.com/repos/bomeng/spark/subscribers","subscription_url":"https://api.github.com/repos/bomeng/spark/subscription","commits_url":"https://api.github.com/repos/bomeng/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/bomeng/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/bomeng/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/bomeng/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/bomeng/spark/contents/{+path}","compare_url":"https://api.github.com/repos/bomeng/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bomeng/spark/merges","archive_url":"https://api.github.com/repos/bomeng/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bomeng/spark/downloads","issues_url":"https://api.github.com/repos/bomeng/spark/issues{/number}","pulls_url":"https://api.github.com/repos/bomeng/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/bomeng/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/bomeng/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bomeng/spark/labels{/name}","releases_url":"https://api.github.com/repos/bomeng/spark/releases{/id}","deployments_url":"https://api.github.com/repos/bomeng/spark/deployments","created_at":"2015-12-08T00:27:00Z","updated_at":"2016-01-14T22:59:24Z","pushed_at":"2016-03-08T18:55:40Z","git_url":"git://github.com/bomeng/spark.git","ssh_url":"git@github.com:bomeng/spark.git","clone_url":"https://github.com/bomeng/spark.git","svn_url":"https://github.com/bomeng/spark","homepage":null,"size":153545,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"46f25c241385fe4f1fff42ac4a1b6e652deb2d02","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-03-08T12:55:38Z","pushed_at":"2016-03-08T19:27:35Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":443085,"stargazers_count":7718,"watchers_count":7718,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7034,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":401,"forks":7034,"open_issues":401,"watchers":7718,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/11568"},"html":{"href":"https://github.com/apache/spark/pull/11568"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/11568"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/11568/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/11568/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/11568/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/0243d326461406ff02ff8218af725eb7179b357d"}}}}