HBASE-12445 hbase is removing all remaining cells immediately after the cell marked with marker = KeyValue.Type.DeleteColumn via PUT (Hani Nadra)
This commit is contained in:
parent
a376c8da9d
commit
f641aada36
|
@ -1114,6 +1114,7 @@ public final class ProtobufUtil {
|
|||
List<Cell> values = family.getValue();
|
||||
if (values != null && values.size() > 0) {
|
||||
for (Cell cell: values) {
|
||||
valueBuilder.clear();
|
||||
valueBuilder.setQualifier(ByteStringer.wrap(
|
||||
cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
|
||||
valueBuilder.setValue(ByteStringer.wrap(
|
||||
|
@ -1176,6 +1177,7 @@ public final class ProtobufUtil {
|
|||
columnBuilder.clear();
|
||||
columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
|
||||
for (Cell cell: family.getValue()) {
|
||||
valueBuilder.clear();
|
||||
valueBuilder.setQualifier(ByteStringer.wrap(
|
||||
cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
|
||||
valueBuilder.setValue(ByteStringer.wrap(
|
||||
|
@ -1966,7 +1968,7 @@ public final class ProtobufUtil {
|
|||
for (Permission.Action a : actions) {
|
||||
builder.addAction(toPermissionAction(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
ret.setNamespacePermission(builder);
|
||||
return ret.build();
|
||||
} else if (tablePerm.hasTable()) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public class TestPutWithDelete {
|
|||
put.add(family, Bytes.toBytes("A"), Bytes.toBytes("a"));
|
||||
put.add(family, Bytes.toBytes("B"), Bytes.toBytes("b"));
|
||||
put.add(family, Bytes.toBytes("C"), Bytes.toBytes("c"));
|
||||
put.add(family, Bytes.toBytes("D"), Bytes.toBytes("d"));
|
||||
table.put(put);
|
||||
// get row back and assert the values
|
||||
Get get = new Get(rowKey);
|
||||
|
@ -72,23 +73,28 @@ public class TestPutWithDelete {
|
|||
Bytes.toString(result.getValue(family, Bytes.toBytes("B"))).equals("b"));
|
||||
assertTrue("Column C value should be c",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("C"))).equals("c"));
|
||||
assertTrue("Column D value should be d",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("D"))).equals("d"));
|
||||
// put the same row again with C column deleted
|
||||
put = new Put(rowKey);
|
||||
put.add(family, Bytes.toBytes("A"), Bytes.toBytes("a"));
|
||||
put.add(family, Bytes.toBytes("B"), Bytes.toBytes("b"));
|
||||
put.add(family, Bytes.toBytes("A"), Bytes.toBytes("a1"));
|
||||
put.add(family, Bytes.toBytes("B"), Bytes.toBytes("b1"));
|
||||
KeyValue marker = new KeyValue(rowKey, family, Bytes.toBytes("C"),
|
||||
HConstants.LATEST_TIMESTAMP, KeyValue.Type.DeleteColumn);
|
||||
put.add(family, Bytes.toBytes("D"), Bytes.toBytes("d1"));
|
||||
put.add(marker);
|
||||
table.put(put);
|
||||
// get row back and assert the values
|
||||
get = new Get(rowKey);
|
||||
result = table.get(get);
|
||||
assertTrue("Column A value should be a",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("A"))).equals("a"));
|
||||
assertTrue("Column B value should be b",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("B"))).equals("b"));
|
||||
assertTrue("Column A value should be a1",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("A"))).equals("a1"));
|
||||
assertTrue("Column B value should be b1",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("B"))).equals("b1"));
|
||||
assertTrue("Column C should not exist",
|
||||
result.getValue(family, Bytes.toBytes("C")) == null);
|
||||
assertTrue("Column D value should be d1",
|
||||
Bytes.toString(result.getValue(family, Bytes.toBytes("D"))).equals("d1"));
|
||||
} finally {
|
||||
table.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue