{"action":"created","comment":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/74868573","id":74868573,"diff_hunk":"@@ -0,0 +1,245 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with 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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package org.apache.apex.malhar.stream.sample;\n+\n+import java.io.BufferedReader;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.InputStreamReader;\n+import java.util.Arrays;\n+\n+import org.joda.time.Duration;\n+import org.apache.apex.malhar.lib.window.TriggerOption;\n+import org.apache.apex.malhar.lib.window.Tuple;\n+import org.apache.apex.malhar.lib.window.WindowOption;\n+import org.apache.apex.malhar.stream.api.ApexStream;\n+import org.apache.apex.malhar.stream.api.WindowedStream;\n+import org.apache.apex.malhar.stream.api.function.Function;\n+import org.apache.apex.malhar.stream.api.impl.StreamFactory;\n+import org.apache.commons.io.IOUtils;\n+import org.apache.hadoop.conf.Configuration;\n+\n+import com.google.common.base.Throwables;\n+import com.datatorrent.api.Context;\n+import com.datatorrent.api.DAG;\n+import com.datatorrent.api.DefaultOutputPort;\n+import com.datatorrent.api.InputOperator;\n+import com.datatorrent.api.StreamingApplication;\n+import com.datatorrent.api.annotation.ApplicationAnnotation;\n+import com.datatorrent.common.util.BaseOperator;\n+import com.datatorrent.lib.util.KeyValPair;\n+\n+import static org.apache.apex.malhar.stream.api.Option.Options.name;\n+\n+/**\n+ * Beam WindowedWordCount Example.\n+ */\n+@ApplicationAnnotation(name = \"WindowedWordCount\")\n+public class WindowedWordCount implements StreamingApplication\n+{\n+  static final int WINDOW_SIZE = 1;  // Default window duration in minutes\n+  \n+  /**\n+   * A input operator that reads from and output a file line by line to downstream with a time gap between\n+   * every two lines.\n+   */\n+  public static class TextInput extends BaseOperator implements InputOperator\n+  {\n+    public final transient DefaultOutputPort<String> output = new DefaultOutputPort<>();\n+    \n+    private transient BufferedReader reader;\n+    \n+    @Override\n+    public void setup(Context.OperatorContext context)\n+    {\n+      initReader();\n+    }\n+    \n+    private void initReader()\n+    {\n+      try {\n+        InputStream resourceStream = this.getClass().getResourceAsStream(\"/wordcount/word.txt\");\n+        reader = new BufferedReader(new InputStreamReader(resourceStream));\n+      } catch (Exception ex) {\n+        throw Throwables.propagate(ex);\n+      }\n+    }\n+    \n+    @Override\n+    public void teardown()\n+    {\n+      IOUtils.closeQuietly(reader);\n+    }\n+    \n+    @Override\n+    public void emitTuples()\n+    {\n+      try {\n+        String line = reader.readLine();\n+        if (line == null) {\n+          reader.close();\n+          initReader();\n+        } else {\n+          this.output.emit(line);\n+        }\n+        Thread.sleep(500);\n+      } catch (IOException ex) {\n+        throw new RuntimeException(ex);\n+      } catch (InterruptedException e) {\n+        e.printStackTrace();","path":"demos/highlevelapi/src/main/java/org/apache/apex/malhar/stream/sample/WindowedWordCount.java","position":105,"original_position":105,"commit_id":"97f063ec99f9426180fab5a8129c76aaf711a55c","original_commit_id":"97f063ec99f9426180fab5a8129c76aaf711a55c","user":{"login":"tweise","id":263695,"avatar_url":"https://avatars.githubusercontent.com/u/263695?v=3","gravatar_id":"","url":"https://api.github.com/users/tweise","html_url":"https://github.com/tweise","followers_url":"https://api.github.com/users/tweise/followers","following_url":"https://api.github.com/users/tweise/following{/other_user}","gists_url":"https://api.github.com/users/tweise/gists{/gist_id}","starred_url":"https://api.github.com/users/tweise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweise/subscriptions","organizations_url":"https://api.github.com/users/tweise/orgs","repos_url":"https://api.github.com/users/tweise/repos","events_url":"https://api.github.com/users/tweise/events{/privacy}","received_events_url":"https://api.github.com/users/tweise/received_events","type":"User","site_admin":false},"body":"At this point we need everything code style related fixed so that we can merge the PR soon (for 3.5 release).","created_at":"2016-08-16T02:36:05Z","updated_at":"2016-08-16T02:36:05Z","html_url":"https://github.com/apache/apex-malhar/pull/339#discussion_r74868573","pull_request_url":"https://api.github.com/repos/apache/apex-malhar/pulls/339","_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/74868573"},"html":{"href":"https://github.com/apache/apex-malhar/pull/339#discussion_r74868573"},"pull_request":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/339"}}},"pull_request":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/339","id":77172445,"html_url":"https://github.com/apache/apex-malhar/pull/339","diff_url":"https://github.com/apache/apex-malhar/pull/339.diff","patch_url":"https://github.com/apache/apex-malhar/pull/339.patch","issue_url":"https://api.github.com/repos/apache/apex-malhar/issues/339","number":339,"state":"open","locked":false,"title":"APEXMALHAR-2142 Windowed Stream First Implementation ","user":{"login":"siyuanh","id":5375712,"avatar_url":"https://avatars.githubusercontent.com/u/5375712?v=3","gravatar_id":"","url":"https://api.github.com/users/siyuanh","html_url":"https://github.com/siyuanh","followers_url":"https://api.github.com/users/siyuanh/followers","following_url":"https://api.github.com/users/siyuanh/following{/other_user}","gists_url":"https://api.github.com/users/siyuanh/gists{/gist_id}","starred_url":"https://api.github.com/users/siyuanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siyuanh/subscriptions","organizations_url":"https://api.github.com/users/siyuanh/orgs","repos_url":"https://api.github.com/users/siyuanh/repos","events_url":"https://api.github.com/users/siyuanh/events{/privacy}","received_events_url":"https://api.github.com/users/siyuanh/received_events","type":"User","site_admin":false},"body":"\r\nThis is for review only, please ignore all checkstyle violations, format issue etc.\r\n\r\nFor windowed operator changes, refer to #319\r\n\r\nPlease only review the code in stream module.\r\n","created_at":"2016-07-12T18:58:40Z","updated_at":"2016-08-16T02:36:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0138acc918d341bce38686a3b6a63acf998e3657","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/apex-malhar/pulls/339/commits","review_comments_url":"https://api.github.com/repos/apache/apex-malhar/pulls/339/comments","review_comment_url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/apex-malhar/issues/339/comments","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/97f063ec99f9426180fab5a8129c76aaf711a55c","head":{"label":"siyuanh:WindowedStream","ref":"WindowedStream","sha":"97f063ec99f9426180fab5a8129c76aaf711a55c","user":{"login":"siyuanh","id":5375712,"avatar_url":"https://avatars.githubusercontent.com/u/5375712?v=3","gravatar_id":"","url":"https://api.github.com/users/siyuanh","html_url":"https://github.com/siyuanh","followers_url":"https://api.github.com/users/siyuanh/followers","following_url":"https://api.github.com/users/siyuanh/following{/other_user}","gists_url":"https://api.github.com/users/siyuanh/gists{/gist_id}","starred_url":"https://api.github.com/users/siyuanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siyuanh/subscriptions","organizations_url":"https://api.github.com/users/siyuanh/orgs","repos_url":"https://api.github.com/users/siyuanh/repos","events_url":"https://api.github.com/users/siyuanh/events{/privacy}","received_events_url":"https://api.github.com/users/siyuanh/received_events","type":"User","site_admin":false},"repo":{"id":41434344,"name":"apex-malhar","full_name":"siyuanh/apex-malhar","owner":{"login":"siyuanh","id":5375712,"avatar_url":"https://avatars.githubusercontent.com/u/5375712?v=3","gravatar_id":"","url":"https://api.github.com/users/siyuanh","html_url":"https://github.com/siyuanh","followers_url":"https://api.github.com/users/siyuanh/followers","following_url":"https://api.github.com/users/siyuanh/following{/other_user}","gists_url":"https://api.github.com/users/siyuanh/gists{/gist_id}","starred_url":"https://api.github.com/users/siyuanh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siyuanh/subscriptions","organizations_url":"https://api.github.com/users/siyuanh/orgs","repos_url":"https://api.github.com/users/siyuanh/repos","events_url":"https://api.github.com/users/siyuanh/events{/privacy}","received_events_url":"https://api.github.com/users/siyuanh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/siyuanh/apex-malhar","description":"Mirror of Apache Apex malhar (Incubating)","fork":true,"url":"https://api.github.com/repos/siyuanh/apex-malhar","forks_url":"https://api.github.com/repos/siyuanh/apex-malhar/forks","keys_url":"https://api.github.com/repos/siyuanh/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/siyuanh/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/siyuanh/apex-malhar/teams","hooks_url":"https://api.github.com/repos/siyuanh/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/siyuanh/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/siyuanh/apex-malhar/events","assignees_url":"https://api.github.com/repos/siyuanh/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/siyuanh/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/siyuanh/apex-malhar/tags","blobs_url":"https://api.github.com/repos/siyuanh/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/siyuanh/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/siyuanh/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/siyuanh/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/siyuanh/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/siyuanh/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/siyuanh/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/siyuanh/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/siyuanh/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/siyuanh/apex-malhar/subscription","commits_url":"https://api.github.com/repos/siyuanh/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/siyuanh/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/siyuanh/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/siyuanh/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/siyuanh/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/siyuanh/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/siyuanh/apex-malhar/merges","archive_url":"https://api.github.com/repos/siyuanh/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/siyuanh/apex-malhar/downloads","issues_url":"https://api.github.com/repos/siyuanh/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/siyuanh/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/siyuanh/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/siyuanh/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/siyuanh/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/siyuanh/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/siyuanh/apex-malhar/deployments","created_at":"2015-08-26T15:42:48Z","updated_at":"2016-06-21T16:34:39Z","pushed_at":"2016-08-11T22:07:12Z","git_url":"git://github.com/siyuanh/apex-malhar.git","ssh_url":"git@github.com:siyuanh/apex-malhar.git","clone_url":"https://github.com/siyuanh/apex-malhar.git","svn_url":"https://github.com/siyuanh/apex-malhar","homepage":null,"size":87108,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"3316d6a78c1cd7101e23f0466a8c9dc0aa6386ed","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":41348334,"name":"apex-malhar","full_name":"apache/apex-malhar","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/apex-malhar","description":"Mirror of Apache Apex malhar","fork":false,"url":"https://api.github.com/repos/apache/apex-malhar","forks_url":"https://api.github.com/repos/apache/apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/apache/apex-malhar/deployments","created_at":"2015-08-25T07:00:05Z","updated_at":"2016-08-12T04:27:06Z","pushed_at":"2016-08-16T00:51:07Z","git_url":"git://github.com/apache/apex-malhar.git","ssh_url":"git@github.com:apache/apex-malhar.git","clone_url":"https://github.com/apache/apex-malhar.git","svn_url":"https://github.com/apache/apex-malhar","homepage":"","size":97475,"stargazers_count":54,"watchers_count":54,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":95,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":28,"forks":95,"open_issues":28,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/339"},"html":{"href":"https://github.com/apache/apex-malhar/pull/339"},"issue":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/339"},"comments":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/339/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/339/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/339/commits"},"statuses":{"href":"https://api.github.com/repos/apache/apex-malhar/statuses/97f063ec99f9426180fab5a8129c76aaf711a55c"}}}}
{"actor":{"display_login":"tweise"}}