diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java index bdac161..829e1ea 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java @@ -164,8 +164,8 @@ public AggrColStats get(String dbName, String tblName, String colName, List nodes = candidateList.nodes; - if (nodes.size() == 0) { + if (nodes.isEmpty()) { mapIterator.remove(); continue; } @@ -359,7 +359,7 @@ public void run() { } } } catch (InterruptedException e) { - LOG.debug("Interrupted Exception ignored ",e); + LOG.debug("Interrupted Exception ignored", e); } finally { if (isLocked) { candidateList.writeLock.unlock(); @@ -447,7 +447,7 @@ private void evictOneNode() { numRemovedLRU++; } } catch (InterruptedException e) { - LOG.debug("Interrupted Exception ignored ",e); + LOG.debug("Interrupted Exception ignored", e); } finally { if (isLocked) { candidateList.writeLock.unlock(); @@ -468,28 +468,41 @@ private boolean isExpired(AggrColStats aggrColStats) { private final String colName; Key(String db, String table, String col) { - // Don't construct an illegal cache key - if ((db == null) || (table == null) || (col == null)) { - throw new IllegalArgumentException("dbName, tblName, colName can't be null"); + this(db, table, col, false); + } + + Key(String db, String table, String col, boolean intern) { + // A legal cache key must be filled in + if (db == null || table == null || col == null) { + throw new IllegalArgumentException("dbName, tblName, colName cannot be null"); } - dbName = db; - tblName = table; + dbName = (intern) ? db.intern() : db; + tblName = (intern) ? table.intern() : table; colName = col; } @Override - public boolean equals(Object other) { - if ((other == null) || !(other instanceof Key)) { - return false; - } - Key that = (Key) other; - return dbName.equals(that.dbName) && tblName.equals(that.tblName) - && colName.equals(that.colName); + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + colName.hashCode(); + result = prime * result + dbName.hashCode(); + result = prime * result + tblName.hashCode(); + return result; } @Override - public int hashCode() { - return dbName.hashCode() * 31 + tblName.hashCode() * 31 + colName.hashCode(); + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Key other = (Key) obj; + return (other.colName.equals(colName) && + other.tblName.equals(tblName) && + other.dbName.equals(dbName)); } @Override