hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1241972 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Wed, 08 Feb 2012 16:55:17 GMT
Author: tedyu
Date: Wed Feb  8 16:55:16 2012
New Revision: 1241972

URL: http://svn.apache.org/viewvc?rev=1241972&view=rev
Log:
HBASE-5345  CheckAndPut doesn't work when value is empty byte[] (Evert Arckens)

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1241972&r1=1241971&r2=1241972&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Feb  8 16:55:16 2012
@@ -11,6 +11,7 @@ Release 0.92.1 - Unreleased
                of the writer threads has exceptions. (Ram)
    HBASE-5243  LogSyncerThread not getting shutdown waiting for the interrupted flag (Ram)
    HBASE-5255  Use singletons for OperationStatus to save memory (Benoit)
+   HBASE-5345  CheckAndPut doesn't work when value is empty byte[] (Evert Arckens)
 
   TESTS
    HBASE-5223  TestMetaReaderEditor is missing call to CatalogTracker.stop()

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1241972&r1=1241971&r2=1241972&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Wed Feb  8
16:55:16 2012
@@ -93,6 +93,7 @@ import org.apache.hadoop.hbase.client.co
 import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.IncompatibleFilterException;
+import org.apache.hadoop.hbase.filter.NullComparator;
 import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
 import org.apache.hadoop.hbase.io.HeapSize;
 import org.apache.hadoop.hbase.io.TimeRange;
@@ -2275,6 +2276,9 @@ public class HRegion implements HeapSize
         boolean matches = false;
         if (result.size() == 0 && valueIsNull) {
           matches = true;
+        } else if (result.size() > 0 && result.get(0).getValue().length == 0 &&
+            valueIsNull) {
+          matches = true;
         } else if (result.size() == 1 && !valueIsNull) {
           KeyValue kv = result.get(0);
           int compareResult = comparator.compareTo(kv.getBuffer(),

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1241972&r1=1241971&r2=1241972&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java Wed Feb
 8 16:55:16 2012
@@ -593,12 +593,22 @@ public class TestHRegion extends HBaseTe
     //Setting up region
     String method = this.getName();
     initHRegion(tableName, method, fam1);
-    //Putting data in key
+
+    //Putting empty data in key
     Put put = new Put(row1);
+    put.add(fam1, qf1, emptyVal);
+
+    //checkAndPut with empty value
+    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
+        new BinaryComparator(emptyVal), put, lockId, true);
+    assertTrue(res);
+    
+    //Putting data in key
+    put = new Put(row1);
     put.add(fam1, qf1, val1);
 
     //checkAndPut with correct value
-    boolean res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
+    res = region.checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL,
         new BinaryComparator(emptyVal), put, lockId, true);
     assertTrue(res);
 



Mime
View raw message