Package com.itrsgroup.collection.instr
Class DimensionalMetricMap<T>
java.lang.Object
com.itrsgroup.collection.instr.DimensionalMetricMap<T>
- Type Parameters:
T- value type
Map optimized for storing values per metric/dimension combination.
Instances are safe for use by concurrent threads. It employs a ConcurrentHashMap
as the underlying storage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceMap value consumer.static interfaceMap value consumer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the map.computeIfAbsent(String namespace, String metric, Set<Dimension> dimensions, Function<Set<Dimension>, T> mappingFunction) computeIfAbsent(String metric, Set<Dimension> dimensions, Function<Set<Dimension>, T> mappingFunction) voidforEach(DimensionalMetricMap.Consumer<T> consumer) Iterate over all entries.voidforEach(DimensionalMetricMap.NamespacedConsumer<T> consumer) Iterate over all entries.Get a value.Get a value.Put a value, overwriting any existing value.Put a value, overwriting any existing value.Put a value only if it does not already exist.putIfAbsent(String metric, Set<Dimension> dimensions, T value) Put a value only if it does not already exist.Remove an entry from the map.Remove an entry from the map.
-
Constructor Details
-
DimensionalMetricMap
public DimensionalMetricMap()
-
-
Method Details
-
get
Get a value.- Parameters:
metric- metric namedimensions- dimensions- Returns:
- the value if it exists, otherwise null
-
get
Get a value.- Parameters:
namespace- metric namespacemetric- metric namedimensions- dimensions- Returns:
- the value if it exists, otherwise null
- Since:
- 5.4.0
-
put
Put a value, overwriting any existing value.- Parameters:
metric- metric namedimensions- dimensionsvalue- value- Returns:
- the previous value
-
put
Put a value, overwriting any existing value.- Parameters:
namespace- metric namespacemetric- metric namedimensions- dimensionsvalue- value- Returns:
- the previous value
- Since:
- 5.4.0
-
putIfAbsent
Put a value only if it does not already exist.- Parameters:
metric- metric namedimensions- dimensionsvalue- value to store only if there is not an existing value- Returns:
- null if a value did not exist, otherwise the existing value
-
putIfAbsent
Put a value only if it does not already exist.- Parameters:
namespace- metric namespacemetric- metric namedimensions- dimensionsvalue- value to store only if there is not an existing value- Returns:
- null if a value did not exist, otherwise the existing value
- Since:
- 5.4.0
-
computeIfAbsent
public T computeIfAbsent(String metric, Set<Dimension> dimensions, Function<Set<Dimension>, T> mappingFunction) - Parameters:
metric- metric namedimensions- dimensionsmappingFunction- the function to compute a value- Returns:
- the existing value if not null, otherwise the computed value
-
computeIfAbsent
public T computeIfAbsent(String namespace, String metric, Set<Dimension> dimensions, Function<Set<Dimension>, T> mappingFunction) - Parameters:
namespace- metric namespacemetric- metric namedimensions- dimensionsmappingFunction- the function to compute a value- Returns:
- the existing value if not null, otherwise the computed value
- Since:
- 5.4.0
-
forEach
Iterate over all entries.Iteration will halt if the consumer returns false for an entry.
- Parameters:
consumer- consumer
-
forEach
Iterate over all entries.Iteration will halt if the consumer returns false for an entry.
- Parameters:
consumer- consumer- Since:
- 5.4.0
-
remove
Remove an entry from the map.- Parameters:
metric- metricdimensions- dimensions- Returns:
- the previous value, or null if it did not exist
-
remove
Remove an entry from the map.- Parameters:
namespace- metric namespacemetric- metricdimensions- dimensions- Returns:
- the previous value, or null if it did not exist
- Since:
- 5.4.0
-
clear
public void clear()Clear the map.
-