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