From 35038df81d8f2af770d0916fe3e10126ad793019 Mon Sep 17 00:00:00 2001 From: Devaraj Das Date: Fri, 19 Apr 2013 01:15:28 +0000 Subject: [PATCH] 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 --- .../apache/hadoop/hbase/ipc/HBaseClient.java | 2 +- .../org/apache/hadoop/hbase/ipc/IPCUtil.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java index 855e8dcc7a7..7fd037008a4 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java @@ -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 diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java index 707c2bff05d..19c786d6b00 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java @@ -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