HBASE-17410 Changed size() == 0 to isEmpty in hbase-client

Signed-off-by: Josh Elser <elserj@apache.org>
This commit is contained in:
Jan Hentschel 2017-01-04 18:29:33 +01:00 committed by Josh Elser
parent dba103e1b6
commit df98d8dcd7
13 changed files with 19 additions and 19 deletions

View File

@ -350,10 +350,10 @@ public abstract class ClientScanner extends AbstractClientScanner {
protected Result nextWithSyncCache() throws IOException { protected Result nextWithSyncCache() throws IOException {
// If the scanner is closed and there's nothing left in the cache, next is a no-op. // If the scanner is closed and there's nothing left in the cache, next is a no-op.
if (cache.size() == 0 && this.closed) { if (cache.isEmpty() && this.closed) {
return null; return null;
} }
if (cache.size() == 0) { if (cache.isEmpty()) {
loadCache(); loadCache();
} }

View File

@ -193,10 +193,10 @@ public class ClientSmallReversedScanner extends ReversedClientScanner {
public Result next() throws IOException { public Result next() throws IOException {
// If the scanner is closed and there's nothing left in the cache, next is a // If the scanner is closed and there's nothing left in the cache, next is a
// no-op. // no-op.
if (cache.size() == 0 && this.closed) { if (cache.isEmpty() && this.closed) {
return null; return null;
} }
if (cache.size() == 0) { if (cache.isEmpty()) {
loadCache(); loadCache();
} }

View File

@ -216,10 +216,10 @@ public class ClientSmallScanner extends ClientSimpleScanner {
public Result next() throws IOException { public Result next() throws IOException {
// If the scanner is closed and there's nothing left in the cache, next is a // If the scanner is closed and there's nothing left in the cache, next is a
// no-op. // no-op.
if (cache.size() == 0 && this.closed) { if (cache.isEmpty() && this.closed) {
return null; return null;
} }
if (cache.size() == 0) { if (cache.isEmpty()) {
loadCache(); loadCache();
} }

View File

@ -569,7 +569,7 @@ public class HTableMultiplexer {
// drain all the queued puts into the tmp list // drain all the queued puts into the tmp list
processingList.clear(); processingList.clear();
queue.drainTo(processingList); queue.drainTo(processingList);
if (processingList.size() == 0) { if (processingList.isEmpty()) {
// Nothing to flush // Nothing to flush
return; return;
} }

View File

@ -225,7 +225,7 @@ public class Increment extends Mutation implements Comparable<Row> {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("row="); sb.append("row=");
sb.append(Bytes.toStringBinary(this.row)); sb.append(Bytes.toStringBinary(this.row));
if(this.familyMap.size() == 0) { if(this.familyMap.isEmpty()) {
sb.append(", no columns set to be incremented"); sb.append(", no columns set to be incremented");
return sb.toString(); return sb.toString();
} }

View File

@ -413,7 +413,7 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
private boolean has(byte[] family, byte[] qualifier, long ts, byte[] value, private boolean has(byte[] family, byte[] qualifier, long ts, byte[] value,
boolean ignoreTS, boolean ignoreValue) { boolean ignoreTS, boolean ignoreValue) {
List<Cell> list = getCellList(family); List<Cell> list = getCellList(family);
if (list.size() == 0) { if (list.isEmpty()) {
return false; return false;
} }
// Boolean analysis of ignoreTS/ignoreValue. // Boolean analysis of ignoreTS/ignoreValue.

View File

@ -871,7 +871,7 @@ public class Scan extends Query {
public Map<String, Object> getFingerprint() { public Map<String, Object> getFingerprint() {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
List<String> families = new ArrayList<String>(); List<String> families = new ArrayList<String>();
if(this.familyMap.size() == 0) { if(this.familyMap.isEmpty()) {
map.put("families", "ALL"); map.put("families", "ALL");
return map; return map;
} else { } else {

View File

@ -61,7 +61,7 @@ public class FirstKeyOnlyFilter extends FilterBase {
} }
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 0, Preconditions.checkArgument(filterArguments.isEmpty(),
"Expected 0 but got: %s", filterArguments.size()); "Expected 0 but got: %s", filterArguments.size());
return new FirstKeyOnlyFilter(); return new FirstKeyOnlyFilter();
} }

View File

@ -75,7 +75,7 @@ public class KeyOnlyFilter extends FilterBase {
} }
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) { public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
Preconditions.checkArgument((filterArguments.size() == 0 || filterArguments.size() == 1), Preconditions.checkArgument((filterArguments.isEmpty() || filterArguments.size() == 1),
"Expected: 0 or 1 but got: %s", filterArguments.size()); "Expected: 0 or 1 but got: %s", filterArguments.size());
KeyOnlyFilter filter = new KeyOnlyFilter(); KeyOnlyFilter filter = new KeyOnlyFilter();
if (filterArguments.size() == 1) { if (filterArguments.size() == 1) {

View File

@ -248,7 +248,7 @@ public class MultiRowRangeFilter extends FilterBase {
* @return the ranges after sort and merge. * @return the ranges after sort and merge.
*/ */
public static List<RowRange> sortAndMerge(List<RowRange> ranges) { public static List<RowRange> sortAndMerge(List<RowRange> ranges) {
if (ranges.size() == 0) { if (ranges.isEmpty()) {
throw new IllegalArgumentException("No ranges found."); throw new IllegalArgumentException("No ranges found.");
} }
List<RowRange> invalidRanges = new ArrayList<RowRange>(); List<RowRange> invalidRanges = new ArrayList<RowRange>();
@ -391,7 +391,7 @@ public class MultiRowRangeFilter extends FilterBase {
throwExceptionForInvalidRanges(invalidRanges, true); throwExceptionForInvalidRanges(invalidRanges, true);
} }
// If no valid ranges found, throw the exception // If no valid ranges found, throw the exception
if(newRanges.size() == 0) { if(newRanges.isEmpty()) {
throw new IllegalArgumentException("No valid ranges found."); throw new IllegalArgumentException("No valid ranges found.");
} }
return newRanges; return newRanges;

View File

@ -70,7 +70,7 @@ public class MultipleColumnPrefixFilter extends FilterBase {
@Override @Override
public ReturnCode filterKeyValue(Cell kv) { public ReturnCode filterKeyValue(Cell kv) {
if (sortedPrefixes.size() == 0) { if (sortedPrefixes.isEmpty()) {
return ReturnCode.INCLUDE; return ReturnCode.INCLUDE;
} else { } else {
return filterColumn(kv); return filterColumn(kv);

View File

@ -204,7 +204,7 @@ public class ReplicationQueuesZKImpl extends ReplicationStateZKBase implements R
String rsPath = ZKUtil.joinZNode(this.queuesZNode, regionserver); String rsPath = ZKUtil.joinZNode(this.queuesZNode, regionserver);
try { try {
List<String> list = ZKUtil.listChildrenNoWatch(this.zookeeper, rsPath); List<String> list = ZKUtil.listChildrenNoWatch(this.zookeeper, rsPath);
if (list != null && list.size() == 0){ if (list != null && list.isEmpty()){
ZKUtil.deleteNode(this.zookeeper, rsPath); ZKUtil.deleteNode(this.zookeeper, rsPath);
} }
} catch (KeeperException e) { } catch (KeeperException e) {
@ -282,7 +282,7 @@ public class ReplicationQueuesZKImpl extends ReplicationStateZKBase implements R
} }
SortedSet<String> logQueue = new TreeSet<>(); SortedSet<String> logQueue = new TreeSet<>();
if (wals == null || wals.size() == 0) { if (wals == null || wals.isEmpty()) {
listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode)); listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode));
} else { } else {
// create the new cluster znode // create the new cluster znode

View File

@ -132,7 +132,7 @@ public class TestHTableDescriptor {
String className1 = "org.apache.hadoop.hbase.coprocessor.BaseRegionObserver"; String className1 = "org.apache.hadoop.hbase.coprocessor.BaseRegionObserver";
String className2 = "org.apache.hadoop.hbase.coprocessor.SampleRegionWALObserver"; String className2 = "org.apache.hadoop.hbase.coprocessor.SampleRegionWALObserver";
// Check that any coprocessor is present. // Check that any coprocessor is present.
assertTrue(desc.getCoprocessors().size() == 0); assertTrue(desc.getCoprocessors().isEmpty());
// Add the 1 coprocessor and check if present. // Add the 1 coprocessor and check if present.
desc.addCoprocessor(className1); desc.addCoprocessor(className1);
@ -153,7 +153,7 @@ public class TestHTableDescriptor {
// Remove the last and check // Remove the last and check
desc.removeCoprocessor(className2); desc.removeCoprocessor(className2);
assertTrue(desc.getCoprocessors().size() == 0); assertTrue(desc.getCoprocessors().isEmpty());
assertFalse(desc.getCoprocessors().contains(className1)); assertFalse(desc.getCoprocessors().contains(className1));
assertFalse(desc.getCoprocessors().contains(className2)); assertFalse(desc.getCoprocessors().contains(className2));
} }