
org.kairosdb.util.SummingMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kairosdb Show documentation
Show all versions of kairosdb Show documentation
KairosDB is a time series database that stores numeric values along
with key/value tags to a nosql data store. Currently supported
backends are Cassandra and H2. An H2 implementation is provided
for development work.
The newest version!
package org.kairosdb.util;
import java.util.HashMap;
public class SummingMap extends HashMap
{
@Override
public Long put(String key, Long value)
{
if (super.containsKey(key)) {
Long sum = super.get(key);
sum += value;
return super.put(key, sum);
}
else
{
return super.put(key, value);
}
}
public String getKeyForSmallestValue()
{
Long smallest = Long.MAX_VALUE;
String smallestKey = null;
for (Entry entry : super.entrySet()) {
if (entry.getValue() < smallest)
{
smallest = entry.getValue();
smallestKey = entry.getKey();
}
}
return smallestKey;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy