HBASE-18515 Introduce Delete.add as a replacement for Delete#addDeleteMarker

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
no_apologies 2017-08-07 11:04:31 +08:00 committed by Chia-Ping Tsai
parent be034c26b4
commit 2c067695dd
9 changed files with 24 additions and 14 deletions

View File

@ -151,15 +151,26 @@ public class Delete extends Mutation implements Comparable<Row> {
} }
/** /**
* Advanced use only. * Advanced use only. Add an existing delete marker to this Delete object.
* @param kv An existing KeyValue of type "delete".
* @return this for invocation chaining
* @throws IOException
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use {@link #add(Cell)}
* instead
*/
@SuppressWarnings("unchecked")
@Deprecated
public Delete addDeleteMarker(Cell kv) throws IOException {
return this.add(kv);
}
/**
* Add an existing delete marker to this Delete object. * Add an existing delete marker to this Delete object.
* @param kv An existing KeyValue of type "delete". * @param kv An existing KeyValue of type "delete".
* @return this for invocation chaining * @return this for invocation chaining
* @throws IOException * @throws IOException
*/ */
@SuppressWarnings("unchecked") public Delete add(Cell kv) throws IOException {
public Delete addDeleteMarker(Cell kv) throws IOException {
// TODO: Deprecate and rename 'add' so it matches how we add KVs to Puts.
if (!CellUtil.isDelete(kv)) { if (!CellUtil.isDelete(kv)) {
throw new IOException("The recently added KeyValue is not of type " throw new IOException("The recently added KeyValue is not of type "
+ "delete. Rowkey: " + Bytes.toStringBinary(this.row)); + "delete. Rowkey: " + Bytes.toStringBinary(this.row));
@ -178,7 +189,6 @@ public class Delete extends Mutation implements Comparable<Row> {
return this; return this;
} }
/** /**
* Delete all versions of all columns of the specified family. * Delete all versions of all columns of the specified family.
* <p> * <p>

View File

@ -580,7 +580,7 @@ public final class ProtobufUtil {
delete = delete =
new Delete(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp); new Delete(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp);
} }
delete.addDeleteMarker(cell); delete.add(cell);
} }
} else { } else {
if (delete == null) { if (delete == null) {

View File

@ -730,7 +730,7 @@ public final class ProtobufUtil {
delete = delete =
new Delete(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp); new Delete(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), timestamp);
} }
delete.addDeleteMarker(cell); delete.add(cell);
} }
} else { } else {
if (delete == null) { if (delete == null) {

View File

@ -548,7 +548,7 @@ public class TestRowProcessorEndpoint {
KeyValue kvDelete = KeyValue kvDelete =
new KeyValue(rows[i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv), new KeyValue(rows[i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv),
kv.getTimestamp(), KeyValue.Type.Delete); kv.getTimestamp(), KeyValue.Type.Delete);
d.addDeleteMarker(kvDelete); d.add(kvDelete);
Put p = new Put(rows[1 - i]); Put p = new Put(rows[1 - i]);
KeyValue kvAdd = KeyValue kvAdd =
new KeyValue(rows[1 - i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv), new KeyValue(rows[1 - i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv),

View File

@ -354,7 +354,7 @@ public class Import extends Configured implements Tool {
*/ */
if (CellUtil.isDeleteFamily(kv)) { if (CellUtil.isDeleteFamily(kv)) {
Delete deleteFamily = new Delete(key.get()); Delete deleteFamily = new Delete(key.get());
deleteFamily.addDeleteMarker(kv); deleteFamily.add(kv);
if (durability != null) { if (durability != null) {
deleteFamily.setDurability(durability); deleteFamily.setDurability(durability);
} }
@ -364,7 +364,7 @@ public class Import extends Configured implements Tool {
if (delete == null) { if (delete == null) {
delete = new Delete(key.get()); delete = new Delete(key.get());
} }
delete.addDeleteMarker(kv); delete.add(kv);
} else { } else {
if (put == null) { if (put == null) {
put = new Put(key.get()); put = new Put(key.get());

View File

@ -182,7 +182,7 @@ public class WALPlayer extends Configured implements Tool {
} }
} }
if (CellUtil.isDelete(cell)) { if (CellUtil.isDelete(cell)) {
del.addDeleteMarker(cell); del.add(cell);
} else { } else {
put.add(cell); put.add(cell);
} }

View File

@ -191,7 +191,7 @@ public class ReplicationSink {
addToHashMultiMap(rowMap, table, clusterIds, m); addToHashMultiMap(rowMap, table, clusterIds, m);
} }
if (CellUtil.isDelete(cell)) { if (CellUtil.isDelete(cell)) {
((Delete) m).addDeleteMarker(cell); ((Delete) m).add(cell);
} else { } else {
((Put) m).add(cell); ((Put) m).add(cell);
} }

View File

@ -400,7 +400,7 @@ public class VisibilityController implements MasterObserver, RegionObserver,
p.add(cell); p.add(cell);
} else if (m instanceof Delete) { } else if (m instanceof Delete) {
Delete d = (Delete) m; Delete d = (Delete) m;
d.addDeleteMarker(cell); d.add(cell);
} }
} }
} }

View File

@ -2376,7 +2376,7 @@ public class WALSplitter {
} }
} }
if (CellUtil.isDelete(cell)) { if (CellUtil.isDelete(cell)) {
((Delete) m).addDeleteMarker(cell); ((Delete) m).add(cell);
} else { } else {
((Put) m).add(cell); ((Put) m).add(cell);
} }