loquisgon commented on a change in pull request #10685: URL: https://github.com/apache/druid/pull/10685#discussion_r552811029
########## File path: processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ByteBufferMinMaxOffsetHeap.java ########## @@ -59,6 +60,35 @@ public ByteBufferMinMaxOffsetHeap( this.heapIndexUpdater = heapIndexUpdater; } + public ByteBufferMinMaxOffsetHeap copy() + { + LimitedBufferHashGrouper.BufferGrouperOffsetHeapIndexUpdater updater = + Optional + .ofNullable(heapIndexUpdater) + .map(LimitedBufferHashGrouper.BufferGrouperOffsetHeapIndexUpdater::copy) + .orElse(null); + + // deep copy buf + ByteBuffer buffer = ByteBuffer.allocateDirect(buf.capacity()); + + int bufPosition = buf.position(); + int bufLimit = buf.limit(); + buf.rewind(); + + buffer.put(buf); + buffer.position(bufPosition); + buffer.limit(bufLimit); + + buf.position(bufPosition); + buf.limit(bufLimit); Review comment: Yeah, agreed. Code should be refactored to abstract out the duplicated block. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org