You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2016/09/13 16:49:25 UTC

hbase git commit: HBASE-16613 Return the unused ByteBuffer to BoundedByteBufferPool when no cell is retrieved from the CellScanner (ChiaPing Tsai)

Repository: hbase
Updated Branches:
  refs/heads/branch-1 059a169d3 -> 8e25ea536


HBASE-16613 Return the unused ByteBuffer to BoundedByteBufferPool when no cell is retrieved from the CellScanner (ChiaPing Tsai)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8e25ea53
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8e25ea53
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8e25ea53

Branch: refs/heads/branch-1
Commit: 8e25ea536aab69ed07de862583d4d081e10dd2ed
Parents: 059a169
Author: tedyu <yu...@gmail.com>
Authored: Tue Sep 13 09:49:13 2016 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Tue Sep 13 09:49:13 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/8e25ea53/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
----------------------------------------------------------------------
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 22c5cc1..c238adb 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
@@ -122,8 +122,9 @@ public class IPCUtil {
     if (codec == null) throw new CellScannerButNoCodecException();
     int bufferSize = this.cellBlockBuildingInitialBufferSize;
     ByteBufferOutputStream baos = null;
+    ByteBuffer bb = null;
     if (pool != null) {
-      ByteBuffer bb = pool.getBuffer();
+      bb = pool.getBuffer();
       bufferSize = bb.capacity();
       baos = new ByteBufferOutputStream(bb);
     } else {
@@ -155,7 +156,12 @@ public class IPCUtil {
       encoder.flush();
       // If no cells, don't mess around.  Just return null (could be a bunch of existence checking
       // gets or something -- stuff that does not return a cell).
-      if (count == 0) return null;
+      if (count == 0) {
+        if (pool != null && bb != null) {
+          pool.putBuffer(bb);
+        }
+        return null;
+      }
     } catch (BufferOverflowException e) {
       throw new DoNotRetryIOException(e);
     } finally {