Class FilteredAttributes
- java.lang.Object
-
- io.opentelemetry.sdk.metrics.internal.view.FilteredAttributes
-
- All Implemented Interfaces:
Attributes
- Direct Known Subclasses:
FilteredAttributes.RegularFilteredAttributes,FilteredAttributes.SmallFilteredAttributes
abstract class FilteredAttributes extends java.lang.Object implements Attributes
Filtered attributes is a filtered view of aImmutableKeyValuePairsbackedAttributesinstance. Rather than creating an entirely new attributes instance, it keeps track of which source attributes are excluded while implementing theAttributesinterface.Notably, the
equals(Object)andhashCode()depend on comparison against otherFilteredAttributesinstances. This means that whereFilteredAttributesis used for things like map keys, it must be used for all keys in that map. You cannot mixAttributesimplementations. This is also true for the default attributes implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFilteredAttributes.RegularFilteredAttributesImplementation that can handle attributes of arbitrary size by storing filter status in aBitSet.private static classFilteredAttributes.SmallFilteredAttributesImplementation that relies on the source having less thanFilteredAttributes.SmallFilteredAttributes.BITS_PER_INTEGERattributes, and storing entry filter status in the bits of an integer.
-
Field Summary
Fields Modifier and Type Field Description private inthashcodeprivate intsizeprivate java.lang.Object[]sourceData
-
Constructor Summary
Constructors Modifier Constructor Description privateFilteredAttributes(java.lang.Object[] sourceData, int hashcode, int size)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Map<AttributeKey<?>,java.lang.Object>asMap()Returns a read-only view of thisAttributesas aMap.private static AttributesconvertToStandardImplementation(Attributes source)(package private) static Attributescreate(Attributes source, java.util.Set<AttributeKey<?>> includedKeys)Create aFilteredAttributesinstance.booleanequals(java.lang.Object object)voidforEach(java.util.function.BiConsumer<? super AttributeKey<?>,? super java.lang.Object> consumer)Iterates over all the key-value pairs of attributes contained by this instance.<T> Tget(AttributeKey<T> key)Returns the value for the givenAttributeKey, ornullif not found.inthashCode()(package private) abstract booleanincludeIndexInOutput(int sourceIndex)booleanisEmpty()Whether there are any attributes contained in this.private static <T> voidputInBuilder(AttributesBuilder builder, AttributeKey<T> key, T value)intsize()The number of attributes contained in this.AttributesBuildertoBuilder()Returns a newAttributesBuilderinstance populated with the data of thisAttributes.java.lang.StringtoString()
-
-
-
Method Detail
-
create
static Attributes create(Attributes source, java.util.Set<AttributeKey<?>> includedKeys)
Create aFilteredAttributesinstance.- Parameters:
source- the source attributes, which SHOULD be based on the standardImmutableKeyValuePairs. If not, the source will first be converted to the standard implementation.includedKeys- the set of attribute keys to include in the output.
-
convertToStandardImplementation
private static Attributes convertToStandardImplementation(Attributes source)
-
get
@Nullable public <T> T get(AttributeKey<T> key)
Description copied from interface:AttributesReturns the value for the givenAttributeKey, ornullif not found.- Specified by:
getin interfaceAttributes
-
forEach
public void forEach(java.util.function.BiConsumer<? super AttributeKey<?>,? super java.lang.Object> consumer)
Description copied from interface:AttributesIterates over all the key-value pairs of attributes contained by this instance.- Specified by:
forEachin interfaceAttributes
-
size
public int size()
Description copied from interface:AttributesThe number of attributes contained in this.- Specified by:
sizein interfaceAttributes
-
isEmpty
public boolean isEmpty()
Description copied from interface:AttributesWhether there are any attributes contained in this.- Specified by:
isEmptyin interfaceAttributes
-
asMap
public java.util.Map<AttributeKey<?>,java.lang.Object> asMap()
Description copied from interface:AttributesReturns a read-only view of thisAttributesas aMap.- Specified by:
asMapin interfaceAttributes
-
toBuilder
public AttributesBuilder toBuilder()
Description copied from interface:AttributesReturns a newAttributesBuilderinstance populated with the data of thisAttributes.- Specified by:
toBuilderin interfaceAttributes
-
putInBuilder
private static <T> void putInBuilder(AttributesBuilder builder, AttributeKey<T> key, T value)
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
includeIndexInOutput
abstract boolean includeIndexInOutput(int sourceIndex)
-
-