Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java (revision 1571370) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java (working copy) @@ -367,7 +367,10 @@ if (bucketEntry.equals(backingMap.get(key))) { int len = bucketEntry.getLength(); ByteBuffer bb = ByteBuffer.allocate(len); - ioEngine.read(bb, bucketEntry.offset()); + int lenRead = ioEngine.read(bb, bucketEntry.offset()); + if (lenRead != len) { + throw new RuntimeException("Only " + lenRead + " bytes read, " + len + " expected"); + } Cacheable cachedBlock = bucketEntry.deserializerReference( deserialiserMap).deserialize(bb, true); long timeTaken = System.nanoTime() - start; Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/ByteBufferIOEngine.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/ByteBufferIOEngine.java (revision 1571370) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/ByteBufferIOEngine.java (working copy) @@ -59,12 +59,13 @@ * @param dstBuffer the given byte buffer into which bytes are to be written * @param offset The offset in the ByteBufferArray of the first byte to be * read + * @return number of bytes read * @throws IOException */ @Override - public void read(ByteBuffer dstBuffer, long offset) throws IOException { + public int read(ByteBuffer dstBuffer, long offset) throws IOException { assert dstBuffer.hasArray(); - bufferArray.getMultiple(offset, dstBuffer.remaining(), dstBuffer.array(), + return bufferArray.getMultiple(offset, dstBuffer.remaining(), dstBuffer.array(), dstBuffer.arrayOffset()); } Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java (revision 1571370) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java (working copy) @@ -69,11 +69,12 @@ * Transfers data from file to the given byte buffer * @param dstBuffer the given byte buffer into which bytes are to be written * @param offset The offset in the file where the first byte to be read + * @return number of bytes read * @throws IOException */ @Override - public void read(ByteBuffer dstBuffer, long offset) throws IOException { - fileChannel.read(dstBuffer, offset); + public int read(ByteBuffer dstBuffer, long offset) throws IOException { + return fileChannel.read(dstBuffer, offset); } /** Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/IOEngine.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/IOEngine.java (revision 1571370) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/IOEngine.java (working copy) @@ -39,9 +39,10 @@ * Transfers data from IOEngine to the given byte buffer * @param dstBuffer the given byte buffer into which bytes are to be written * @param offset The offset in the IO engine where the first byte to be read + * @return number of bytes read * @throws IOException */ - void read(ByteBuffer dstBuffer, long offset) throws IOException; + int read(ByteBuffer dstBuffer, long offset) throws IOException; /** * Transfers data from the given byte buffer to IOEngine Index: hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java =================================================================== --- hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java (revision 1571370) +++ hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferArray.java (working copy) @@ -80,9 +80,10 @@ * @param start start position in the ByteBufferArray * @param len The maximum number of bytes to be written to the given array * @param dstArray The array into which bytes are to be written + * @return number of bytes read */ - public void getMultiple(long start, int len, byte[] dstArray) { - getMultiple(start, len, dstArray, 0); + public int getMultiple(long start, int len, byte[] dstArray) { + return getMultiple(start, len, dstArray, 0); } /** @@ -92,13 +93,15 @@ * @param dstArray The array into which bytes are to be written * @param dstOffset The offset within the given array of the first byte to be * written + * @return number of bytes read */ - public void getMultiple(long start, int len, byte[] dstArray, int dstOffset) { + public int getMultiple(long start, int len, byte[] dstArray, int dstOffset) { multiple(start, len, dstArray, dstOffset, new Visitor() { public void visit(ByteBuffer bb, byte[] array, int arrayIdx, int len) { bb.get(array, arrayIdx, len); } }); + return len; } /**