Jackie-Jiang commented on code in PR #11346: URL: https://github.com/apache/pinot/pull/11346#discussion_r1328143364
########## pinot-core/src/main/java/org/apache/pinot/core/common/ObjectSerDeUtils.java: ########## @@ -554,6 +559,35 @@ private HyperLogLog deserialize(IntBuffer intBuffer) { } }; + public static final ObjectSerDe<HyperLogLogPlus> HYPER_LOG_LOG_PLUS_SER_DE = new ObjectSerDe<HyperLogLogPlus>() { + + @Override + public byte[] serialize(HyperLogLogPlus hyperLogLogPlus) { + try { + return hyperLogLogPlus.getBytes(); + } catch (IOException e) { + throw new RuntimeException("Caught exception while serializing HyperLogLogPlus", e); + } + } + + @Override + public HyperLogLogPlus deserialize(byte[] bytes) { + try { + return HyperLogLogPlus.Builder.build(bytes); + } catch (IOException e) { + throw new RuntimeException("Caught exception while serializing HyperLogLogPlus", e); + } + } + + @Override + public HyperLogLogPlus deserialize(ByteBuffer byteBuffer) { + // NOTE: The passed in byte buffer is always BIG ENDIAN Review Comment: (minor) Remove this comment as it doesn't apply ########## pinot-core/src/main/java/org/apache/pinot/core/operator/query/NonScanBasedAggregationOperator.java: ########## @@ -233,6 +256,25 @@ private static HyperLogLog getDistinctCountHLLResult(Dictionary dictionary, } } + private static HyperLogLogPlus getDistinctCountHLLPlusResult(Dictionary dictionary, + DistinctCountHLLPlusAggregationFunction function) { + if (dictionary.getValueType() == FieldSpec.DataType.BYTES) { + // Treat BYTES value as serialized HyperLogLog + try { + HyperLogLogPlus hllplus = ObjectSerDeUtils.HYPER_LOG_LOG_PLUS_SER_DE.deserialize(dictionary.getBytesValue(0)); + int length = dictionary.length(); + for (int i = 1; i < length; i++) { + hllplus.addAll(ObjectSerDeUtils.HYPER_LOG_LOG_PLUS_SER_DE.deserialize(dictionary.getBytesValue(i))); + } + return hllplus; + } catch (Exception e) { + throw new RuntimeException("Caught exception while merging HyperLogLogs", e); Review Comment: (minor) Revise the message ########## pinot-core/src/main/java/org/apache/pinot/core/operator/query/NonScanBasedAggregationOperator.java: ########## @@ -233,6 +256,25 @@ private static HyperLogLog getDistinctCountHLLResult(Dictionary dictionary, } } + private static HyperLogLogPlus getDistinctCountHLLPlusResult(Dictionary dictionary, + DistinctCountHLLPlusAggregationFunction function) { + if (dictionary.getValueType() == FieldSpec.DataType.BYTES) { + // Treat BYTES value as serialized HyperLogLog Review Comment: (minor) Revise the comment ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/CustomSerDeUtils.java: ########## @@ -188,6 +189,38 @@ public HyperLogLog deserialize(ByteBuffer byteBuffer) { } }; + public static final ObjectSerDe<HyperLogLogPlus> HYPER_LOG_LOG_PLUS_SER_DE = new ObjectSerDe<HyperLogLogPlus>() { + + @Override + public byte[] serialize(HyperLogLogPlus hyperLogLogPlus) { + try { + return hyperLogLogPlus.getBytes(); + } catch (IOException e) { + throw new RuntimeException("Caught exception while serializing HyperLogLogPlus", e); + } + } + + @Override + public HyperLogLogPlus deserialize(byte[] bytes) { + try { + return HyperLogLogPlus.Builder.build(bytes); + } catch (IOException e) { + throw new RuntimeException("Caught exception while de-serializing HyperLogLogPlus", e); + } + } + + @Override + public HyperLogLogPlus deserialize(ByteBuffer byteBuffer) { + byte[] bytes = new byte[byteBuffer.remaining()]; + byteBuffer.get(bytes); + try { + return HyperLogLogPlus.Builder.build(bytes); + } catch (IOException e) { + throw new RuntimeException("Caught exception while de-serializing HyperLogLogPlus", e); + } Review Comment: ```suggestion return deserialize(bytes); ``` -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org