V put(K k, Supplier<V> supplier) {
    return ((Payload<V>) map.compute(k, (k1, oldValue) -> {
      if (oldValue != null) {
        oldValue.refCount++;
        return oldValue;
      } else {
        return new Payload(supplier.get());
      }
    })).v;
  }
A map of K to V, but does ref counting for added and removed values. The values are not added
directly, but instead requested from the given Supplier if ref count == 0. Each put() call will
increment the ref count, and each remove() will decrement it. The values are removed from the map
iff ref count == 0.
hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/RefCountingMap.java