{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/28302015","id":28302015,"diff_hunk":"@@ -70,7 +71,103 @@ def createStream(ssc, zkQuorum, groupId, topics, kafkaParams={},\n         except Py4JJavaError, e:\n             # TODO: use --jar once it also work on driver\n             if 'ClassNotFoundException' in str(e.java_exception):\n-                print \"\"\"\n+                KafkaUtils._printErrorMsg(ssc.sparkContext)\n+            raise e\n+        ser = PairDeserializer(NoOpSerializer(), NoOpSerializer())\n+        stream = DStream(jstream, ssc, ser)\n+        return stream.map(lambda (k, v): (keyDecoder(k), valueDecoder(v)))\n+\n+    @staticmethod\n+    def createDirectStream(ssc, brokerList, topics, kafkaParams={},","path":"python/pyspark/streaming/kafka.py","position":30,"original_position":30,"commit_id":"c3019515e3636568db6e625705b774f792c8bc2b","original_commit_id":"c3019515e3636568db6e625705b774f792c8bc2b","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"body":"I agree as such it is not a complicated thing, just that this way of doing\nthings is non-standard practice (unless you show me some examples of this\nbeing done in other python kafka libraries) and therefore should be added\nonly if there is a good use case / demand for it.\n\n\n\nOn Mon, Apr 13, 2015 at 10:48 PM, Saisai Shao <notifications@github.com>\nwrote:\n\n> In python/pyspark/streaming/kafka.py\n> <https://github.com/apache/spark/pull/4723#discussion_r28301930>:\n>\n> > @@ -70,7 +71,103 @@ def createStream(ssc, zkQuorum, groupId, topics, kafkaParams={},\n> >          except Py4JJavaError, e:\n> >              # TODO: use --jar once it also work on driver\n> >              if 'ClassNotFoundException' in str(e.java_exception):\n> > -                print \"\"\"\n> > +                KafkaUtils._printErrorMsg(ssc.sparkContext)\n> > +            raise e\n> > +        ser = PairDeserializer(NoOpSerializer(), NoOpSerializer())\n> > +        stream = DStream(jstream, ssc, ser)\n> > +        return stream.map(lambda (k, v): (keyDecoder(k), valueDecoder(v)))\n> > +\n> > +    @staticmethod\n> > +    def createDirectStream(ssc, brokerList, topics, kafkaParams={},\n>\n> OK, I will leave this to another PR.\n>\n> Basically this solution is not so complicated, just write (topic,\n> partition, key, message, offset) with a controlled format into a byte\n> array. And the python code unpack this byte array with same format into the\n> original data and construct a object used for message handler function.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/apache/spark/pull/4723/files#r28301930>.\n>\n","created_at":"2015-04-14T05:51:21Z","updated_at":"2015-04-14T05:51:21Z","html_url":"https://github.com/apache/spark/pull/4723#discussion_r28302015","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/4723","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/28302015"},"html":{"href":"https://github.com/apache/spark/pull/4723#discussion_r28302015"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/4723"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4723","id":29786841,"html_url":"https://github.com/apache/spark/pull/4723","diff_url":"https://github.com/apache/spark/pull/4723.diff","patch_url":"https://github.com/apache/spark/pull/4723.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/4723","number":4723,"state":"open","locked":false,"title":"[SPARK-5946][Streaming] Add Python API for direct Kafka stream","user":{"login":"jerryshao","id":850797,"avatar_url":"https://avatars.githubusercontent.com/u/850797?v=3","gravatar_id":"","url":"https://api.github.com/users/jerryshao","html_url":"https://github.com/jerryshao","followers_url":"https://api.github.com/users/jerryshao/followers","following_url":"https://api.github.com/users/jerryshao/following{/other_user}","gists_url":"https://api.github.com/users/jerryshao/gists{/gist_id}","starred_url":"https://api.github.com/users/jerryshao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerryshao/subscriptions","organizations_url":"https://api.github.com/users/jerryshao/orgs","repos_url":"https://api.github.com/users/jerryshao/repos","events_url":"https://api.github.com/users/jerryshao/events{/privacy}","received_events_url":"https://api.github.com/users/jerryshao/received_events","type":"User","site_admin":false},"body":"Currently only added `createDirectStream` API, I'm not sure if `createRDD` is also needed, since some Java object needs to be wrapped in Python. Please help to review, thanks a lot.","created_at":"2015-02-23T05:20:09Z","updated_at":"2015-04-14T05:51:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f53c6d3bf614e9ea3448ec5eff240fca8e37c4a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/4723/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/4723/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/4723/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/c3019515e3636568db6e625705b774f792c8bc2b","head":{"label":"jerryshao:direct-kafka-python-api","ref":"direct-kafka-python-api","sha":"c3019515e3636568db6e625705b774f792c8bc2b","user":{"login":"jerryshao","id":850797,"avatar_url":"https://avatars.githubusercontent.com/u/850797?v=3","gravatar_id":"","url":"https://api.github.com/users/jerryshao","html_url":"https://github.com/jerryshao","followers_url":"https://api.github.com/users/jerryshao/followers","following_url":"https://api.github.com/users/jerryshao/following{/other_user}","gists_url":"https://api.github.com/users/jerryshao/gists{/gist_id}","starred_url":"https://api.github.com/users/jerryshao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerryshao/subscriptions","organizations_url":"https://api.github.com/users/jerryshao/orgs","repos_url":"https://api.github.com/users/jerryshao/repos","events_url":"https://api.github.com/users/jerryshao/events{/privacy}","received_events_url":"https://api.github.com/users/jerryshao/received_events","type":"User","site_admin":false},"repo":{"id":18259371,"name":"apache-spark","full_name":"jerryshao/apache-spark","owner":{"login":"jerryshao","id":850797,"avatar_url":"https://avatars.githubusercontent.com/u/850797?v=3","gravatar_id":"","url":"https://api.github.com/users/jerryshao","html_url":"https://github.com/jerryshao","followers_url":"https://api.github.com/users/jerryshao/followers","following_url":"https://api.github.com/users/jerryshao/following{/other_user}","gists_url":"https://api.github.com/users/jerryshao/gists{/gist_id}","starred_url":"https://api.github.com/users/jerryshao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerryshao/subscriptions","organizations_url":"https://api.github.com/users/jerryshao/orgs","repos_url":"https://api.github.com/users/jerryshao/repos","events_url":"https://api.github.com/users/jerryshao/events{/privacy}","received_events_url":"https://api.github.com/users/jerryshao/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jerryshao/apache-spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/jerryshao/apache-spark","forks_url":"https://api.github.com/repos/jerryshao/apache-spark/forks","keys_url":"https://api.github.com/repos/jerryshao/apache-spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jerryshao/apache-spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jerryshao/apache-spark/teams","hooks_url":"https://api.github.com/repos/jerryshao/apache-spark/hooks","issue_events_url":"https://api.github.com/repos/jerryshao/apache-spark/issues/events{/number}","events_url":"https://api.github.com/repos/jerryshao/apache-spark/events","assignees_url":"https://api.github.com/repos/jerryshao/apache-spark/assignees{/user}","branches_url":"https://api.github.com/repos/jerryshao/apache-spark/branches{/branch}","tags_url":"https://api.github.com/repos/jerryshao/apache-spark/tags","blobs_url":"https://api.github.com/repos/jerryshao/apache-spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jerryshao/apache-spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jerryshao/apache-spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/jerryshao/apache-spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jerryshao/apache-spark/statuses/{sha}","languages_url":"https://api.github.com/repos/jerryshao/apache-spark/languages","stargazers_url":"https://api.github.com/repos/jerryshao/apache-spark/stargazers","contributors_url":"https://api.github.com/repos/jerryshao/apache-spark/contributors","subscribers_url":"https://api.github.com/repos/jerryshao/apache-spark/subscribers","subscription_url":"https://api.github.com/repos/jerryshao/apache-spark/subscription","commits_url":"https://api.github.com/repos/jerryshao/apache-spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/jerryshao/apache-spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/jerryshao/apache-spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/jerryshao/apache-spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/jerryshao/apache-spark/contents/{+path}","compare_url":"https://api.github.com/repos/jerryshao/apache-spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jerryshao/apache-spark/merges","archive_url":"https://api.github.com/repos/jerryshao/apache-spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jerryshao/apache-spark/downloads","issues_url":"https://api.github.com/repos/jerryshao/apache-spark/issues{/number}","pulls_url":"https://api.github.com/repos/jerryshao/apache-spark/pulls{/number}","milestones_url":"https://api.github.com/repos/jerryshao/apache-spark/milestones{/number}","notifications_url":"https://api.github.com/repos/jerryshao/apache-spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jerryshao/apache-spark/labels{/name}","releases_url":"https://api.github.com/repos/jerryshao/apache-spark/releases{/id}","created_at":"2014-03-30T07:04:45Z","updated_at":"2014-07-09T01:42:23Z","pushed_at":"2015-04-13T05:11:13Z","git_url":"git://github.com/jerryshao/apache-spark.git","ssh_url":"git@github.com:jerryshao/apache-spark.git","clone_url":"https://github.com/jerryshao/apache-spark.git","svn_url":"https://github.com/jerryshao/apache-spark","homepage":null,"size":126987,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"e0e64ba4b1b8eb72e856286f756c65fa22ab0a36","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-04-14T05:31:11Z","pushed_at":"2015-04-14T05:36:01Z","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":1511582,"stargazers_count":3596,"watchers_count":3596,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3109,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":295,"forks":3109,"open_issues":295,"watchers":3596,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/4723"},"html":{"href":"https://github.com/apache/spark/pull/4723"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/4723"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/4723/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/4723/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/4723/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/c3019515e3636568db6e625705b774f792c8bc2b"}}}}