{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/24188162","id":24188162,"diff_hunk":"@@ -23,15 +23,27 @@ import org.apache.spark.api.python.Converter\n import org.apache.hadoop.hbase.client.{Put, Result}\n import org.apache.hadoop.hbase.io.ImmutableBytesWritable\n import org.apache.hadoop.hbase.util.Bytes\n+import org.apache.hadoop.hbase.KeyValue.Type\n+import org.apache.hadoop.hbase.CellUtil\n \n /**\n- * Implementation of [[org.apache.spark.api.python.Converter]] that converts an\n- * HBase Result to a String\n+ * Implementation of [[org.apache.spark.api.python.Converter]] that converts all\n+ * the records in an HBase Result to a String\n  */\n class HBaseResultToStringConverter extends Converter[Any, String] {\n   override def convert(obj: Any): String = {\n+    import collection.JavaConverters._\n     val result = obj.asInstanceOf[Result]\n-    Bytes.toStringBinary(result.value())\n+    val output = result.listCells.asScala.map(cell =>\n+        \"{'columnFamily':'%s','qualifier':'%s','timestamp':'%s','type':'%s','value':'%s'}\".format(","path":"examples/src/main/scala/org/apache/spark/examples/pythonconverters/HBaseConverters.scala","position":19,"original_position":19,"commit_id":"15b1fe33caf1c2524afed7be6e99a903dfebb356","original_commit_id":"15b1fe33caf1c2524afed7be6e99a903dfebb356","user":{"login":"davies","id":40902,"avatar_url":"https://avatars.githubusercontent.com/u/40902?v=3","gravatar_id":"","url":"https://api.github.com/users/davies","html_url":"https://github.com/davies","followers_url":"https://api.github.com/users/davies/followers","following_url":"https://api.github.com/users/davies/following{/other_user}","gists_url":"https://api.github.com/users/davies/gists{/gist_id}","starred_url":"https://api.github.com/users/davies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davies/subscriptions","organizations_url":"https://api.github.com/users/davies/orgs","repos_url":"https://api.github.com/users/davies/repos","events_url":"https://api.github.com/users/davies/events{/privacy}","received_events_url":"https://api.github.com/users/davies/received_events","type":"User","site_admin":false},"body":"Also, we can bypassing the decoding in Python, then user could get a DataFrame by call sqlCtx.JsonRDD()","created_at":"2015-02-05T18:55:57Z","updated_at":"2015-02-05T18:55:57Z","html_url":"https://github.com/apache/spark/pull/3920#discussion_r24188162","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/3920","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/24188162"},"html":{"href":"https://github.com/apache/spark/pull/3920#discussion_r24188162"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/3920"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3920","id":26933448,"html_url":"https://github.com/apache/spark/pull/3920","diff_url":"https://github.com/apache/spark/pull/3920.diff","patch_url":"https://github.com/apache/spark/pull/3920.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/3920","number":3920,"state":"open","locked":false,"title":"[SPARK-5090][examples] The improvement of python converter for hbase","user":{"login":"GenTang","id":8790101,"avatar_url":"https://avatars.githubusercontent.com/u/8790101?v=3","gravatar_id":"","url":"https://api.github.com/users/GenTang","html_url":"https://github.com/GenTang","followers_url":"https://api.github.com/users/GenTang/followers","following_url":"https://api.github.com/users/GenTang/following{/other_user}","gists_url":"https://api.github.com/users/GenTang/gists{/gist_id}","starred_url":"https://api.github.com/users/GenTang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GenTang/subscriptions","organizations_url":"https://api.github.com/users/GenTang/orgs","repos_url":"https://api.github.com/users/GenTang/repos","events_url":"https://api.github.com/users/GenTang/events{/privacy}","received_events_url":"https://api.github.com/users/GenTang/received_events","type":"User","site_admin":false},"body":"Hi,\r\n\r\nFollowing the discussion in http://apache-spark-developers-list.1001551.n3.nabble.com/python-converter-in-HBaseConverter-scala-spark-examples-td10001.html. I made some modification in three files in package examples:\r\n1. HBaseConverters.scala: the new converter will converts all the records in an hbase results into a single string\r\n2. hbase_input.py: as the value string may contain several records, we can use ast package to convert the string into dict\r\n3. HBaseTest.scala: as the package examples use hbase 0.98.7 the original constructor HTableDescriptor is deprecated. The updation to new constructor is made\r\n","created_at":"2015-01-07T02:14:28Z","updated_at":"2015-02-05T18:55:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b15cd08a851642f49f510e6eaeeb14123f0e8e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/3920/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/3920/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/3920/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/15b1fe33caf1c2524afed7be6e99a903dfebb356","head":{"label":"GenTang:master","ref":"master","sha":"15b1fe33caf1c2524afed7be6e99a903dfebb356","user":{"login":"GenTang","id":8790101,"avatar_url":"https://avatars.githubusercontent.com/u/8790101?v=3","gravatar_id":"","url":"https://api.github.com/users/GenTang","html_url":"https://github.com/GenTang","followers_url":"https://api.github.com/users/GenTang/followers","following_url":"https://api.github.com/users/GenTang/following{/other_user}","gists_url":"https://api.github.com/users/GenTang/gists{/gist_id}","starred_url":"https://api.github.com/users/GenTang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GenTang/subscriptions","organizations_url":"https://api.github.com/users/GenTang/orgs","repos_url":"https://api.github.com/users/GenTang/repos","events_url":"https://api.github.com/users/GenTang/events{/privacy}","received_events_url":"https://api.github.com/users/GenTang/received_events","type":"User","site_admin":false},"repo":{"id":26017631,"name":"spark","full_name":"GenTang/spark","owner":{"login":"GenTang","id":8790101,"avatar_url":"https://avatars.githubusercontent.com/u/8790101?v=3","gravatar_id":"","url":"https://api.github.com/users/GenTang","html_url":"https://github.com/GenTang","followers_url":"https://api.github.com/users/GenTang/followers","following_url":"https://api.github.com/users/GenTang/following{/other_user}","gists_url":"https://api.github.com/users/GenTang/gists{/gist_id}","starred_url":"https://api.github.com/users/GenTang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GenTang/subscriptions","organizations_url":"https://api.github.com/users/GenTang/orgs","repos_url":"https://api.github.com/users/GenTang/repos","events_url":"https://api.github.com/users/GenTang/events{/privacy}","received_events_url":"https://api.github.com/users/GenTang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GenTang/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/GenTang/spark","forks_url":"https://api.github.com/repos/GenTang/spark/forks","keys_url":"https://api.github.com/repos/GenTang/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GenTang/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GenTang/spark/teams","hooks_url":"https://api.github.com/repos/GenTang/spark/hooks","issue_events_url":"https://api.github.com/repos/GenTang/spark/issues/events{/number}","events_url":"https://api.github.com/repos/GenTang/spark/events","assignees_url":"https://api.github.com/repos/GenTang/spark/assignees{/user}","branches_url":"https://api.github.com/repos/GenTang/spark/branches{/branch}","tags_url":"https://api.github.com/repos/GenTang/spark/tags","blobs_url":"https://api.github.com/repos/GenTang/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GenTang/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GenTang/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/GenTang/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GenTang/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/GenTang/spark/languages","stargazers_url":"https://api.github.com/repos/GenTang/spark/stargazers","contributors_url":"https://api.github.com/repos/GenTang/spark/contributors","subscribers_url":"https://api.github.com/repos/GenTang/spark/subscribers","subscription_url":"https://api.github.com/repos/GenTang/spark/subscription","commits_url":"https://api.github.com/repos/GenTang/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/GenTang/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/GenTang/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/GenTang/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/GenTang/spark/contents/{+path}","compare_url":"https://api.github.com/repos/GenTang/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GenTang/spark/merges","archive_url":"https://api.github.com/repos/GenTang/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GenTang/spark/downloads","issues_url":"https://api.github.com/repos/GenTang/spark/issues{/number}","pulls_url":"https://api.github.com/repos/GenTang/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/GenTang/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/GenTang/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GenTang/spark/labels{/name}","releases_url":"https://api.github.com/repos/GenTang/spark/releases{/id}","created_at":"2014-10-31T13:39:53Z","updated_at":"2015-01-22T23:18:24Z","pushed_at":"2015-02-01T19:45:08Z","git_url":"git://github.com/GenTang/spark.git","ssh_url":"git@github.com:GenTang/spark.git","clone_url":"https://github.com/GenTang/spark.git","svn_url":"https://github.com/GenTang/spark","homepage":null,"size":87295,"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":"c9c8b219ad81c4c30bc1598ff35b01f964570c29","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-02-05T18:16:24Z","pushed_at":"2015-02-05T18:16: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":1206449,"stargazers_count":2787,"watchers_count":2787,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2442,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":304,"forks":2442,"open_issues":304,"watchers":2787,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/3920"},"html":{"href":"https://github.com/apache/spark/pull/3920"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/3920"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/3920/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/3920/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/3920/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/15b1fe33caf1c2524afed7be6e99a903dfebb356"}}}}