Details
Description
InvalidateBlocks.java
private final Map<DatanodeInfo, LightWeightHashSet<Block>> nodeToBlocks = new HashMap<>(); private final Map<DatanodeInfo, LightWeightHashSet<Block>> nodeToECBlocks = new HashMap<>(); ... private LightWeightHashSet<Block> getBlocksSet(final DatanodeInfo dn) { if (nodeToBlocks.containsKey(dn)) { return nodeToBlocks.get(dn); } return null; } private LightWeightHashSet<Block> getECBlocksSet(final DatanodeInfo dn) { if (nodeToECBlocks.containsKey(dn)) { return nodeToECBlocks.get(dn); } return null; }
There is no need to check for containsKey here since a call to get will already return 'null' if the key is not there. This just adds overhead of having to dive into the Map twice to get the value.
private LightWeightHashSet<Block> getECBlocksSet(final DatanodeInfo dn) { return nodeToECBlocks.get(dn); }