MCPcopy Create free account
hub / github.com/apache/impala / putOrUpdate

Method putOrUpdate

fe/src/main/java/org/apache/impala/util/TopNCache.java:87–97  ·  view source on GitHub ↗

Adds or updates an item in the cache. If the item already exists, its rank position is refreshed by removing and adding the item back to the cache. If the item is not in the cache and maximum capacity hasn't been reached, the item is added to the cache. Otherwise, the eviction policy is applied and

(T item)

Source from the content-addressed store, hash-verified

85 * lowest rank in the cache.
86 */
87 public synchronized void putOrUpdate(T item) {
88 if (!heap_.remove(item)) {
89 if (heap_.size() == maxCapacity_) {
90 if (!alwaysEvictAtCapacity_ && compareRanks(item, heap_.peek()) <= 0) {
91 return;
92 }
93 heap_.poll();
94 }
95 }
96 heap_.add(item);
97 }
98
99 /**
100 * Removes an item from the cache.

Calls 6

compareRanksMethod · 0.95
removeMethod · 0.45
sizeMethod · 0.45
peekMethod · 0.45
pollMethod · 0.45
addMethod · 0.45