hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-16613 Return the unused ByteBuffer to BoundedByteBufferPool when no cell is retrieved from the CellScanner (ChiaPing Tsai)
Date Tue, 13 Sep 2016 16:49:25 GMT
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 <yuzhihong@gmail.com>
Authored: Tue Sep 13 09:49:13 2016 -0700
Committer: tedyu <yuzhihong@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 {


Mime
View raw message