Class MutableRoaringArray

    • Constructor Detail

      • MutableRoaringArray

        protected MutableRoaringArray()
      • MutableRoaringArray

        public MutableRoaringArray​(int initialCapacity)
    • Method Detail

      • advanceUntil

        public int advanceUntil​(short 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.
      • appendCopiesAfter

        protected void appendCopiesAfter​(PointableRoaringArray highLowContainer,
                                         short beforeStart)
        Append copies of the values AFTER a specified key (may or may not be present) to end.
        Parameters:
        highLowContainer - the other array
        beforeStart - given key is the largest key that we won't copy
      • appendCopiesUntil

        protected void appendCopiesUntil​(PointableRoaringArray highLowContainer,
                                         short stoppingKey)
        Append copies of the values from another array, from the start
        Parameters:
        highLowContainer - the other array
        stoppingKey - any equal or larger key in other array will terminate copying
      • appendCopy

        protected void appendCopy​(PointableRoaringArray highLowContainer,
                                  int startingIndex,
                                  int end)
        Append copies of the values from another array
        Parameters:
        highLowContainer - other array
        startingIndex - starting index in the other array
        end - last index array in the other array
      • clear

        protected void clear()
      • trim

        public void trim()
        If possible, recover wasted memory.
      • copyRange

        protected void copyRange​(int begin,
                                 int end,
                                 int newBegin)
      • deserialize

        public void deserialize​(DataInput in)
                         throws IOException
        Deserialize.
        Parameters:
        in - the DataInput stream
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • deserialize

        public void deserialize​(ByteBuffer bbf)
        Deserialize (retrieve) this bitmap. See format specification at https://github.com/RoaringBitmap/RoaringFormatSpec The current bitmap is overwritten. It is not necessary that limit() on the input ByteBuffer indicates the end of the serialized data. After loading this RoaringBitmap, you can advance to the rest of the data (if there is more) by setting bbf.position(bbf.position() + bitmap.serializedSizeInBytes()); Note that 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 byte buffer (can be mapped, direct, array backed etc.
      • extendArray

        protected void extendArray​(int k)
      • getCardinality

        public int getCardinality​(int i)
        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:
        i - index
        Returns:
        the cardinality
      • getContainerIndex

        public int getContainerIndex​(short 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)
      • getIndex

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

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

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

        protected int headerSize()
      • insertNewKeyValueAt

        protected void insertNewKeyValueAt​(int i,
                                           short key,
                                           MappeableContainer value)
      • removeAtIndex

        protected void removeAtIndex​(int i)
      • removeIndexRange

        protected void removeIndexRange​(int begin,
                                        int end)
      • replaceKeyAndContainerAtIndex

        protected void replaceKeyAndContainerAtIndex​(int i,
                                                     short key,
                                                     MappeableContainer c)
      • resize

        protected void resize​(int newLength)
      • serialize

        public void serialize​(ByteBuffer buffer)
        Serialize. The current bitmap is not modified.
        Specified by:
        serialize in interface PointableRoaringArray
        Parameters:
        buffer - the ByteBuffer to write to
      • serializedSizeInBytes

        public int serializedSizeInBytes()
        Report the number of bytes required for serialization.
        Specified by:
        serializedSizeInBytes in interface PointableRoaringArray
        Returns:
        the size in bytes
      • setContainerAtIndex

        protected void setContainerAtIndex​(int i,
                                           MappeableContainer c)
      • containsForContainerAtIndex

        public boolean containsForContainerAtIndex​(int i,
                                                   short 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