HBASE-9115 HTableInterface.append operation may overwrites values (Ted Yu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1509849 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-08-02 20:47:17 +00:00
parent 1a76ba5336
commit 5b89721c1e
2 changed files with 10 additions and 3 deletions

View File

@ -111,8 +111,15 @@ public class Append extends Mutation {
}
// Cast so explicit list type rather than ? extends Cell. Help the compiler out. See
// http://stackoverflow.com/questions/6474784/java-using-generics-with-lists-and-interfaces
((List<KeyValue>)list).add(kv);
List<KeyValue> l = (List<KeyValue>)list;
// find where the new entry should be placed in the List
int idx = 0;
for (KeyValue keyval : l) {
if (Bytes.compareTo(kv.getQualifier(), keyval.getQualifier()) < 0) break;
idx ++;
}
l.add(idx, kv);
this.familyMap.put(family, list);
return this;
}
}
}

View File

@ -4373,7 +4373,7 @@ public class TestFromClientSide {
byte[] v1 = Bytes.toBytes("42");
byte[] v2 = Bytes.toBytes("23");
byte [][] QUALIFIERS = new byte [][] {
Bytes.toBytes("a"), Bytes.toBytes("b")
Bytes.toBytes("b"), Bytes.toBytes("a")
};
Append a = new Append(ROW);
a.add(FAMILY, QUALIFIERS[0], v1);