HBASE-18555: Remove redundant familyMap.put() from addxxx() of sub-classes of Mutation and Query

Signed-off-by: Jerry He <jerryjch@apache.org>
This commit is contained in:
Xiang Li 2017-08-11 00:07:11 +08:00 committed by Jerry He
parent 578e29f96b
commit 7bd2795ee9
7 changed files with 9 additions and 17 deletions

View File

@ -125,10 +125,10 @@ public class Append extends Mutation {
List<Cell> list = this.familyMap.get(family); List<Cell> list = this.familyMap.get(family);
if (list == null) { if (list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
this.familyMap.put(family, list);
} }
// find where the new entry should be placed in the List // find where the new entry should be placed in the List
list.add(cell); list.add(cell);
this.familyMap.put(family, list);
return this; return this;
} }

View File

@ -173,9 +173,9 @@ public class Delete extends Mutation implements Comparable<Row> {
List<Cell> list = familyMap.get(family); List<Cell> list = familyMap.get(family);
if (list == null) { if (list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
familyMap.put(family, list);
} }
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -239,12 +239,12 @@ public class Delete extends Mutation implements Comparable<Row> {
List<Cell> list = familyMap.get(family); List<Cell> list = familyMap.get(family);
if(list == null) { if(list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
familyMap.put(family, list);
} else if(!list.isEmpty()) { } else if(!list.isEmpty()) {
list.clear(); list.clear();
} }
KeyValue kv = new KeyValue(row, family, null, timestamp, KeyValue.Type.DeleteFamily); KeyValue kv = new KeyValue(row, family, null, timestamp, KeyValue.Type.DeleteFamily);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -272,10 +272,10 @@ public class Delete extends Mutation implements Comparable<Row> {
List<Cell> list = familyMap.get(family); List<Cell> list = familyMap.get(family);
if(list == null) { if(list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
familyMap.put(family, list);
} }
list.add(new KeyValue(row, family, null, timestamp, list.add(new KeyValue(row, family, null, timestamp,
KeyValue.Type.DeleteFamilyVersion)); KeyValue.Type.DeleteFamilyVersion));
familyMap.put(family, list);
return this; return this;
} }
@ -331,10 +331,10 @@ public class Delete extends Mutation implements Comparable<Row> {
List<Cell> list = familyMap.get(family); List<Cell> list = familyMap.get(family);
if (list == null) { if (list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
familyMap.put(family, list);
} }
list.add(new KeyValue(this.row, family, qualifier, timestamp, list.add(new KeyValue(this.row, family, qualifier, timestamp,
KeyValue.Type.DeleteColumn)); KeyValue.Type.DeleteColumn));
familyMap.put(family, list);
return this; return this;
} }
@ -394,10 +394,10 @@ public class Delete extends Mutation implements Comparable<Row> {
List<Cell> list = familyMap.get(family); List<Cell> list = familyMap.get(family);
if(list == null) { if(list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
familyMap.put(family, list);
} }
KeyValue kv = new KeyValue(this.row, family, qualifier, timestamp, KeyValue.Type.Delete); KeyValue kv = new KeyValue(this.row, family, qualifier, timestamp, KeyValue.Type.Delete);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }

View File

@ -176,12 +176,12 @@ public class Get extends Query
NavigableSet<byte []> set = familyMap.get(family); NavigableSet<byte []> set = familyMap.get(family);
if(set == null) { if(set == null) {
set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR); set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
familyMap.put(family, set);
} }
if (qualifier == null) { if (qualifier == null) {
qualifier = HConstants.EMPTY_BYTE_ARRAY; qualifier = HConstants.EMPTY_BYTE_ARRAY;
} }
set.add(qualifier); set.add(qualifier);
familyMap.put(family, set);
return this; return this;
} }

View File

@ -106,7 +106,6 @@ public class Increment extends Mutation implements Comparable<Row> {
" doesn't match the original one " + Bytes.toStringBinary(this.row)); " doesn't match the original one " + Bytes.toStringBinary(this.row));
} }
list.add(cell); list.add(cell);
familyMap.put(family, list);
return this; return this;
} }
@ -130,7 +129,6 @@ public class Increment extends Mutation implements Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, Bytes.toBytes(amount)); KeyValue kv = createPutKeyValue(family, qualifier, ts, Bytes.toBytes(amount));
list.add(kv); list.add(kv);
familyMap.put(CellUtil.cloneFamily(kv), list);
return this; return this;
} }

View File

@ -116,6 +116,7 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C
List<Cell> list = this.familyMap.get(family); List<Cell> list = this.familyMap.get(family);
if (list == null) { if (list == null) {
list = new ArrayList<Cell>(); list = new ArrayList<Cell>();
this.familyMap.put(family, list);
} }
return list; return list;
} }

View File

@ -206,7 +206,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value); KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
list.add(kv); list.add(kv);
familyMap.put(CellUtil.cloneFamily(kv), list);
return this; return this;
} }
@ -222,7 +221,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value); KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -237,7 +235,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -256,7 +253,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -292,7 +288,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null);
list.add(kv); list.add(kv);
familyMap.put(CellUtil.cloneFamily(kv), list);
return this; return this;
} }
@ -308,7 +303,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null);
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }
@ -331,7 +325,6 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
" doesn't match the original one " + Bytes.toStringBinary(this.row)); " doesn't match the original one " + Bytes.toStringBinary(this.row));
} }
list.add(kv); list.add(kv);
familyMap.put(family, list);
return this; return this;
} }

View File

@ -341,12 +341,12 @@ public class Scan extends Query {
NavigableSet<byte []> set = familyMap.get(family); NavigableSet<byte []> set = familyMap.get(family);
if(set == null) { if(set == null) {
set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR); set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
familyMap.put(family, set);
} }
if (qualifier == null) { if (qualifier == null) {
qualifier = HConstants.EMPTY_BYTE_ARRAY; qualifier = HConstants.EMPTY_BYTE_ARRAY;
} }
set.add(qualifier); set.add(qualifier);
familyMap.put(family, set);
return this; return this;
} }