HBASE-5271 Result.getValue and Result.getColumnLatest return the wrong column (Ghais Issa)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1236347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-01-26 18:51:33 +00:00
parent ec1c804fc1
commit da1443d90a
3 changed files with 17 additions and 1 deletions

View File

@ -877,6 +877,7 @@ Release 0.92.0 - 01/23/2012
Release 0.90.7 - Unreleased Release 0.90.7 - Unreleased
BUG FIXES BUG FIXES
HBASE-5271 Result.getValue and Result.getColumnLatest return the wrong column (Ghais Issa)
Release 0.90.6 - Unreleased Release 0.90.6 - Unreleased

View File

@ -1277,7 +1277,7 @@ public class KeyValue implements Writable, HeapSize {
int o = getFamilyOffset(rl); int o = getFamilyOffset(rl);
int fl = getFamilyLength(o); int fl = getFamilyLength(o);
int ql = getQualifierLength(rl,fl); int ql = getQualifierLength(rl,fl);
if (!Bytes.equals(family, 0, family.length, this.bytes, o, family.length)) { if (!Bytes.equals(family, 0, family.length, this.bytes, o, fl)) {
return false; return false;
} }
if (qualifier == null || qualifier.length == 0) { if (qualifier == null || qualifier.length == 0) {

View File

@ -56,6 +56,21 @@ public class TestKeyValue extends TestCase {
assertFalse(aaa.matchingColumn(family2,qualifier2)); assertFalse(aaa.matchingColumn(family2,qualifier2));
} }
/**
* Test a corner case when the family qualifier is a prefix of the
* column qualifier.
*/
public void testColumnCompare_prefix() throws Exception {
final byte [] a = Bytes.toBytes("aaa");
byte [] family1 = Bytes.toBytes("abc");
byte [] qualifier1 = Bytes.toBytes("def");
byte [] family2 = Bytes.toBytes("ab");
byte [] qualifier2 = Bytes.toBytes("def");
KeyValue aaa = new KeyValue(a, family1, qualifier1, 0L, Type.Put, a);
assertFalse(aaa.matchingColumn(family2, qualifier2));
}
public void testBasics() throws Exception { public void testBasics() throws Exception {
LOG.info("LOWKEY: " + KeyValue.LOWESTKEY.toString()); LOG.info("LOWKEY: " + KeyValue.LOWESTKEY.toString());
check(Bytes.toBytes(getName()), check(Bytes.toBytes(getName()),