{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/67961040","id":67961040,"diff_hunk":"@@ -0,0 +1,68 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.apache.spark.examples.sql.streaming;\n+\n+\n+import org.apache.spark.sql.*;\n+import org.apache.spark.sql.streaming.OutputMode;\n+\n+import java.util.regex.Pattern;\n+\n+/**\n+ * Counts words in UTF8 encoded, '\\n' delimited text received from the network every second.\n+ *\n+ * Usage: JavaStructuredNetworkWordCount <hostname> <port> <checkpoint dir>\n+ * <hostname> and <port> describe the TCP server that Spark Streaming would connect to receive data.\n+ *\n+ * To run this on your local machine, you need to first run a Netcat server\n+ *    `$ nc -lk 9999`\n+ * and then run the example\n+ *    `$ bin/run-example org.apache.spark.examples.sql.streaming.JavaStructuredNetworkWordCount\n+ *    localhost 9999 <checkpoint dir>`\n+ */\n+public class JavaStructuredNetworkWordCount {\n+  private static final Pattern SPACE = Pattern.compile(\" \");\n+\n+  public static void main(String[] args) throws Exception {\n+    if (args.length < 3) {\n+      System.err.println(\"Usage: JavaNetworkWordCount <hostname> <port> <checkpoint dir>\");\n+      System.exit(1);\n+    }\n+\n+    SparkSession spark = SparkSession\n+      .builder()\n+      .appName(\"JavaStructuredNetworkWordCount\")\n+      .getOrCreate();\n+\n+    Dataset<String> df = spark.readStream().format(\"socket\").option(\"host\", args[0])\n+      .option(\"port\", args[1]).load().as(Encoders.STRING());\n+\n+    Dataset<String> words = df.select(functions.explode(functions.split(df.col(\"value\"), \" \")).alias(\"word\"))","path":"examples/src/main/java/org/apache/spark/examples/sql/streaming/JavaStructuredNetworkWordCount.java","position":54,"original_position":54,"commit_id":"38b5497ef17b0c1f1cf2a8c5731832bed06d2fc8","original_commit_id":"38b5497ef17b0c1f1cf2a8c5731832bed06d2fc8","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":"Same as above.\r\n\r\nand add comments on each line. \r\nis it a dataset of string or row??","created_at":"2016-06-21T22:05:24Z","updated_at":"2016-06-21T22:05:24Z","html_url":"https://github.com/apache/spark/pull/13816#discussion_r67961040","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/13816","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/67961040"},"html":{"href":"https://github.com/apache/spark/pull/13816#discussion_r67961040"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/13816"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13816","id":74685568,"html_url":"https://github.com/apache/spark/pull/13816","diff_url":"https://github.com/apache/spark/pull/13816.diff","patch_url":"https://github.com/apache/spark/pull/13816.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/13816","number":13816,"state":"open","locked":false,"title":"[SPARK-16114] [SQL] structured streaming network word count examples","user":{"login":"jjthomas","id":1242427,"avatar_url":"https://avatars.githubusercontent.com/u/1242427?v=3","gravatar_id":"","url":"https://api.github.com/users/jjthomas","html_url":"https://github.com/jjthomas","followers_url":"https://api.github.com/users/jjthomas/followers","following_url":"https://api.github.com/users/jjthomas/following{/other_user}","gists_url":"https://api.github.com/users/jjthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/jjthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjthomas/subscriptions","organizations_url":"https://api.github.com/users/jjthomas/orgs","repos_url":"https://api.github.com/users/jjthomas/repos","events_url":"https://api.github.com/users/jjthomas/events{/privacy}","received_events_url":"https://api.github.com/users/jjthomas/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nNetwork word count example for structured streaming\r\n\r\n\r\n## How was this patch tested?\r\n\r\nRun locally\r\n\r\n\r\n","created_at":"2016-06-21T21:07:13Z","updated_at":"2016-06-21T22:05:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33d2156309339c90dd7bdf1fe101c763b80b44fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/13816/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/13816/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/13816/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/38b5497ef17b0c1f1cf2a8c5731832bed06d2fc8","head":{"label":"jjthomas:master","ref":"master","sha":"38b5497ef17b0c1f1cf2a8c5731832bed06d2fc8","user":{"login":"jjthomas","id":1242427,"avatar_url":"https://avatars.githubusercontent.com/u/1242427?v=3","gravatar_id":"","url":"https://api.github.com/users/jjthomas","html_url":"https://github.com/jjthomas","followers_url":"https://api.github.com/users/jjthomas/followers","following_url":"https://api.github.com/users/jjthomas/following{/other_user}","gists_url":"https://api.github.com/users/jjthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/jjthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjthomas/subscriptions","organizations_url":"https://api.github.com/users/jjthomas/orgs","repos_url":"https://api.github.com/users/jjthomas/repos","events_url":"https://api.github.com/users/jjthomas/events{/privacy}","received_events_url":"https://api.github.com/users/jjthomas/received_events","type":"User","site_admin":false},"repo":{"id":61665583,"name":"spark","full_name":"jjthomas/spark","owner":{"login":"jjthomas","id":1242427,"avatar_url":"https://avatars.githubusercontent.com/u/1242427?v=3","gravatar_id":"","url":"https://api.github.com/users/jjthomas","html_url":"https://github.com/jjthomas","followers_url":"https://api.github.com/users/jjthomas/followers","following_url":"https://api.github.com/users/jjthomas/following{/other_user}","gists_url":"https://api.github.com/users/jjthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/jjthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjthomas/subscriptions","organizations_url":"https://api.github.com/users/jjthomas/orgs","repos_url":"https://api.github.com/users/jjthomas/repos","events_url":"https://api.github.com/users/jjthomas/events{/privacy}","received_events_url":"https://api.github.com/users/jjthomas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jjthomas/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/jjthomas/spark","forks_url":"https://api.github.com/repos/jjthomas/spark/forks","keys_url":"https://api.github.com/repos/jjthomas/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jjthomas/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jjthomas/spark/teams","hooks_url":"https://api.github.com/repos/jjthomas/spark/hooks","issue_events_url":"https://api.github.com/repos/jjthomas/spark/issues/events{/number}","events_url":"https://api.github.com/repos/jjthomas/spark/events","assignees_url":"https://api.github.com/repos/jjthomas/spark/assignees{/user}","branches_url":"https://api.github.com/repos/jjthomas/spark/branches{/branch}","tags_url":"https://api.github.com/repos/jjthomas/spark/tags","blobs_url":"https://api.github.com/repos/jjthomas/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jjthomas/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jjthomas/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/jjthomas/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jjthomas/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/jjthomas/spark/languages","stargazers_url":"https://api.github.com/repos/jjthomas/spark/stargazers","contributors_url":"https://api.github.com/repos/jjthomas/spark/contributors","subscribers_url":"https://api.github.com/repos/jjthomas/spark/subscribers","subscription_url":"https://api.github.com/repos/jjthomas/spark/subscription","commits_url":"https://api.github.com/repos/jjthomas/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/jjthomas/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/jjthomas/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/jjthomas/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/jjthomas/spark/contents/{+path}","compare_url":"https://api.github.com/repos/jjthomas/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jjthomas/spark/merges","archive_url":"https://api.github.com/repos/jjthomas/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jjthomas/spark/downloads","issues_url":"https://api.github.com/repos/jjthomas/spark/issues{/number}","pulls_url":"https://api.github.com/repos/jjthomas/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/jjthomas/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/jjthomas/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jjthomas/spark/labels{/name}","releases_url":"https://api.github.com/repos/jjthomas/spark/releases{/id}","deployments_url":"https://api.github.com/repos/jjthomas/spark/deployments","created_at":"2016-06-21T20:38:41Z","updated_at":"2016-06-21T20:39:05Z","pushed_at":"2016-06-21T21:04:27Z","git_url":"git://github.com/jjthomas/spark.git","ssh_url":"git@github.com:jjthomas/spark.git","clone_url":"https://github.com/jjthomas/spark.git","svn_url":"https://github.com/jjthomas/spark","homepage":null,"size":174879,"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":"dbfdae4e41a900de01b48639d6554d32edbb2e0b","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-06-21T19:40:41Z","pushed_at":"2016-06-21T22:05:04Z","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":492665,"stargazers_count":8999,"watchers_count":8999,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8364,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":388,"forks":8364,"open_issues":388,"watchers":8999,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/13816"},"html":{"href":"https://github.com/apache/spark/pull/13816"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/13816"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/13816/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/13816/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/13816/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/38b5497ef17b0c1f1cf2a8c5731832bed06d2fc8"}}}}
{"actor":{"display_login":"tdas"}}