Class RoaringArray

    • Constructor Detail

      • RoaringArray

        protected RoaringArray()
    • Method Detail

      • advanceUntil

        protected int advanceUntil​(short x,
                                   int pos)
        Find the smallest integer index larger than pos such that array[index].key>=x. If none can be found, return size. Based on code by O. Kaser.
        Parameters:
        x - minimal value
        pos - index to exceed
        Returns:
        the smallest index greater than pos such that array[index].key is at least as large as min, or size if it is not possible.
      • append

        public void append​(short key,
                           Container value)
        Description copied from interface: AppendableStorage
        Appends the key and container to the storage, throws if the key is less than the current mark.
        Specified by:
        append in interface AppendableStorage<Container>
        Parameters:
        key - the key to append
        value - the data to append
      • appendCopiesAfter

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

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

        protected void appendCopy​(RoaringArray sa,
                                  int index)
        Append copy of the one value from another array
        Parameters:
        sa - other array
        index - index in the other array
      • appendCopy

        protected void appendCopy​(RoaringArray sa,
                                  int startingIndex,
                                  int end)
        Append copies of the values from another array
        Parameters:
        sa - other array
        startingIndex - starting index in the other array
        end - endingIndex (exclusive) in the other array
      • append

        protected void append​(RoaringArray sa,
                              int startingIndex,
                              int end)
        Append the values from another array, no copy is made (use with care)
        Parameters:
        sa - other array
        startingIndex - starting index in the other array
        end - endingIndex (exclusive) 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,
                                byte[] buffer)
                         throws IOException
        Deserialize.
        Parameters:
        in - the DataInput stream
        buffer - The buffer gets overwritten with data during deserialization. You can pass a NULL reference as a buffer. A buffer containing at least 8192 bytes might be ideal for performance. It is recommended to reuse the buffer between calls to deserialize (in a single-threaded context) for best performance.
        Throws:
        IOException - Signals that an I/O exception has occurred.
        InvalidRoaringFormat - if a Roaring Bitmap cookie is missing.
      • 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)
      • getContainer

        protected Container getContainer​(short x)
      • getContainerAtIndex

        protected Container getContainerAtIndex​(int i)
      • getContainerPointer

        public ContainerPointer getContainerPointer()
        Create a ContainerPointer for this RoaringArray
        Returns:
        a ContainerPointer
      • getContainerPointer

        public ContainerPointer getContainerPointer​(int startIndex)
        Create a ContainerPointer for this RoaringArray
        Parameters:
        startIndex - starting index in the container list
        Returns:
        a ContainerPointer
      • getIndex

        protected int getIndex​(short x)
      • getKeyAtIndex

        protected short getKeyAtIndex​(int i)
      • hashCode

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

        protected int headerSize()
      • insertNewKeyValueAt

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

        protected void removeAtIndex​(int i)
      • removeIndexRange

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

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

        protected void resize​(int newLength)
      • serialize

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

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

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

        protected void setContainerAtIndex​(int i,
                                           Container c)
      • size

        protected int size()
      • first

        public int first()
        Gets the first value in the array
        Returns:
        the first value in the array
        Throws:
        NoSuchElementException - if empty
      • last

        public int last()
        Gets the last value in the array
        Returns:
        the last value in the array
        Throws:
        NoSuchElementException - if empty