HBASE-12845 - ByteBufferOutputStream should grow as direct buffer if the
initial buffer is also direct BB (Ram)
This commit is contained in:
parent
1c45263cf4
commit
71184309e1
@ -70,8 +70,12 @@ public class ByteBufferOutputStream extends OutputStream {
|
|||||||
int newSize = (int)Math.min((((long)buf.capacity()) * 2),
|
int newSize = (int)Math.min((((long)buf.capacity()) * 2),
|
||||||
(long)(Integer.MAX_VALUE));
|
(long)(Integer.MAX_VALUE));
|
||||||
newSize = Math.max(newSize, buf.position() + extra);
|
newSize = Math.max(newSize, buf.position() + extra);
|
||||||
|
ByteBuffer newBuf = null;
|
||||||
ByteBuffer newBuf = ByteBuffer.allocate(newSize);
|
if (buf.isDirect()) {
|
||||||
|
newBuf = ByteBuffer.allocateDirect(newSize);
|
||||||
|
} else {
|
||||||
|
newBuf = ByteBuffer.allocate(newSize);
|
||||||
|
}
|
||||||
buf.flip();
|
buf.flip();
|
||||||
newBuf.put(buf);
|
newBuf.put(buf);
|
||||||
buf = newBuf;
|
buf = newBuf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user