HBASE-5345 CheckAndPut doesn't work when value is empty byte[] (Evert Arckens)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1241972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
50f3e412a9
commit
10f108630f
|
@ -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()
|
||||
|
|
|
@ -93,6 +93,7 @@ import org.apache.hadoop.hbase.client.coprocessor.ExecResult;
|
|||
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 { // , Writable{
|
|||
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(),
|
||||
|
|
|
@ -593,12 +593,22 @@ public class TestHRegion extends HBaseTestCase {
|
|||
//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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue