YutSean commented on a change in pull request #3964:
URL: https://github.com/apache/hbase/pull/3964#discussion_r772866871
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CellBlockBuilder.java
##########
@@ -294,14 +296,15 @@ private ByteBuffer decompress(CompressionCodec
compressor, InputStream cellBlock
}
Decompressor poolDecompressor = CodecPool.getDecompressor(compressor);
CompressionInputStream cis = compressor.createInputStream(cellBlockStream,
poolDecompressor);
- ByteBufferOutputStream bbos;
try {
// TODO: This is ugly. The buffer will be resized on us if we guess
wrong.
- // TODO: Reuse buffers.
- bbos = new ByteBufferOutputStream(osInitialSize);
- IOUtils.copy(cis, bbos);
- bbos.close();
- return bbos.getByteBuffer();
+ if (this.decompressBuff.get() == null) {
+ this.decompressBuff.set(new ByteBufferOutputStream(osInitialSize));
+ }
+ ByteBufferOutputStream localBbos = this.decompressBuff.get();
+ localBbos.clear();
+ IOUtils.copy(cis, localBbos);
+ return localBbos.getByteBuffer();
Review comment:
It seems that there is no better solution except returning a copy of the
underlying bytebuffer. But copy is not a reuse of buffers. Currently, the
threadlocal is not a good idea here... (this should be reconsidered). May I
close this PR and the related ticket ? @Apache9
--
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]