{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/57959477","id":57959477,"diff_hunk":"@@ -391,41 +383,18 @@ public boolean advance() throws IOException {\n       if (Long.MAX_VALUE - source.stride < current) {\n         return false;\n       }\n-      if (getSplitBacklogElements() <= 0) {\n+      long nextValue = current + source.stride;\n+      if (timeToEmit(nextValue).isAfter(Instant.now())) {\n         return false;\n       }\n-      current += source.stride;\n+      current = nextValue;\n       currentTimestamp = source.timestampFn.apply(current);\n-      totalProduced++;\n       return true;\n     }\n \n-    /**\n-     * Gets the size of the split backlog in number of elements.\n-     */\n-    private long getSplitBacklogElements() {\n-      if (source.period.getMillis() == 0) {\n-        return Long.MAX_VALUE;\n-      }\n-      long msElapsed = Instant.now().getMillis() - started.getMillis();\n-      long expectedOutputs =\n-          LongMath.checkedMultiply(source.elementsPerPeriod, msElapsed) / source.period.getMillis();\n-      return expectedOutputs - totalProduced;\n-    }\n-\n-    @Override\n-    public long getSplitBacklogBytes() {\n-      long backlogElems = getSplitBacklogElements();\n-      if (backlogElems == Long.MAX_VALUE) {\n-        return BACKLOG_UNKNOWN;\n-      }\n-      // 8 == Long.BYTES\n-      long backlogBytes = backlogElems * 8;\n-      // overflow protection\n-      if (backlogBytes < backlogElems) {\n-        return Long.MAX_VALUE;\n-      }\n-      return backlogBytes;\n+    private Instant timeToEmit(long value) {\n+      long periodForValue = value / source.elementsPerPeriod;\n+      return firstStarted.plus(source.period.multipliedBy(periodForValue));","path":"sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/io/CountingSource.java","position":140,"original_position":140,"commit_id":"9470cf209e325bcc6a9bba365427d07091be8016","original_commit_id":"9470cf209e325bcc6a9bba365427d07091be8016","user":{"login":"dhalperi","id":526415,"avatar_url":"https://avatars.githubusercontent.com/u/526415?v=3","gravatar_id":"","url":"https://api.github.com/users/dhalperi","html_url":"https://github.com/dhalperi","followers_url":"https://api.github.com/users/dhalperi/followers","following_url":"https://api.github.com/users/dhalperi/following{/other_user}","gists_url":"https://api.github.com/users/dhalperi/gists{/gist_id}","starred_url":"https://api.github.com/users/dhalperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhalperi/subscriptions","organizations_url":"https://api.github.com/users/dhalperi/orgs","repos_url":"https://api.github.com/users/dhalperi/repos","events_url":"https://api.github.com/users/dhalperi/events{/privacy}","received_events_url":"https://api.github.com/users/dhalperi/received_events","type":"User","site_admin":false},"body":"this numeric rounding seems terrible if we have 100 elements per 100s, for example.","created_at":"2016-03-30T20:39:00Z","updated_at":"2016-03-30T20:39:00Z","html_url":"https://github.com/apache/incubator-beam/pull/17#discussion_r57959477","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/57959477"},"html":{"href":"https://github.com/apache/incubator-beam/pull/17#discussion_r57959477"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/17","id":61643098,"html_url":"https://github.com/apache/incubator-beam/pull/17","diff_url":"https://github.com/apache/incubator-beam/pull/17.diff","patch_url":"https://github.com/apache/incubator-beam/pull/17.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/17","number":17,"state":"open","locked":false,"title":"[BEAM-94] Add UnboundedCountingInput#withRate","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"body":"The period between elements controls the rate at which\r\nUnboundedCountingInput will output elements. This is an aggregate rate\r\nacross all instances of the source, and thus elements will not\r\nnecessarily be output \"smoothly\", or within the first period. The\r\naggregate rate, however, will be approximately equal to the provided\r\nrate.\r\n\r\nAdd package-private CountingSource.createUnbounded() to expose the\r\nUnboundedCountingSource type. Make UnboundedCountingSource\r\npackage-private.","created_at":"2016-03-03T23:23:25Z","updated_at":"2016-03-30T20:39:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb1efbeef67ccb31991052150818bdd9967b370a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/17/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/17/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-beam/issues/17/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/9470cf209e325bcc6a9bba365427d07091be8016","head":{"label":"tgroh:rate_limited_counting_source","ref":"rate_limited_counting_source","sha":"9470cf209e325bcc6a9bba365427d07091be8016","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"repo":{"id":52644388,"name":"incubator-beam","full_name":"tgroh/incubator-beam","owner":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tgroh/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/tgroh/incubator-beam","forks_url":"https://api.github.com/repos/tgroh/incubator-beam/forks","keys_url":"https://api.github.com/repos/tgroh/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgroh/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgroh/incubator-beam/teams","hooks_url":"https://api.github.com/repos/tgroh/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/tgroh/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/tgroh/incubator-beam/events","assignees_url":"https://api.github.com/repos/tgroh/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/tgroh/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/tgroh/incubator-beam/tags","blobs_url":"https://api.github.com/repos/tgroh/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgroh/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgroh/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgroh/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgroh/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/tgroh/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/tgroh/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/tgroh/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/tgroh/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/tgroh/incubator-beam/subscription","commits_url":"https://api.github.com/repos/tgroh/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgroh/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgroh/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgroh/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgroh/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/tgroh/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgroh/incubator-beam/merges","archive_url":"https://api.github.com/repos/tgroh/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgroh/incubator-beam/downloads","issues_url":"https://api.github.com/repos/tgroh/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/tgroh/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/tgroh/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/tgroh/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgroh/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/tgroh/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/tgroh/incubator-beam/deployments","created_at":"2016-02-27T01:43:32Z","updated_at":"2016-02-27T01:43:35Z","pushed_at":"2016-03-30T20:29:26Z","git_url":"git://github.com/tgroh/incubator-beam.git","ssh_url":"git@github.com:tgroh/incubator-beam.git","clone_url":"https://github.com/tgroh/incubator-beam.git","svn_url":"https://github.com/tgroh/incubator-beam","homepage":null,"size":11549,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"17863c851b2fff6a923122942833804a14ed9598","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":50904245,"name":"incubator-beam","full_name":"apache/incubator-beam","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/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-beam","forks_url":"https://api.github.com/repos/apache/incubator-beam/forks","keys_url":"https://api.github.com/repos/apache/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-beam/teams","hooks_url":"https://api.github.com/repos/apache/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-beam/events","assignees_url":"https://api.github.com/repos/apache/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-beam/tags","blobs_url":"https://api.github.com/repos/apache/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-beam/subscription","commits_url":"https://api.github.com/repos/apache/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-beam/merges","archive_url":"https://api.github.com/repos/apache/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-beam/downloads","issues_url":"https://api.github.com/repos/apache/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2016-03-30T20:22:17Z","pushed_at":"2016-03-30T20:29:26Z","git_url":"git://github.com/apache/incubator-beam.git","ssh_url":"git@github.com:apache/incubator-beam.git","clone_url":"https://github.com/apache/incubator-beam.git","svn_url":"https://github.com/apache/incubator-beam","homepage":null,"size":11743,"stargazers_count":98,"watchers_count":98,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":48,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":21,"forks":48,"open_issues":21,"watchers":98,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/17"},"html":{"href":"https://github.com/apache/incubator-beam/pull/17"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/17"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/9470cf209e325bcc6a9bba365427d07091be8016"}}}}