Skip to content

Commit

Permalink
[core] fix hll class not found (apache#4025)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranxianglei authored Aug 21, 2024
1 parent 24d8a3b commit a21e0f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@
import org.apache.paimon.annotation.VisibleForTesting;

import org.apache.datasketches.hll.HllSketch;
import org.apache.datasketches.hll.TgtHllType;
import org.apache.datasketches.hll.Union;

/** A compressed bitmap for 32-bit integer. */
public class HllSketchUtil {

public static byte[] union(byte[] sketchBytes1, byte[] sketchBytes2) {
HllSketch heapify = HllSketch.heapify((byte[]) sketchBytes1);
org.apache.datasketches.hll.Union union = Union.heapify((byte[]) sketchBytes2);
union.update(heapify);
HllSketch result = union.getResult(TgtHllType.HLL_4);
return result.toCompactByteArray();
}

@VisibleForTesting
public static byte[] sketchOf(int... values) {
HllSketch hllSketch = new HllSketch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
package org.apache.paimon.mergetree.compact.aggregate;

import org.apache.paimon.types.VarBinaryType;

import org.apache.datasketches.hll.HllSketch;
import org.apache.datasketches.hll.TgtHllType;
import org.apache.datasketches.hll.Union;
import org.apache.paimon.utils.HllSketchUtil;

/** HllSketch aggregate a field of a row. */
public class FieldHllSketchAgg extends FieldAggregator {
Expand Down Expand Up @@ -50,10 +47,6 @@ public Object agg(Object accumulator, Object inputField) {
return accumulator == null ? inputField : accumulator;
}

HllSketch heapify = HllSketch.heapify((byte[]) accumulator);
Union union = Union.heapify((byte[]) inputField);
union.update(heapify);
HllSketch result = union.getResult(TgtHllType.HLL_4);
return result.toCompactByteArray();
return HllSketchUtil.union((byte[]) accumulator, (byte[]) inputField);
}
}

0 comments on commit a21e0f4

Please sign in to comment.