HBASE-7239. Introduces chunked reading for large cellblocks

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1469654 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2013-04-19 01:15:28 +00:00
parent b7391e5449
commit 35038df81d
2 changed files with 19 additions and 1 deletions

View File

@ -1026,7 +1026,7 @@ public class HBaseClient {
if (responseHeader.hasCellBlockMeta()) {
int size = responseHeader.getCellBlockMeta().getLength();
byte [] cellBlock = new byte[size];
IOUtils.readFully(this.in, cellBlock, 0, cellBlock.length);
IPCUtil.readChunked(this.in, cellBlock, 0, size);
cellBlockScanner = ipcUtil.createCellScanner(this.codec, this.compressor, cellBlock);
}
// it's possible that this call may have been cleaned up due to a RPC

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.ipc;
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -230,6 +231,23 @@ class IPCUtil {
return bytes;
}
/**
* Read in chunks of 8K (HBASE-7239)
* @param in
* @param dest
* @param offset
* @param len
* @throws IOException
*/
static void readChunked(final DataInput in, byte[] dest, int offset, int len)
throws IOException {
int maxRead = 8192;
for (; offset < len; offset += maxRead) {
in.readFully(dest, offset, Math.min(len - offset, maxRead));
}
}
/**
* @param header
* @param body