{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/206328302","pull_request_review_id":141724442,"id":206328302,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjMyODMwMg==","diff_hunk":"@@ -0,0 +1,151 @@\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.first;\n+\n+import io.druid.java.util.common.StringUtils;\n+import io.druid.query.aggregation.BufferAggregator;\n+import io.druid.query.aggregation.SerializablePairLongString;\n+import io.druid.query.monomorphicprocessing.RuntimeShapeInspector;\n+import io.druid.segment.BaseLongColumnValueSelector;\n+import io.druid.segment.BaseObjectColumnValueSelector;\n+\n+import java.nio.ByteBuffer;\n+\n+// TODO: Unit Test\n+public class StringFirstBufferAggregator implements BufferAggregator\n+{\n+  private final BaseLongColumnValueSelector timeSelector;\n+  private final BaseObjectColumnValueSelector valueSelector;\n+  private final int maxStringBytes;\n+\n+  public StringFirstBufferAggregator(\n+      BaseLongColumnValueSelector timeSelector,\n+      BaseObjectColumnValueSelector valueSelector,\n+      int maxStringBytes\n+  )\n+  {\n+    this.timeSelector = timeSelector;\n+    this.valueSelector = valueSelector;\n+    this.maxStringBytes = maxStringBytes;\n+  }\n+\n+  @Override\n+  public void init(ByteBuffer buf, int position)\n+  {\n+    buf.putLong(position, Long.MAX_VALUE);\n+    buf.putInt(position + Long.BYTES, 0);\n+  }\n+\n+  @Override\n+  public void aggregate(ByteBuffer buf, int position)\n+  {\n+    ByteBuffer mutationBuffer = buf.duplicate();\n+    mutationBuffer.position(position);\n+\n+    Object value = valueSelector.getObject();\n+\n+    long time = Long.MAX_VALUE;\n+    String firstString = null;\n+\n+    if (value instanceof SerializablePairLongString) {\n+      SerializablePairLongString serializablePair = (SerializablePairLongString) value;\n+      time = serializablePair.lhs;\n+      firstString = serializablePair.rhs;\n+    } else if (value instanceof String) {\n+      time = timeSelector.getLong();\n+      firstString = (String) value;\n+    } else if (value != null) {\n+      throw new IllegalStateException(\n+          \"Try to aggregate unsuported class type [\"\n+          + value.getClass().getName() +\n+          \"]. Supported class types: String or SerializablePairLongString\"\n+      );\n+    }\n+\n+    long lastTime = mutationBuffer.getLong(position);\n+    if (firstString != null && time < lastTime) {","path":"processing/src/main/java/io/druid/query/aggregation/first/StringFirstBufferAggregator.java","position":null,"original_position":83,"commit_id":"7ff6fc30e01684bbe56afbdefd81f473d79b669e","original_commit_id":"9829263e7344b551904ec9eba5aab732d121e311","user":{"login":"andresgomezfrr","id":4025771,"node_id":"MDQ6VXNlcjQwMjU3NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/4025771?v=4","gravatar_id":"","url":"https://api.github.com/users/andresgomezfrr","html_url":"https://github.com/andresgomezfrr","followers_url":"https://api.github.com/users/andresgomezfrr/followers","following_url":"https://api.github.com/users/andresgomezfrr/following{/other_user}","gists_url":"https://api.github.com/users/andresgomezfrr/gists{/gist_id}","starred_url":"https://api.github.com/users/andresgomezfrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andresgomezfrr/subscriptions","organizations_url":"https://api.github.com/users/andresgomezfrr/orgs","repos_url":"https://api.github.com/users/andresgomezfrr/repos","events_url":"https://api.github.com/users/andresgomezfrr/events{/privacy}","received_events_url":"https://api.github.com/users/andresgomezfrr/received_events","type":"User","site_admin":false},"body":"But can you use the filters at indexing time? \r\n\r\nBecause if the aggregator at the indexing time tries to index the `minute: 1.4, client: AAA, location: null`. This message discards the lastValue and the client: AAA has `null`location to `minute: 1`, because of the queryGranularity=MINUTE.","created_at":"2018-07-30T21:29:09Z","updated_at":"2018-07-30T21:29:09Z","html_url":"https://github.com/apache/incubator-druid/pull/5789#discussion_r206328302","pull_request_url":"https://api.github.com/repos/apache/incubator-druid/pulls/5789","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/206328302"},"html":{"href":"https://github.com/apache/incubator-druid/pull/5789#discussion_r206328302"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/5789"}},"in_reply_to_id":194274258},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/5789","id":189235197,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg5MjM1MTk3","html_url":"https://github.com/apache/incubator-druid/pull/5789","diff_url":"https://github.com/apache/incubator-druid/pull/5789.diff","patch_url":"https://github.com/apache/incubator-druid/pull/5789.patch","issue_url":"https://api.github.com/repos/apache/incubator-druid/issues/5789","number":5789,"state":"open","locked":false,"title":"Add stringLast and stringFirst aggregators extension","user":{"login":"andresgomezfrr","id":4025771,"node_id":"MDQ6VXNlcjQwMjU3NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/4025771?v=4","gravatar_id":"","url":"https://api.github.com/users/andresgomezfrr","html_url":"https://github.com/andresgomezfrr","followers_url":"https://api.github.com/users/andresgomezfrr/followers","following_url":"https://api.github.com/users/andresgomezfrr/following{/other_user}","gists_url":"https://api.github.com/users/andresgomezfrr/gists{/gist_id}","starred_url":"https://api.github.com/users/andresgomezfrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andresgomezfrr/subscriptions","organizations_url":"https://api.github.com/users/andresgomezfrr/orgs","repos_url":"https://api.github.com/users/andresgomezfrr/repos","events_url":"https://api.github.com/users/andresgomezfrr/events{/privacy}","received_events_url":"https://api.github.com/users/andresgomezfrr/received_events","type":"User","site_admin":false},"body":"Hi all,\r\n\r\nThis PR contains a druid extension module that adds a `stringLast` & `stringFirst` aggregators. ","created_at":"2018-05-20T14:04:54Z","updated_at":"2018-07-30T21:29:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a62b07caffb47ec0eaa6a50b616f707e9bbd0ca","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-druid/pulls/5789/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-druid/pulls/5789/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-druid/issues/5789/comments","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/7ff6fc30e01684bbe56afbdefd81f473d79b669e","head":{"label":"wizzie-io:feature-first-last-string-aggregators","ref":"feature-first-last-string-aggregators","sha":"7ff6fc30e01684bbe56afbdefd81f473d79b669e","user":{"login":"wizzie-io","id":20482219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDgyMjE5","avatar_url":"https://avatars1.githubusercontent.com/u/20482219?v=4","gravatar_id":"","url":"https://api.github.com/users/wizzie-io","html_url":"https://github.com/wizzie-io","followers_url":"https://api.github.com/users/wizzie-io/followers","following_url":"https://api.github.com/users/wizzie-io/following{/other_user}","gists_url":"https://api.github.com/users/wizzie-io/gists{/gist_id}","starred_url":"https://api.github.com/users/wizzie-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wizzie-io/subscriptions","organizations_url":"https://api.github.com/users/wizzie-io/orgs","repos_url":"https://api.github.com/users/wizzie-io/repos","events_url":"https://api.github.com/users/wizzie-io/events{/privacy}","received_events_url":"https://api.github.com/users/wizzie-io/received_events","type":"Organization","site_admin":false},"repo":{"id":134008811,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQwMDg4MTE=","name":"druid","full_name":"wizzie-io/druid","owner":{"login":"wizzie-io","id":20482219,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDgyMjE5","avatar_url":"https://avatars1.githubusercontent.com/u/20482219?v=4","gravatar_id":"","url":"https://api.github.com/users/wizzie-io","html_url":"https://github.com/wizzie-io","followers_url":"https://api.github.com/users/wizzie-io/followers","following_url":"https://api.github.com/users/wizzie-io/following{/other_user}","gists_url":"https://api.github.com/users/wizzie-io/gists{/gist_id}","starred_url":"https://api.github.com/users/wizzie-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wizzie-io/subscriptions","organizations_url":"https://api.github.com/users/wizzie-io/orgs","repos_url":"https://api.github.com/users/wizzie-io/repos","events_url":"https://api.github.com/users/wizzie-io/events{/privacy}","received_events_url":"https://api.github.com/users/wizzie-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wizzie-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/wizzie-io/druid","forks_url":"https://api.github.com/repos/wizzie-io/druid/forks","keys_url":"https://api.github.com/repos/wizzie-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wizzie-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wizzie-io/druid/teams","hooks_url":"https://api.github.com/repos/wizzie-io/druid/hooks","issue_events_url":"https://api.github.com/repos/wizzie-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/wizzie-io/druid/events","assignees_url":"https://api.github.com/repos/wizzie-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/wizzie-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/wizzie-io/druid/tags","blobs_url":"https://api.github.com/repos/wizzie-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wizzie-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wizzie-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/wizzie-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wizzie-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/wizzie-io/druid/languages","stargazers_url":"https://api.github.com/repos/wizzie-io/druid/stargazers","contributors_url":"https://api.github.com/repos/wizzie-io/druid/contributors","subscribers_url":"https://api.github.com/repos/wizzie-io/druid/subscribers","subscription_url":"https://api.github.com/repos/wizzie-io/druid/subscription","commits_url":"https://api.github.com/repos/wizzie-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/wizzie-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/wizzie-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/wizzie-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/wizzie-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/wizzie-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wizzie-io/druid/merges","archive_url":"https://api.github.com/repos/wizzie-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wizzie-io/druid/downloads","issues_url":"https://api.github.com/repos/wizzie-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/wizzie-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/wizzie-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/wizzie-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wizzie-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/wizzie-io/druid/releases{/id}","deployments_url":"https://api.github.com/repos/wizzie-io/druid/deployments","created_at":"2018-05-18T22:12:55Z","updated_at":"2018-07-06T15:33:20Z","pushed_at":"2018-07-30T07:51:12Z","git_url":"git://github.com/wizzie-io/druid.git","ssh_url":"git@github.com:wizzie-io/druid.git","clone_url":"https://github.com/wizzie-io/druid.git","svn_url":"https://github.com/wizzie-io/druid","homepage":"http://druid.io","size":139280,"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":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"94d6c9a0a577888a071789285b8c34c02a739103","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":6358188,"node_id":"MDEwOlJlcG9zaXRvcnk2MzU4MTg4","name":"incubator-druid","full_name":"apache/incubator-druid","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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-druid","description":"Apache Druid (Incubating) - Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/apache/incubator-druid","forks_url":"https://api.github.com/repos/apache/incubator-druid/forks","keys_url":"https://api.github.com/repos/apache/incubator-druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-druid/teams","hooks_url":"https://api.github.com/repos/apache/incubator-druid/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-druid/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-druid/events","assignees_url":"https://api.github.com/repos/apache/incubator-druid/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-druid/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-druid/tags","blobs_url":"https://api.github.com/repos/apache/incubator-druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-druid/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-druid/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-druid/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-druid/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-druid/subscription","commits_url":"https://api.github.com/repos/apache/incubator-druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-druid/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-druid/merges","archive_url":"https://api.github.com/repos/apache/incubator-druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-druid/downloads","issues_url":"https://api.github.com/repos/apache/incubator-druid/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-druid/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-druid/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-druid/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-druid/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-druid/deployments","created_at":"2012-10-23T19:08:07Z","updated_at":"2018-07-30T21:07:57Z","pushed_at":"2018-07-30T21:07:34Z","git_url":"git://github.com/apache/incubator-druid.git","ssh_url":"git@github.com:apache/incubator-druid.git","clone_url":"https://github.com/apache/incubator-druid.git","svn_url":"https://github.com/apache/incubator-druid","homepage":"http://druid.io","size":141621,"stargazers_count":6809,"watchers_count":6809,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1673,"mirror_url":null,"archived":false,"open_issues_count":1117,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1673,"open_issues":1117,"watchers":6809,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/5789"},"html":{"href":"https://github.com/apache/incubator-druid/pull/5789"},"issue":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/5789"},"comments":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/5789/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/5789/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/5789/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-druid/statuses/7ff6fc30e01684bbe56afbdefd81f473d79b669e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"andresgomezfrr"}}