FrankChen021 commented on code in PR #20090:
URL: https://github.com/apache/druid/pull/20090#discussion_r3821777715


##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchBufferAggregatorHelper.java:
##########
@@ -38,8 +36,8 @@ final class SketchBufferAggregatorHelper
 {
   private final int size;
   private final int maxIntermediateSize;
-  private final IdentityHashMap<ByteBuffer, Int2ObjectMap<Union>> unions = new 
IdentityHashMap<>();
-  private final IdentityHashMap<ByteBuffer, WritableMemory> memCache = new 
IdentityHashMap<>();
+  private final ConcurrentHashMap<ByteBuffer, ConcurrentHashMap<Integer, 
Union>> unions = new ConcurrentHashMap<>();

Review Comment:
   [P1] Do not key caches by mutable ByteBuffers
   
   ConcurrentHashMap uses ByteBuffer.equals/hashCode, which depend on the 
buffer's remaining contents. Union updates mutate those contents in place, 
changing the key hash after insertion. Subsequent unions.get(buf) calls can 
miss and get() returns SketchHolder.EMPTY; distinct equal-content buffers can 
also alias. Preserve identity/stable-key semantics while making access 
concurrent.



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