hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [2/2] hbase git commit: HBASE-12431 Use of getColumnLatestCell(byte[], int, int, byte[], int, int) is Not Thread Safe (Jingcheng Du)
Date Thu, 04 Dec 2014 06:35:25 GMT
HBASE-12431 Use of getColumnLatestCell(byte[], int, int, byte[], int, int) is Not Thread Safe
(Jingcheng Du)

(cherry picked from commit c45772e76a581838ea89ff303d0ff67ceaa82845)


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

Branch: refs/heads/branch-1
Commit: bb07de19606cce699e539d49af3ba1c5a12b75fe
Parents: fe9e748
Author: stack <stack@apache.org>
Authored: Wed Dec 3 22:34:27 2014 -0800
Committer: stack <stack@apache.org>
Committed: Wed Dec 3 22:35:14 2014 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/hadoop/hbase/client/Result.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bb07de19/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 86070de..401710e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -84,8 +84,7 @@ public class Result implements CellScannable, CellScanner {
   // Ditto for familyMap.  It can be composed on fly from passed in kvs.
   private transient NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long,
byte[]>>> familyMap = null;
 
-  // never use directly
-  private static byte [] buffer = null;
+  private static ThreadLocal<byte[]> localBuffer = new ThreadLocal<byte[]>();
   private static final int PAD_WIDTH = 128;
   public static final Result EMPTY_RESULT = new Result();
 
@@ -334,9 +333,11 @@ public class Result implements CellScannable, CellScanner {
     double keyValueSize = (double)
         KeyValue.getKeyValueDataStructureSize(kvs[0].getRowLength(), flength, qlength, 0);
 
+    byte[] buffer = localBuffer.get();
     if (buffer == null || keyValueSize > buffer.length) {
       // pad to the smallest multiple of the pad width
       buffer = new byte[(int) Math.ceil(keyValueSize / PAD_WIDTH) * PAD_WIDTH];
+      localBuffer.set(buffer);
     }
 
     Cell searchTerm = KeyValueUtil.createFirstOnRow(buffer, 0,


Mime
View raw message