You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/02/13 00:25:28 UTC

[GitHub] amansinha100 commented on a change in pull request #729: Drill 1328: Support table statistics for Parquet

amansinha100 commented on a change in pull request #729: Drill 1328: Support table statistics for Parquet
URL: https://github.com/apache/drill/pull/729#discussion_r256195822
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StatisticsAggrFunctions.java
 ##########
 @@ -5513,4 +5514,1517 @@ public void reset() {
       nonNullCount.value = 0;
     }
   }
+
+  @FunctionTemplate(name = "approx_count_dups", scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+  public static class BitCntDupsFunction implements DrillAggFunc {
+    @Param
+    BitHolder in;
+    @Workspace
+    ObjectHolder work;
+    @Workspace BigIntHolder dups;
+    @Output NullableBigIntHolder out;
+    @Inject OptionManager options;
+    @Workspace IntHolder ndvBloomFilterElts;
+    @Workspace IntHolder ndvBloomFilterFPProb;
+
+    @Override
+    public void setup() {
+      work = new ObjectHolder();
+      ndvBloomFilterElts.value = (int) options.getLong(org.apache.drill.exec.ExecConstants.NDV_BLOOM_FILTER_ELEMENTS);
+      ndvBloomFilterFPProb.value = (int) options.getLong(org.apache.drill.exec.ExecConstants.NDV_BLOOM_FILTER_FPOS_PROB);
+      work.obj = new com.clearspring.analytics.stream.membership.BloomFilter(ndvBloomFilterElts.value, ndvBloomFilterFPProb.value);
+    }
+
+    @Override
+    public void add() {
+      if (work.obj != null) {
+        com.clearspring.analytics.stream.membership.BloomFilter filter =
+                (com.clearspring.analytics.stream.membership.BloomFilter ) work.obj;
+        if (!filter.isPresent(String.valueOf(in.value))) {
+          filter.add(String.valueOf(in.value));
+        } else {
+          dups.value++;
+        }
+      }
+    }
+
+    @Override
+    public void output() {
+      if (work.obj != null) {
+        com.clearspring.analytics.stream.membership.BloomFilter filter =
+                (com.clearspring.analytics.stream.membership.BloomFilter ) work.obj;
+        out.isSet = 1;
+        out.value = dups.value;
+      } else {
+        out.isSet = 0;
+      }
+    }
+
+    @Override
+    public void reset() {
 
 Review comment:
   reset() should reset dups.value = 0

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


With regards,
Apache Git Services