HBASE-18573 Update Append and Delete to use Mutation#getCellList(family)

Signed-off-by: Jerry He <jerryjch@apache.org>
This commit is contained in:
Xiang Li 2017-08-17 00:39:35 +08:00 committed by Jerry He
parent 7149f99978
commit 4057552ed6
2 changed files with 10 additions and 30 deletions

View File

@ -134,11 +134,10 @@ public class Append extends Mutation {
public Append add(final Cell cell) {
// Presume it is KeyValue for now.
byte [] family = CellUtil.cloneFamily(cell);
List<Cell> list = this.familyMap.get(family);
if (list == null) {
list = new ArrayList<>(1);
this.familyMap.put(family, list);
}
// Get cell list for the family
List<Cell> list = getCellList(family);
// find where the new entry should be placed in the List
list.add(cell);
return this;

View File

@ -180,11 +180,7 @@ public class Delete extends Mutation implements Comparable<Row> {
" doesn't match the original one " + Bytes.toStringBinary(this.row));
}
byte [] family = CellUtil.cloneFamily(kv);
List<Cell> list = familyMap.get(family);
if (list == null) {
list = new ArrayList<>(1);
familyMap.put(family, list);
}
List<Cell> list = getCellList(family);
list.add(kv);
return this;
}
@ -216,11 +212,8 @@ public class Delete extends Mutation implements Comparable<Row> {
if (timestamp < 0) {
throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
}
List<Cell> list = familyMap.get(family);
if(list == null) {
list = new ArrayList<>(1);
familyMap.put(family, list);
} else if(!list.isEmpty()) {
List<Cell> list = getCellList(family);
if(!list.isEmpty()) {
list.clear();
}
KeyValue kv = new KeyValue(row, family, null, timestamp, KeyValue.Type.DeleteFamily);
@ -236,11 +229,7 @@ public class Delete extends Mutation implements Comparable<Row> {
* @return this for invocation chaining
*/
public Delete addFamilyVersion(final byte [] family, final long timestamp) {
List<Cell> list = familyMap.get(family);
if(list == null) {
list = new ArrayList<>(1);
familyMap.put(family, list);
}
List<Cell> list = getCellList(family);
list.add(new KeyValue(row, family, null, timestamp,
KeyValue.Type.DeleteFamilyVersion));
return this;
@ -269,11 +258,7 @@ public class Delete extends Mutation implements Comparable<Row> {
if (timestamp < 0) {
throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
}
List<Cell> list = familyMap.get(family);
if (list == null) {
list = new ArrayList<>(1);
familyMap.put(family, list);
}
List<Cell> list = getCellList(family);
list.add(new KeyValue(this.row, family, qualifier, timestamp,
KeyValue.Type.DeleteColumn));
return this;
@ -304,11 +289,7 @@ public class Delete extends Mutation implements Comparable<Row> {
if (timestamp < 0) {
throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
}
List<Cell> list = familyMap.get(family);
if(list == null) {
list = new ArrayList<>(1);
familyMap.put(family, list);
}
List<Cell> list = getCellList(family);
KeyValue kv = new KeyValue(this.row, family, qualifier, timestamp, KeyValue.Type.Delete);
list.add(kv);
return this;