[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7331: TDigest backed sketch aggregators

2019-05-09 Thread GitBox
samarthjain commented on a change in pull request #7331: TDigest backed sketch 
aggregators
URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r282698466
 
 

 ##
 File path: 
extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestBuildSketchBufferAggregator.java
 ##
 @@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.tdigestsketch;
+
+import com.google.common.base.Preconditions;
+import com.tdunning.math.stats.MergingDigest;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.query.aggregation.BufferAggregator;
+import org.apache.druid.segment.ColumnValueSelector;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
+import java.nio.ByteBuffer;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+/**
+ * Aggregator that builds t-digest backed sketches using numeric values read 
from {@link ByteBuffer}
+ */
+public class TDigestBuildSketchBufferAggregator implements BufferAggregator
+{
+
+  @Nonnull
+  private final ColumnValueSelector selector;
+  @Nonnull
+  private final int compression;
+
+  @GuardedBy("this")
+  private Map> sketches = new 
IdentityHashMap<>();
+
+  public TDigestBuildSketchBufferAggregator(
+  final ColumnValueSelector valueSelector,
+  final Integer compression
+  )
+  {
+Preconditions.checkNotNull(valueSelector);
+this.selector = valueSelector;
+if (compression != null) {
+  this.compression = compression;
+} else {
+  this.compression = TDigestBuildSketchAggregator.DEFAULT_COMPRESSION;
+}
+  }
+
+  @Override
+  public synchronized void init(ByteBuffer buffer, int position)
 
 Review comment:
   Thanks. I have made the change to synchronize access for get() and 
aggregate()


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7331: TDigest backed sketch aggregators

2019-05-08 Thread GitBox
samarthjain commented on a change in pull request #7331: TDigest backed sketch 
aggregators
URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r282275813
 
 

 ##
 File path: 
extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestBuildSketchBufferAggregator.java
 ##
 @@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.tdigestsketch;
+
+import com.google.common.base.Preconditions;
+import com.tdunning.math.stats.MergingDigest;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.query.aggregation.BufferAggregator;
+import org.apache.druid.segment.ColumnValueSelector;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
+import java.nio.ByteBuffer;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+/**
+ * Aggregator that builds t-digest backed sketches using numeric values read 
from {@link ByteBuffer}
+ */
+public class TDigestBuildSketchBufferAggregator implements BufferAggregator
+{
+
+  @Nonnull
+  private final ColumnValueSelector selector;
+  @Nonnull
+  private final int compression;
+
+  @GuardedBy("this")
+  private Map> sketches = new 
IdentityHashMap<>();
+
+  public TDigestBuildSketchBufferAggregator(
+  final ColumnValueSelector valueSelector,
+  final Integer compression
+  )
+  {
+Preconditions.checkNotNull(valueSelector);
+this.selector = valueSelector;
+if (compression != null) {
+  this.compression = compression;
+} else {
+  this.compression = TDigestBuildSketchAggregator.DEFAULT_COMPRESSION;
+}
+  }
+
+  @Override
+  public synchronized void init(ByteBuffer buffer, int position)
 
 Review comment:
   For clarity, when building an incremental index, are aggregators invoked? 
And is that BufferedAggregator or Aggregator. From your comments it sounds like 
we needn't worry about thread safety for BufferedAggregators but what about 
Aggregators? Looking at HistogramAggregator or HistogramBufferAggregator, I 
don't see any kind of synchronization.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7331: TDigest backed sketch aggregators

2019-05-08 Thread GitBox
samarthjain commented on a change in pull request #7331: TDigest backed sketch 
aggregators
URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r281958380
 
 

 ##
 File path: 
extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestBuildSketchBufferAggregator.java
 ##
 @@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.tdigestsketch;
+
+import com.google.common.base.Preconditions;
+import com.tdunning.math.stats.MergingDigest;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.query.aggregation.BufferAggregator;
+import org.apache.druid.segment.ColumnValueSelector;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
+import java.nio.ByteBuffer;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+/**
+ * Aggregator that builds t-digest backed sketches using numeric values read 
from {@link ByteBuffer}
+ */
+public class TDigestBuildSketchBufferAggregator implements BufferAggregator
+{
+
+  @Nonnull
+  private final ColumnValueSelector selector;
+  @Nonnull
+  private final int compression;
+
+  @GuardedBy("this")
+  private Map> sketches = new 
IdentityHashMap<>();
+
+  public TDigestBuildSketchBufferAggregator(
+  final ColumnValueSelector valueSelector,
+  final Integer compression
+  )
+  {
+Preconditions.checkNotNull(valueSelector);
+this.selector = valueSelector;
+if (compression != null) {
+  this.compression = compression;
+} else {
+  this.compression = TDigestBuildSketchAggregator.DEFAULT_COMPRESSION;
+}
+  }
+
+  @Override
+  public synchronized void init(ByteBuffer buffer, int position)
 
 Review comment:
   @jihoonson - unfortunately the documentation on the base classes/interfaces 
doesn't clearly mention which methods could be called in a multi-threaded 
fashion. So I ended up following what the DataSketches implementation does. 
   For ex - 
   
https://github.com/apache/incubator-druid/blob/master/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildBufferAggregator.java#L54
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7331: TDigest backed sketch aggregators

2019-05-08 Thread GitBox
samarthjain commented on a change in pull request #7331: TDigest backed sketch 
aggregators
URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r281958692
 
 

 ##
 File path: 
extensions-contrib/tdigestsketch/src/test/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestSketchAggregatorTest.java
 ##
 @@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.query.aggregation.tdigestsketch;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.data.input.Row;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.java.util.common.granularity.Granularities;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.query.aggregation.AggregationTestHelper;
+import org.apache.druid.query.aggregation.AggregatorFactory;
+import org.apache.druid.query.groupby.GroupByQueryConfig;
+import org.apache.druid.query.groupby.GroupByQueryRunnerTest;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@RunWith(Parameterized.class)
+public class TDigestSketchAggregatorTest
+{
+
+  private final AggregationTestHelper helper;
+  private final AggregationTestHelper timeSeriesHelper;
 
 Review comment:
   Done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



[GitHub] [incubator-druid] samarthjain commented on a change in pull request #7331: TDigest backed sketch aggregators

2019-04-24 Thread GitBox
samarthjain commented on a change in pull request #7331: TDigest backed sketch 
aggregators
URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r278349065
 
 

 ##
 File path: distribution/pom.xml
 ##
 @@ -333,6 +333,8 @@
 
org.apache.druid.extensions.contrib:druid-time-min-max
 -c
 
org.apache.druid.extensions.contrib:druid-virtual-columns
+-c
+
io.druid.extensions.contrib:druid-tdigestsketch
 
 Review comment:
   Ah! I initially built this against 0.12.2 since that is what we use at my 
day job. Fixed. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org