HBASE-4956 Control direct memory buffer consumption by HBaseClient (Bob Copeland)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1363526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-07-19 20:31:44 +00:00
parent 1a6834c8c9
commit 309f846827
1 changed files with 9 additions and 1 deletions

View File

@ -720,10 +720,18 @@ public class Result implements Writable, WritableWithSize {
return;
}
byte [] raw = new byte[totalBuffer];
in.readFully(raw, 0, totalBuffer);
readChunked(in, raw, 0, totalBuffer);
bytes = new ImmutableBytesWritable(raw, 0, totalBuffer);
}
private void readChunked(final DataInput in, byte[] dest, int ofs, int len)
throws IOException {
int maxRead = 8192;
for (; ofs < len; ofs += maxRead)
in.readFully(dest, ofs, Math.min(len - ofs, maxRead));
}
//Create KeyValue[] when needed
private void readFields() {
if (bytes == null) {