Class 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 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 as attribute.
        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 and encoded 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.
      • getAttributeDescription

        public AttributeDescription getAttributeDescription()
        Description copied from interface: Attribute
        Returns 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: Attribute
        Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).
        Returns:
        true if this is a virtual attribute.
      • matchesAnyNormalizedValue

        public boolean matchesAnyNormalizedValue​(Map<ByteString,​ByteString> normalizedValues)
        Description copied from interface: Attribute
        Returns true if any values in this attribute match at least one of the values in the provided map. Returns false if 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 true if the intersection of the normalized values in this attribute and the normalized values of the provided map is not empty.

        Specified by:
        matchesAnyNormalizedValue in interface Attribute
        Overrides:
        matchesAnyNormalizedValue in class AbstractAttribute
        Parameters:
        normalizedValues - The map whose elements are mappings from normalized values to their corresponding values.
        Returns:
        true if any values in this attribute are contained in the provided map.