{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/61411759","id":61411759,"diff_hunk":"@@ -0,0 +1,128 @@\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+\n+package org.apache.kafka.streams.kstream;\n+\n+import org.apache.kafka.streams.kstream.internals.TimeWindow;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+/**\n+ * The time-based window specifications used for aggregations.\n+ */\n+public class TimeWindows extends Windows<TimeWindow> {\n+\n+    /**\n+     * The size of the window, i.e. how long a window lasts.\n+     * The window size's effective time unit is determined by the semantics of the topology's\n+     * configured {@link org.apache.kafka.streams.processor.TimestampExtractor}.\n+     */\n+    public final long size;\n+\n+    /**\n+     * The size of the window's hop, i.e. by how much a window moves forward relative to the previous one.\n+     * The hop size's effective time unit is determined by the semantics of the topology's\n+     * configured {@link org.apache.kafka.streams.processor.TimestampExtractor}.\n+     */\n+    public final long hop;\n+\n+    private TimeWindows(String name, long size, long hop) {\n+        super(name);\n+        if (size <= 0) {\n+            throw new IllegalArgumentException(\"size must be > 0 (you provided \" + size + \")\");\n+        }\n+        this.size = size;\n+        if (!(0 < hop && hop <= size)) {\n+            throw new IllegalArgumentException(String.format(\"hop (%d) must lie within interval (0, %d]\", hop, size));\n+        }\n+        this.hop = hop;\n+    }\n+\n+    /**\n+     * Returns a window definition with the given window size, and with the hop size being equal to\n+     * the window size.  Think: [N * size, N * size + size), with N denoting the N-th window.\n+     *\n+     * This provides the semantics of tumbling windows, which are fixed-sized, gap-less,\n+     * non-overlapping windows.  Tumbling windows are a specialization of hopping windows.\n+     *\n+     * @param name The name of the window.  Must not be null or empty.\n+     * @param size The size of the window, with the requirement that size &gt; 0.\n+     *             The window size's effective time unit is determined by the semantics of the\n+     *             topology's configured {@link org.apache.kafka.streams.processor.TimestampExtractor}.\n+     * @return a new window definition\n+     */\n+    public static TimeWindows of(String name, long size) {\n+        return new TimeWindows(name, size, size);\n+    }\n+\n+    /**\n+     * Returns a window definition with the original size, but shift (\"hop\") the window by the given\n+     * hop size, which specifies by how much a window moves forward relative to the previous one.\n+     * Think: [N * hop, N * hop + size), with N denoting the N-th window.\n+     *\n+     * This provides the semantics of hopping windows, which are fixed-sized, overlapping windows.\n+     *\n+     * @param hop The hop size of the window, with the requirement that 0 &lt; hop &le; size.\n+     *            The hop size's effective time unit is determined by the semantics of the\n+     *            topology's configured {@link org.apache.kafka.streams.processor.TimestampExtractor}.\n+     * @return a new window definition\n+     */\n+    public TimeWindows shiftedBy(long hop) {","path":"streams/src/main/java/org/apache/kafka/streams/kstream/TimeWindows.java","position":85,"original_position":85,"commit_id":"b0f68c4b1a1f83ee20a4ff2ea55e4e915d016a30","original_commit_id":"b0f68c4b1a1f83ee20a4ff2ea55e4e915d016a30","user":{"login":"mjsax","id":8959638,"avatar_url":"https://avatars.githubusercontent.com/u/8959638?v=3","gravatar_id":"","url":"https://api.github.com/users/mjsax","html_url":"https://github.com/mjsax","followers_url":"https://api.github.com/users/mjsax/followers","following_url":"https://api.github.com/users/mjsax/following{/other_user}","gists_url":"https://api.github.com/users/mjsax/gists{/gist_id}","starred_url":"https://api.github.com/users/mjsax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjsax/subscriptions","organizations_url":"https://api.github.com/users/mjsax/orgs","repos_url":"https://api.github.com/users/mjsax/repos","events_url":"https://api.github.com/users/mjsax/events{/privacy}","received_events_url":"https://api.github.com/users/mjsax/received_events","type":"User","site_admin":false},"body":"I would prefer `advanceBy(long advance)`","created_at":"2016-04-28T11:31:36Z","updated_at":"2016-04-28T11:31:36Z","html_url":"https://github.com/apache/kafka/pull/1277#discussion_r61411759","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/1277","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/61411759"},"html":{"href":"https://github.com/apache/kafka/pull/1277#discussion_r61411759"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/1277"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/1277","id":68128928,"html_url":"https://github.com/apache/kafka/pull/1277","diff_url":"https://github.com/apache/kafka/pull/1277.diff","patch_url":"https://github.com/apache/kafka/pull/1277.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/1277","number":1277,"state":"open","locked":false,"title":"KAFKA-3613: Consolidate TumblingWindows and HoppingWindows into TimeWindows","user":{"login":"miguno","id":294849,"avatar_url":"https://avatars.githubusercontent.com/u/294849?v=3","gravatar_id":"","url":"https://api.github.com/users/miguno","html_url":"https://github.com/miguno","followers_url":"https://api.github.com/users/miguno/followers","following_url":"https://api.github.com/users/miguno/following{/other_user}","gists_url":"https://api.github.com/users/miguno/gists{/gist_id}","starred_url":"https://api.github.com/users/miguno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguno/subscriptions","organizations_url":"https://api.github.com/users/miguno/orgs","repos_url":"https://api.github.com/users/miguno/repos","events_url":"https://api.github.com/users/miguno/events{/privacy}","received_events_url":"https://api.github.com/users/miguno/received_events","type":"User","site_admin":false},"body":"This PR includes the same code as https://github.com/apache/kafka/pull/1261 but is rebased on latest trunk.","created_at":"2016-04-27T21:34:17Z","updated_at":"2016-04-28T11:31:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b44cf391a06811ee74ba75f425d6d07f8c134bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/1277/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/1277/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/1277/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/b0f68c4b1a1f83ee20a4ff2ea55e4e915d016a30","head":{"label":"miguno:KAFKA-3613-v2","ref":"KAFKA-3613-v2","sha":"b0f68c4b1a1f83ee20a4ff2ea55e4e915d016a30","user":{"login":"miguno","id":294849,"avatar_url":"https://avatars.githubusercontent.com/u/294849?v=3","gravatar_id":"","url":"https://api.github.com/users/miguno","html_url":"https://github.com/miguno","followers_url":"https://api.github.com/users/miguno/followers","following_url":"https://api.github.com/users/miguno/following{/other_user}","gists_url":"https://api.github.com/users/miguno/gists{/gist_id}","starred_url":"https://api.github.com/users/miguno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguno/subscriptions","organizations_url":"https://api.github.com/users/miguno/orgs","repos_url":"https://api.github.com/users/miguno/repos","events_url":"https://api.github.com/users/miguno/events{/privacy}","received_events_url":"https://api.github.com/users/miguno/received_events","type":"User","site_admin":false},"repo":{"id":8747931,"name":"kafka","full_name":"miguno/kafka","owner":{"login":"miguno","id":294849,"avatar_url":"https://avatars.githubusercontent.com/u/294849?v=3","gravatar_id":"","url":"https://api.github.com/users/miguno","html_url":"https://github.com/miguno","followers_url":"https://api.github.com/users/miguno/followers","following_url":"https://api.github.com/users/miguno/following{/other_user}","gists_url":"https://api.github.com/users/miguno/gists{/gist_id}","starred_url":"https://api.github.com/users/miguno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguno/subscriptions","organizations_url":"https://api.github.com/users/miguno/orgs","repos_url":"https://api.github.com/users/miguno/repos","events_url":"https://api.github.com/users/miguno/events{/privacy}","received_events_url":"https://api.github.com/users/miguno/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miguno/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/miguno/kafka","forks_url":"https://api.github.com/repos/miguno/kafka/forks","keys_url":"https://api.github.com/repos/miguno/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miguno/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miguno/kafka/teams","hooks_url":"https://api.github.com/repos/miguno/kafka/hooks","issue_events_url":"https://api.github.com/repos/miguno/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/miguno/kafka/events","assignees_url":"https://api.github.com/repos/miguno/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/miguno/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/miguno/kafka/tags","blobs_url":"https://api.github.com/repos/miguno/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miguno/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miguno/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/miguno/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miguno/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/miguno/kafka/languages","stargazers_url":"https://api.github.com/repos/miguno/kafka/stargazers","contributors_url":"https://api.github.com/repos/miguno/kafka/contributors","subscribers_url":"https://api.github.com/repos/miguno/kafka/subscribers","subscription_url":"https://api.github.com/repos/miguno/kafka/subscription","commits_url":"https://api.github.com/repos/miguno/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/miguno/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/miguno/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/miguno/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/miguno/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/miguno/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miguno/kafka/merges","archive_url":"https://api.github.com/repos/miguno/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miguno/kafka/downloads","issues_url":"https://api.github.com/repos/miguno/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/miguno/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/miguno/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/miguno/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miguno/kafka/labels{/name}","releases_url":"https://api.github.com/repos/miguno/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/miguno/kafka/deployments","created_at":"2013-03-13T08:24:00Z","updated_at":"2015-11-04T08:48:27Z","pushed_at":"2016-04-27T22:51:32Z","git_url":"git://github.com/miguno/kafka.git","ssh_url":"git@github.com:miguno/kafka.git","clone_url":"https://github.com/miguno/kafka.git","svn_url":"https://github.com/miguno/kafka","homepage":null,"size":29700,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":0,"forks":12,"open_issues":0,"watchers":1,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"8407dac6ee409d832c95533e6f1d5578511232ae","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":2211243,"name":"kafka","full_name":"apache/kafka","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/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2016-04-28T09:59:25Z","pushed_at":"2016-04-28T11:18:49Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":40291,"stargazers_count":3020,"watchers_count":3020,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1815,"mirror_url":"git://git.apache.org/kafka.git","open_issues_count":182,"forks":1815,"open_issues":182,"watchers":3020,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/1277"},"html":{"href":"https://github.com/apache/kafka/pull/1277"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/1277"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/1277/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/1277/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/1277/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/b0f68c4b1a1f83ee20a4ff2ea55e4e915d016a30"}}}}