adarshsanjeev commented on code in PR #15162:
URL: https://github.com/apache/druid/pull/15162#discussion_r1363217612


##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchHolderObjectStrategy.java:
##########
@@ -48,12 +49,18 @@ public int compare(final HllSketchHolder sketch1, final 
HllSketchHolder sketch2)
   @Override
   public HllSketchHolder fromByteBuffer(final ByteBuffer buf, final int size)
   {
+    if (size == 0 || isSafeToConvertToNullSketch(buf)) {
+      return HllSketchHolder.of((HllSketch) null);
+    }
     return HllSketchHolder.of(HllSketch.wrap(Memory.wrap(buf, 
ByteOrder.LITTLE_ENDIAN).region(buf.position(), size)));
   }
 
   @Override
   public byte[] toBytes(final HllSketchHolder sketch)
   {
+    if (sketch.getSketch() == null || sketch.getSketch().isEmpty()) {

Review Comment:
   Good callout! I think I missed this initially. I'll try to make sure that I 
stick to this in the future.
   Also, renamed the holder parameter.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to