{"action":"created","comment":{"url":"https://api.github.com/repos/google/instrumentation-java/pulls/comments/111592380","pull_request_review_id":32848452,"id":111592380,"diff_hunk":"@@ -0,0 +1,215 @@\n+/*\n+ * Copyright 2017, Google Inc.\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *     http://www.apache.org/licenses/LICENSE-2.0\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 com.google.instrumentation.stats;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+import javax.annotation.Nullable;\n+\n+/**\n+ * Mutable version of {@link Distribution}.\n+ */\n+public final class MutableDistribution {\n+  private long count = 0; // The number of values in the population.\n+  private double sum = 0.0; // The sum of the values in the population.\n+  private Range range = Range.create(); // Range of values in the population.\n+\n+  @Nullable\n+  private final BucketBoundaries bucketBoundaries; // Histogram boundaries; null means no histogram\n+\n+  @Nullable\n+  private long[] bucketCounts; // Counts for each histogram bucket\n+\n+  /**\n+   * Constructs a new, empty {@link MutableDistribution}.\n+   *\n+   * @return a new, empty {@code MutableDistribution}.\n+   */\n+  public static final MutableDistribution create() {\n+    return new MutableDistribution(null);\n+  }\n+\n+  /**\n+   * Constructs a new {@link MutableDistribution} with specified {@code bucketBoundaryList}.\n+   *\n+   * @param bucketBoundaries the boundaries for the buckets in the underlying {@code\n+   *     MutableDistribution}.\n+   * @return a new, empty {@code MutableDistribution} with the specified boundaries.\n+   */\n+  public static final MutableDistribution create(BucketBoundaries bucketBoundaries) {\n+    checkNotNull(bucketBoundaries, \"bucketBoundaries Object should not be null.\");\n+    return new MutableDistribution(bucketBoundaries);\n+  }\n+\n+  // Returns true if the distribution has histogram buckets.\n+  private boolean hasBuckets() {\n+    return (bucketBoundaries != null);\n+  }\n+\n+  // Construct a new MutableDistribution with optional bucket boundaries.\n+  private MutableDistribution(@Nullable BucketBoundaries bucketBoundaries) {\n+    this.bucketBoundaries = bucketBoundaries;\n+    if (hasBuckets()) {\n+      bucketCounts = new long[bucketBoundaries.getBoundaries().size() + 1];\n+    }\n+  }\n+\n+  /**\n+   * The number of values in the population. Must be non-negative.","path":"core/src/main/java/com/google/instrumentation/stats/MutableDistribution.java","position":72,"original_position":72,"commit_id":"a8385a758b2e5cd24e2f28739e7ba35f71578a2d","original_commit_id":"a8385a758b2e5cd24e2f28739e7ba35f71578a2d","user":{"login":"bogdandrutu","id":1373887,"avatar_url":"https://avatars3.githubusercontent.com/u/1373887?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdandrutu","html_url":"https://github.com/bogdandrutu","followers_url":"https://api.github.com/users/bogdandrutu/followers","following_url":"https://api.github.com/users/bogdandrutu/following{/other_user}","gists_url":"https://api.github.com/users/bogdandrutu/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdandrutu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdandrutu/subscriptions","organizations_url":"https://api.github.com/users/bogdandrutu/orgs","repos_url":"https://api.github.com/users/bogdandrutu/repos","events_url":"https://api.github.com/users/bogdandrutu/events{/privacy}","received_events_url":"https://api.github.com/users/bogdandrutu/received_events","type":"User","site_admin":false},"body":"I would start this sentence with:\r\n\r\nReturns the number ....\r\nhttps://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment\r\n","created_at":"2017-04-14T15:49:24Z","updated_at":"2017-04-14T15:49:34Z","html_url":"https://github.com/google/instrumentation-java/pull/206#discussion_r111592380","pull_request_url":"https://api.github.com/repos/google/instrumentation-java/pulls/206","_links":{"self":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/comments/111592380"},"html":{"href":"https://github.com/google/instrumentation-java/pull/206#discussion_r111592380"},"pull_request":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/206"}}},"pull_request":{"url":"https://api.github.com/repos/google/instrumentation-java/pulls/206","id":115680894,"html_url":"https://github.com/google/instrumentation-java/pull/206","diff_url":"https://github.com/google/instrumentation-java/pull/206.diff","patch_url":"https://github.com/google/instrumentation-java/pull/206.patch","issue_url":"https://api.github.com/repos/google/instrumentation-java/issues/206","number":206,"state":"open","locked":false,"title":"Split Distribution into mutable and immutable classes.","user":{"login":"sebright","id":19807615,"avatar_url":"https://avatars3.githubusercontent.com/u/19807615?v=3","gravatar_id":"","url":"https://api.github.com/users/sebright","html_url":"https://github.com/sebright","followers_url":"https://api.github.com/users/sebright/followers","following_url":"https://api.github.com/users/sebright/following{/other_user}","gists_url":"https://api.github.com/users/sebright/gists{/gist_id}","starred_url":"https://api.github.com/users/sebright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebright/subscriptions","organizations_url":"https://api.github.com/users/sebright/orgs","repos_url":"https://api.github.com/users/sebright/repos","events_url":"https://api.github.com/users/sebright/events{/privacy}","received_events_url":"https://api.github.com/users/sebright/received_events","type":"User","site_admin":false},"body":"Distribution is an immutable AutoValue class, and MutableDistribution is a\r\nmutable version of Distribution.  We can use MutableDistribution to store stats\r\nas they are recorded and then copy them into a Distribution before returning\r\nthem in a View.  We can also use Distribution to store the distribution data in\r\nDistributionAggregation.\r\n\r\nI copied/renamed files in separate commits to try to make the diffs smaller.\r\n\r\n/cc @a-veitch @dinooliva ","created_at":"2017-04-13T04:15:36Z","updated_at":"2017-04-14T15:49:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40f8c642c51a8f68a0786e99a5c93da6b931bfaf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/instrumentation-java/pulls/206/commits","review_comments_url":"https://api.github.com/repos/google/instrumentation-java/pulls/206/comments","review_comment_url":"https://api.github.com/repos/google/instrumentation-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/instrumentation-java/issues/206/comments","statuses_url":"https://api.github.com/repos/google/instrumentation-java/statuses/a8385a758b2e5cd24e2f28739e7ba35f71578a2d","head":{"label":"sebright:immutable-distribution","ref":"immutable-distribution","sha":"a8385a758b2e5cd24e2f28739e7ba35f71578a2d","user":{"login":"sebright","id":19807615,"avatar_url":"https://avatars3.githubusercontent.com/u/19807615?v=3","gravatar_id":"","url":"https://api.github.com/users/sebright","html_url":"https://github.com/sebright","followers_url":"https://api.github.com/users/sebright/followers","following_url":"https://api.github.com/users/sebright/following{/other_user}","gists_url":"https://api.github.com/users/sebright/gists{/gist_id}","starred_url":"https://api.github.com/users/sebright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebright/subscriptions","organizations_url":"https://api.github.com/users/sebright/orgs","repos_url":"https://api.github.com/users/sebright/repos","events_url":"https://api.github.com/users/sebright/events{/privacy}","received_events_url":"https://api.github.com/users/sebright/received_events","type":"User","site_admin":false},"repo":{"id":64432626,"name":"instrumentation-java","full_name":"sebright/instrumentation-java","owner":{"login":"sebright","id":19807615,"avatar_url":"https://avatars3.githubusercontent.com/u/19807615?v=3","gravatar_id":"","url":"https://api.github.com/users/sebright","html_url":"https://github.com/sebright","followers_url":"https://api.github.com/users/sebright/followers","following_url":"https://api.github.com/users/sebright/following{/other_user}","gists_url":"https://api.github.com/users/sebright/gists{/gist_id}","starred_url":"https://api.github.com/users/sebright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebright/subscriptions","organizations_url":"https://api.github.com/users/sebright/orgs","repos_url":"https://api.github.com/users/sebright/repos","events_url":"https://api.github.com/users/sebright/events{/privacy}","received_events_url":"https://api.github.com/users/sebright/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sebright/instrumentation-java","description":"A stats collection framework","fork":true,"url":"https://api.github.com/repos/sebright/instrumentation-java","forks_url":"https://api.github.com/repos/sebright/instrumentation-java/forks","keys_url":"https://api.github.com/repos/sebright/instrumentation-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sebright/instrumentation-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sebright/instrumentation-java/teams","hooks_url":"https://api.github.com/repos/sebright/instrumentation-java/hooks","issue_events_url":"https://api.github.com/repos/sebright/instrumentation-java/issues/events{/number}","events_url":"https://api.github.com/repos/sebright/instrumentation-java/events","assignees_url":"https://api.github.com/repos/sebright/instrumentation-java/assignees{/user}","branches_url":"https://api.github.com/repos/sebright/instrumentation-java/branches{/branch}","tags_url":"https://api.github.com/repos/sebright/instrumentation-java/tags","blobs_url":"https://api.github.com/repos/sebright/instrumentation-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sebright/instrumentation-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sebright/instrumentation-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/sebright/instrumentation-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sebright/instrumentation-java/statuses/{sha}","languages_url":"https://api.github.com/repos/sebright/instrumentation-java/languages","stargazers_url":"https://api.github.com/repos/sebright/instrumentation-java/stargazers","contributors_url":"https://api.github.com/repos/sebright/instrumentation-java/contributors","subscribers_url":"https://api.github.com/repos/sebright/instrumentation-java/subscribers","subscription_url":"https://api.github.com/repos/sebright/instrumentation-java/subscription","commits_url":"https://api.github.com/repos/sebright/instrumentation-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/sebright/instrumentation-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/sebright/instrumentation-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/sebright/instrumentation-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/sebright/instrumentation-java/contents/{+path}","compare_url":"https://api.github.com/repos/sebright/instrumentation-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sebright/instrumentation-java/merges","archive_url":"https://api.github.com/repos/sebright/instrumentation-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sebright/instrumentation-java/downloads","issues_url":"https://api.github.com/repos/sebright/instrumentation-java/issues{/number}","pulls_url":"https://api.github.com/repos/sebright/instrumentation-java/pulls{/number}","milestones_url":"https://api.github.com/repos/sebright/instrumentation-java/milestones{/number}","notifications_url":"https://api.github.com/repos/sebright/instrumentation-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sebright/instrumentation-java/labels{/name}","releases_url":"https://api.github.com/repos/sebright/instrumentation-java/releases{/id}","deployments_url":"https://api.github.com/repos/sebright/instrumentation-java/deployments","created_at":"2016-07-28T22:38:05Z","updated_at":"2016-11-03T19:32:37Z","pushed_at":"2017-04-14T04:39:09Z","git_url":"git://github.com/sebright/instrumentation-java.git","ssh_url":"git@github.com:sebright/instrumentation-java.git","clone_url":"https://github.com/sebright/instrumentation-java.git","svn_url":"https://github.com/sebright/instrumentation-java","homepage":"","size":763,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":false,"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":"google:master","ref":"master","sha":"e0f6ae0640ac9ebeb20733aa8b5400d5b8261ed7","user":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":64431348,"name":"instrumentation-java","full_name":"google/instrumentation-java","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars2.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/instrumentation-java","description":"A stats collection framework","fork":false,"url":"https://api.github.com/repos/google/instrumentation-java","forks_url":"https://api.github.com/repos/google/instrumentation-java/forks","keys_url":"https://api.github.com/repos/google/instrumentation-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/instrumentation-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/instrumentation-java/teams","hooks_url":"https://api.github.com/repos/google/instrumentation-java/hooks","issue_events_url":"https://api.github.com/repos/google/instrumentation-java/issues/events{/number}","events_url":"https://api.github.com/repos/google/instrumentation-java/events","assignees_url":"https://api.github.com/repos/google/instrumentation-java/assignees{/user}","branches_url":"https://api.github.com/repos/google/instrumentation-java/branches{/branch}","tags_url":"https://api.github.com/repos/google/instrumentation-java/tags","blobs_url":"https://api.github.com/repos/google/instrumentation-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/instrumentation-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/instrumentation-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/instrumentation-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/instrumentation-java/statuses/{sha}","languages_url":"https://api.github.com/repos/google/instrumentation-java/languages","stargazers_url":"https://api.github.com/repos/google/instrumentation-java/stargazers","contributors_url":"https://api.github.com/repos/google/instrumentation-java/contributors","subscribers_url":"https://api.github.com/repos/google/instrumentation-java/subscribers","subscription_url":"https://api.github.com/repos/google/instrumentation-java/subscription","commits_url":"https://api.github.com/repos/google/instrumentation-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/instrumentation-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/instrumentation-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/instrumentation-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/instrumentation-java/contents/{+path}","compare_url":"https://api.github.com/repos/google/instrumentation-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/instrumentation-java/merges","archive_url":"https://api.github.com/repos/google/instrumentation-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/instrumentation-java/downloads","issues_url":"https://api.github.com/repos/google/instrumentation-java/issues{/number}","pulls_url":"https://api.github.com/repos/google/instrumentation-java/pulls{/number}","milestones_url":"https://api.github.com/repos/google/instrumentation-java/milestones{/number}","notifications_url":"https://api.github.com/repos/google/instrumentation-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/instrumentation-java/labels{/name}","releases_url":"https://api.github.com/repos/google/instrumentation-java/releases{/id}","deployments_url":"https://api.github.com/repos/google/instrumentation-java/deployments","created_at":"2016-07-28T22:10:03Z","updated_at":"2017-04-12T21:01:18Z","pushed_at":"2017-04-14T15:30:35Z","git_url":"git://github.com/google/instrumentation-java.git","ssh_url":"git@github.com:google/instrumentation-java.git","clone_url":"https://github.com/google/instrumentation-java.git","svn_url":"https://github.com/google/instrumentation-java","homepage":"","size":704,"stargazers_count":67,"watchers_count":67,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":26,"forks":24,"open_issues":26,"watchers":67,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/206"},"html":{"href":"https://github.com/google/instrumentation-java/pull/206"},"issue":{"href":"https://api.github.com/repos/google/instrumentation-java/issues/206"},"comments":{"href":"https://api.github.com/repos/google/instrumentation-java/issues/206/comments"},"review_comments":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/206/comments"},"review_comment":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/instrumentation-java/pulls/206/commits"},"statuses":{"href":"https://api.github.com/repos/google/instrumentation-java/statuses/a8385a758b2e5cd24e2f28739e7ba35f71578a2d"}}}}
{"actor":{"display_login":"bogdandrutu"}}