Package org.opends.server.types
Class CompactAttribute
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<ByteString>
-
- org.forgerock.opendj.ldap.AbstractAttribute
-
- org.opends.server.types.CompactAttribute
-
- All Implemented Interfaces:
Iterable<ByteString>,Collection<ByteString>,Set<ByteString>,Attribute
public final class CompactAttribute extends AbstractAttribute
A compact attribute represents values using a hash array map trie (HAMT) index and an array of encoded values. Experiments show that the average space required to store N values of M bytes is approximately N(M+5.5). This implementation has very compact encoding and reasonable membership operations approaching that of a hash table.
-
-
Constructor Summary
Constructors Constructor Description CompactAttribute(AttributeDescription attributeDescription, Collection<?> values)Creates a compact read-only attribute with the provided attribute description and values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CompactAttributecompactCopyOf(Attribute attribute)Returns a compact read-only attribute having the same attribute description and attribute values asattribute.booleancontains(Object o)Returnstrueif this attribute containsvalue.static CompactAttributedecodeValues(AttributeDescription attributeDescription, int size, ByteStringReader encodedValues)Returns a new compact read-only attribute with the provided attribute description, size andencoded values.ByteStringBuilderencodeValues(ByteStringBuilder builder)Encodes this attribute's values to the provided builder.AttributeDescriptiongetAttributeDescription()Returns the attribute description of this attribute, which includes its attribute type and any options.booleanisEmpty()Returnstrueif this attribute contains no attribute values.booleanisVirtual()Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).Iterator<ByteString>iterator()Returns an iterator over the attribute values in this attribute.booleanmatchesAnyNormalizedValue(Map<ByteString,ByteString> normalizedValues)Returnstrueif any values in this attribute match at least one of the values in the provided map.intsize()Returns the number of attribute values in this attribute.-
Methods inherited from class org.forgerock.opendj.ldap.AbstractAttribute
add, addAll, addAll, containsAll, equals, firstValue, forEachNormalizedValue, hashCode, matchesAnyNormalizedValue, normalizeValue, parse, removeAll, removeAll, retainAll, retainAll, toArray, toString
-
Methods inherited from class java.util.AbstractCollection
add, clear, remove, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.forgerock.opendj.ldap.Attribute
add, clear, firstValueAsString, getAttributeDescriptionAsString, isReal, put, put, remove, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Constructor Detail
-
CompactAttribute
public CompactAttribute(AttributeDescription attributeDescription, Collection<?> values)
Creates a compact read-only attribute with the provided attribute description and values.- Parameters:
attributeDescription- The attribute description.values- The values.
-
-
Method Detail
-
compactCopyOf
public static CompactAttribute compactCopyOf(Attribute attribute)
Returns a compact read-only attribute having the same attribute description and attribute values asattribute.- Parameters:
attribute- The attribute to be copied.- Returns:
- A compact read-only copy of the provided attribute.
-
decodeValues
public static CompactAttribute decodeValues(AttributeDescription attributeDescription, int size, ByteStringReader encodedValues)
Returns a new compact read-only attribute with the provided attribute description, size andencoded values.- Parameters:
attributeDescription- The attribute description.size- The number of attribute values.encodedValues- A reader over the encoded values.- Returns:
- A new compact read-only attribute.
-
encodeValues
public ByteStringBuilder encodeValues(ByteStringBuilder builder)
Encodes this attribute's values to the provided builder. The encoded values may be decoded usingdecodeValues(AttributeDescription, int, ByteStringReader).- Parameters:
builder- The builder.- Returns:
- The updated builder.
-
getAttributeDescription
public AttributeDescription getAttributeDescription()
Description copied from interface:AttributeReturns the attribute description of this attribute, which includes its attribute type and any options.- Returns:
- The attribute description.
-
isVirtual
public boolean isVirtual()
Description copied from interface:AttributeIndicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).- Returns:
trueif this is a virtual attribute.
-
isEmpty
public boolean isEmpty()
Description copied from interface:AttributeReturnstrueif this attribute contains no attribute values.- Specified by:
isEmptyin interfaceAttribute- Specified by:
isEmptyin interfaceCollection<ByteString>- Specified by:
isEmptyin interfaceSet<ByteString>- Overrides:
isEmptyin classAbstractAttribute- Returns:
trueif this attribute contains no attribute values.
-
size
public int size()
Description copied from interface:AttributeReturns the number of attribute values in this attribute.- Specified by:
sizein interfaceAttribute- Specified by:
sizein interfaceCollection<ByteString>- Specified by:
sizein interfaceSet<ByteString>- Overrides:
sizein classAbstractAttribute- Returns:
- The number of attribute values in this attribute.
-
contains
public boolean contains(Object o)
Description copied from interface:AttributeReturnstrueif this attribute containsvalue.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Specified by:
containsin interfaceAttribute- Specified by:
containsin interfaceCollection<ByteString>- Specified by:
containsin interfaceSet<ByteString>- Overrides:
containsin classAbstractAttribute- Parameters:
o- The attribute value whose presence in this attribute is to be tested.- Returns:
trueif this attribute containsvalue, orfalseif not.
-
matchesAnyNormalizedValue
public boolean matchesAnyNormalizedValue(Map<ByteString,ByteString> normalizedValues)
Description copied from interface:AttributeReturnstrueif any values in this attribute match at least one of the values in the provided map. Returnsfalseif this attribute is empty or if the provided map is empty. The map elements are mappings from normalized values to their corresponding values, where the normalized values must have been normalized according to this attribute's equality matching rule.NOTE: this method returns
trueif the intersection of the normalized values in this attribute and the normalized values of the provided map is not empty.- Specified by:
matchesAnyNormalizedValuein interfaceAttribute- Overrides:
matchesAnyNormalizedValuein classAbstractAttribute- Parameters:
normalizedValues- The map whose elements are mappings from normalized values to their corresponding values.- Returns:
trueif any values in this attribute are contained in the provided map.
-
iterator
public Iterator<ByteString> iterator()
Description copied from interface:AttributeReturns an iterator over the attribute values in this attribute. The attribute values are returned in no particular order, unless the implementation of this attribute provides such a guarantee.- Specified by:
iteratorin interfaceAttribute- Specified by:
iteratorin interfaceCollection<ByteString>- Specified by:
iteratorin interfaceIterable<ByteString>- Specified by:
iteratorin interfaceSet<ByteString>- Specified by:
iteratorin classAbstractAttribute- Returns:
- An iterator over the attribute values in this attribute.
-
-