Class ImmutableRoaringArray

  • All Implemented Interfaces:
    java.lang.Cloneable, PointableRoaringArray

    public final class ImmutableRoaringArray
    extends java.lang.Object
    implements PointableRoaringArray
    This is the underlying data structure for an ImmutableRoaringBitmap. This class is not meant for end-users.
    • Field Detail

      • SERIAL_COOKIE_NO_RUNCONTAINER

        protected static final short SERIAL_COOKIE_NO_RUNCONTAINER
        See Also:
        Constant Field Values
    • Constructor Detail

      • ImmutableRoaringArray

        protected ImmutableRoaringArray​(java.nio.ByteBuffer bbf)
        Create an array based on a previously serialized ByteBuffer. The input ByteBuffer is effectively copied (with the slice operation) so you should expect the provided ByteBuffer position/mark/limit/order to remain unchanged.
        Parameters:
        bbf - The source ByteBuffer
    • Method Detail

      • advanceUntil

        public int advanceUntil​(char x,
                                int pos)
        Description copied from interface: PointableRoaringArray
        Find the smallest integer index larger than pos such that getKeyAtIndex(index)>=x. If none can be found, return size.
        Specified by:
        advanceUntil in interface PointableRoaringArray
        Parameters:
        x - minimal value
        pos - index to exceed
        Returns:
        the smallest index greater than pos such that getKeyAtIndex(index) is at least as large as min, or size if it is not possible.
      • getCardinality

        public int getCardinality​(int k)
        Description copied from interface: PointableRoaringArray
        Returns the cardinality of the container at the given index. This method is expected to be fast.
        Specified by:
        getCardinality in interface PointableRoaringArray
        Parameters:
        k - index
        Returns:
        the cardinality
      • getContainerIndex

        public int getContainerIndex​(char x)
        Description copied from interface: PointableRoaringArray
        Returns either the index of the container corresponding to key x, or a negative value.
        Specified by:
        getContainerIndex in interface PointableRoaringArray
        Parameters:
        x - 16-bit key
        Returns:
        index of container (negative value if no container found)
      • containsForContainerAtIndex

        public boolean containsForContainerAtIndex​(int i,
                                                   char x)
        Description copied from interface: PointableRoaringArray
        This checks whether the container at index i has the value x. This can be faster than calling "getContainerAtIndex" and then calling contains.
        Specified by:
        containsForContainerAtIndex in interface PointableRoaringArray
        Parameters:
        i - container index (assumed to be non-negative)
        x - 16-bit value to check
        Returns:
        whether the container contains at index i contains x
      • getIndex

        public int getIndex​(char x)
        Specified by:
        getIndex in interface PointableRoaringArray
        Parameters:
        x - 16-bit key
        Returns:
        corresponding index
      • getKeyAtIndex

        public char getKeyAtIndex​(int i)
        Specified by:
        getKeyAtIndex in interface PointableRoaringArray
        Parameters:
        i - the index
        Returns:
        16-bit key at the index
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • headerSize

        protected int headerSize​(boolean hasrun)
      • isEmpty

        public boolean isEmpty()
        Returns true if this bitmap is empty.
        Returns:
        true if empty
      • serialize

        public void serialize​(java.io.DataOutput out)
                       throws java.io.IOException
        Serialize. The current bitmap is not modified.
        Specified by:
        serialize in interface PointableRoaringArray
        Parameters:
        out - the DataOutput stream
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • serialize

        public void serialize​(java.nio.ByteBuffer buffer)
        Description copied from interface: PointableRoaringArray
        Serialize. The current bitmap is not modified.
        Specified by:
        serialize in interface PointableRoaringArray
        Parameters:
        buffer - the buffer to serialize to