leerho commented on issue #478:
URL: 
https://github.com/apache/datasketches-java/issues/478#issuecomment-1839817734

   1. `HllSketch.wrap(mem)` has more checks because it must handle the cases 
where the sketch is not empty.  And even if it is empty it must create a valid 
Direct Sketch with a reference to the empty memory object.  From my 
understanding of what your issue is, you just want to check if the sketch is 
empty and abort from that path as quickly as possible to look at the next 
sketch (for example).  
   
   2. WRT the binary approach:  This simple test assumes:
       - That your ByteBuffer image has the sketch image starting with byte 0 
of the BB.  I.e., there is nothing in front of the start of the sketch!  
       - There has been no modification to the sketch image contained in the BB.
       - If this is true, then the simple test I gave you will **always** work. 
   
   4. One more possible check: **If, and only if,** the capacity of the BB is 
exactly the size of the sketch image, AND the sketch has been serialized into 
its compact form; i.e., the sketch image was created by 
`sketch.toCompactByteArray()` then all you need to do is check the size of the 
ByteBuffer:  if (byteBuffer.capacity() == 8) { /\*the sketch is guaranteed to 
be empty!\*/ } 
   
   


-- 
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