Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Not A Problem
-
0.90.1, 0.90.2, 0.90.4, 0.92.0
-
None
-
None
Description
The HLog class (method findMemstoresWithEditsEqualOrOlderThan) has unnecessary if check in a loop.
static byte [][] findMemstoresWithEditsEqualOrOlderThan(final long oldestWALseqid,
final Map<byte [], Long> regionsToSeqids) {
// This method is static so it can be unit tested the easier.
List<byte []> regions = null;
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
if (e.getValue().longValue() <= oldestWALseqid)
}
return regions == null?
null: regions.toArray(new byte [][]
}
The following change is suggested
static byte [][] findMemstoresWithEditsEqualOrOlderThan(final long oldestWALseqid,
final Map<byte [], Long> regionsToSeqids) {
// This method is static so it can be unit tested the easier.
List<byte []> regions = new ArrayList<byte []>();
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
if (e.getValue().longValue() <= oldestWALseqid) { regions.add(e.getKey()); }
}
return regions.size() == 0?
null: regions.toArray(new byte [][] {HConstants.EMPTY_BYTE_ARRAY}
);
}