{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/171968971","pull_request_review_id":100921132,"id":171968971,"diff_hunk":"@@ -0,0 +1,76 @@\n+/*\n+ * Licensed to Metamarkets Group Inc. (Metamarkets) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. Metamarkets 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+\n+package io.druid.query.aggregation.datasketches.tuple;\n+\n+import com.yahoo.sketches.tuple.ArrayOfDoublesSetOperationBuilder;\n+import com.yahoo.sketches.tuple.ArrayOfDoublesSketch;\n+import com.yahoo.sketches.tuple.ArrayOfDoublesUnion;\n+import io.druid.query.aggregation.Aggregator;\n+import io.druid.segment.BaseObjectColumnValueSelector;\n+\n+public class ArrayOfDoublesSketchMergeAggregator implements Aggregator\n+{\n+\n+  private final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector;\n+  private ArrayOfDoublesUnion union;\n+\n+  public ArrayOfDoublesSketchMergeAggregator(final BaseObjectColumnValueSelector<ArrayOfDoublesSketch> selector,\n+      final int nominalEntries, final int numberOfValues)\n+  {\n+    this.selector = selector;\n+    union = new ArrayOfDoublesSetOperationBuilder().setNominalEntries(nominalEntries).setNumberOfValues(numberOfValues)\n+        .buildUnion();\n+  }\n+\n+  @Override\n+  public synchronized void aggregate()\n+  {\n+    final ArrayOfDoublesSketch update = selector.getObject();\n+    if (update == null) {\n+      return;\n+    }\n+    union.update(update);\n+  }\n+\n+  @Override\n+  public synchronized Object get()","path":"extensions-core/datasketches/src/main/java/io/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchMergeAggregator.java","position":56,"original_position":53,"commit_id":"33d9bcbf85691fa5ebba239db1a9d79b55a10d72","original_commit_id":"7b16e72674866707dabb6903553f2e089c71f142","user":{"login":"leventov","id":609240,"avatar_url":"https://avatars0.githubusercontent.com/u/609240?v=4","gravatar_id":"","url":"https://api.github.com/users/leventov","html_url":"https://github.com/leventov","followers_url":"https://api.github.com/users/leventov/followers","following_url":"https://api.github.com/users/leventov/following{/other_user}","gists_url":"https://api.github.com/users/leventov/gists{/gist_id}","starred_url":"https://api.github.com/users/leventov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leventov/subscriptions","organizations_url":"https://api.github.com/users/leventov/orgs","repos_url":"https://api.github.com/users/leventov/repos","events_url":"https://api.github.com/users/leventov/events{/privacy}","received_events_url":"https://api.github.com/users/leventov/received_events","type":"User","site_admin":false},"body":"However no, this is all wrong, sorry for confusion.\r\n\r\n`synchronized` on `get()` is pointless, because it's not where the returned object is actually used. Something like\r\n```java\r\nsynchronized T get() {\r\n  return object.clone();\r\n}\r\n```\r\nwould work, but it's bad for performance. What should really be done is some method like `with(Consumer<T>)` added to `Aggregator` interface, but it means overhaul of the whole API and processing engine, definitely not the subject for this PR.\r\n\r\nAnd since `synchronized` on `get()` is pointless, `synchronized` on `aggregate()` is pointless too, because there are no concurrent updates from multiple writers, there is only read (get) / write (aggregate) concurrency.\r\n\r\nSo as of this PR, I suggest to remove all `synchronized`. This issue should be tackled separately.","created_at":"2018-03-02T21:35:34Z","updated_at":"2018-03-02T21:35:34Z","html_url":"https://github.com/druid-io/druid/pull/5148#discussion_r171968971","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/5148","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/171968971"},"html":{"href":"https://github.com/druid-io/druid/pull/5148#discussion_r171968971"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5148"}},"in_reply_to_id":170906998},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/5148","id":157367391,"html_url":"https://github.com/druid-io/druid/pull/5148","diff_url":"https://github.com/druid-io/druid/pull/5148.diff","patch_url":"https://github.com/druid-io/druid/pull/5148.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/5148","number":5148,"state":"open","locked":false,"title":"ArrayOfDoublesSketch module","user":{"login":"AlexanderSaydakov","id":13126686,"avatar_url":"https://avatars2.githubusercontent.com/u/13126686?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexanderSaydakov","html_url":"https://github.com/AlexanderSaydakov","followers_url":"https://api.github.com/users/AlexanderSaydakov/followers","following_url":"https://api.github.com/users/AlexanderSaydakov/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderSaydakov/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderSaydakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderSaydakov/subscriptions","organizations_url":"https://api.github.com/users/AlexanderSaydakov/orgs","repos_url":"https://api.github.com/users/AlexanderSaydakov/repos","events_url":"https://api.github.com/users/AlexanderSaydakov/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderSaydakov/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-09T01:53:38Z","updated_at":"2018-03-02T21:35:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc0941e9d5336f7ad88690d12cffade6b77017d8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/5148/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/5148/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/5148/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/33d9bcbf85691fa5ebba239db1a9d79b55a10d72","head":{"label":"AlexanderSaydakov:tuple-sketch-aggregator","ref":"tuple-sketch-aggregator","sha":"33d9bcbf85691fa5ebba239db1a9d79b55a10d72","user":{"login":"AlexanderSaydakov","id":13126686,"avatar_url":"https://avatars2.githubusercontent.com/u/13126686?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexanderSaydakov","html_url":"https://github.com/AlexanderSaydakov","followers_url":"https://api.github.com/users/AlexanderSaydakov/followers","following_url":"https://api.github.com/users/AlexanderSaydakov/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderSaydakov/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderSaydakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderSaydakov/subscriptions","organizations_url":"https://api.github.com/users/AlexanderSaydakov/orgs","repos_url":"https://api.github.com/users/AlexanderSaydakov/repos","events_url":"https://api.github.com/users/AlexanderSaydakov/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderSaydakov/received_events","type":"User","site_admin":false},"repo":{"id":87870285,"name":"druid","full_name":"AlexanderSaydakov/druid","owner":{"login":"AlexanderSaydakov","id":13126686,"avatar_url":"https://avatars2.githubusercontent.com/u/13126686?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexanderSaydakov","html_url":"https://github.com/AlexanderSaydakov","followers_url":"https://api.github.com/users/AlexanderSaydakov/followers","following_url":"https://api.github.com/users/AlexanderSaydakov/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderSaydakov/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderSaydakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderSaydakov/subscriptions","organizations_url":"https://api.github.com/users/AlexanderSaydakov/orgs","repos_url":"https://api.github.com/users/AlexanderSaydakov/repos","events_url":"https://api.github.com/users/AlexanderSaydakov/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderSaydakov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlexanderSaydakov/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/AlexanderSaydakov/druid","forks_url":"https://api.github.com/repos/AlexanderSaydakov/druid/forks","keys_url":"https://api.github.com/repos/AlexanderSaydakov/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlexanderSaydakov/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlexanderSaydakov/druid/teams","hooks_url":"https://api.github.com/repos/AlexanderSaydakov/druid/hooks","issue_events_url":"https://api.github.com/repos/AlexanderSaydakov/druid/issues/events{/number}","events_url":"https://api.github.com/repos/AlexanderSaydakov/druid/events","assignees_url":"https://api.github.com/repos/AlexanderSaydakov/druid/assignees{/user}","branches_url":"https://api.github.com/repos/AlexanderSaydakov/druid/branches{/branch}","tags_url":"https://api.github.com/repos/AlexanderSaydakov/druid/tags","blobs_url":"https://api.github.com/repos/AlexanderSaydakov/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlexanderSaydakov/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlexanderSaydakov/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlexanderSaydakov/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlexanderSaydakov/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/AlexanderSaydakov/druid/languages","stargazers_url":"https://api.github.com/repos/AlexanderSaydakov/druid/stargazers","contributors_url":"https://api.github.com/repos/AlexanderSaydakov/druid/contributors","subscribers_url":"https://api.github.com/repos/AlexanderSaydakov/druid/subscribers","subscription_url":"https://api.github.com/repos/AlexanderSaydakov/druid/subscription","commits_url":"https://api.github.com/repos/AlexanderSaydakov/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlexanderSaydakov/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlexanderSaydakov/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlexanderSaydakov/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlexanderSaydakov/druid/contents/{+path}","compare_url":"https://api.github.com/repos/AlexanderSaydakov/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlexanderSaydakov/druid/merges","archive_url":"https://api.github.com/repos/AlexanderSaydakov/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlexanderSaydakov/druid/downloads","issues_url":"https://api.github.com/repos/AlexanderSaydakov/druid/issues{/number}","pulls_url":"https://api.github.com/repos/AlexanderSaydakov/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/AlexanderSaydakov/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/AlexanderSaydakov/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlexanderSaydakov/druid/labels{/name}","releases_url":"https://api.github.com/repos/AlexanderSaydakov/druid/releases{/id}","deployments_url":"https://api.github.com/repos/AlexanderSaydakov/druid/deployments","created_at":"2017-04-11T00:30:46Z","updated_at":"2017-04-11T00:30:59Z","pushed_at":"2018-03-02T20:16:32Z","git_url":"git://github.com/AlexanderSaydakov/druid.git","ssh_url":"git@github.com:AlexanderSaydakov/druid.git","clone_url":"https://github.com/AlexanderSaydakov/druid.git","svn_url":"https://github.com/AlexanderSaydakov/druid","homepage":"http://druid.io","size":131425,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"61e6878afdb9cbcde37effe0742dc7e8ecb1d975","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars0.githubusercontent.com/u/4203474?v=4","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars0.githubusercontent.com/u/4203474?v=4","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","deployments_url":"https://api.github.com/repos/druid-io/druid/deployments","created_at":"2012-10-23T19:08:07Z","updated_at":"2018-03-02T09:47:30Z","pushed_at":"2018-03-02T20:48:49Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":135098,"stargazers_count":6152,"watchers_count":6152,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1516,"mirror_url":null,"archived":false,"open_issues_count":933,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1516,"open_issues":933,"watchers":6152,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5148"},"html":{"href":"https://github.com/druid-io/druid/pull/5148"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/5148"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/5148/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5148/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5148/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/33d9bcbf85691fa5ebba239db1a9d79b55a10d72"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"leventov"}}