Class ArrayLongCompressed


  • public class ArrayLongCompressed
    extends java.lang.Object
    This class compresses fixed-size long[] in a very fast and memory efficient manner if many leading and/or trailing bits of the stored longs are not used commonly. The internal data is never copied during the process of retrieving or reconstructing objects of this class and allows for fast I/O writing and reading of the underlying byte[]. Furthermore alomst no additinal data is used beside the underlying byte[]. Thereby the memory consumption of this data structure is kept at a minmum to build efficient long[] caches.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayLongCompressed​(byte[] bytes)
      Create LongArrayCompressed from bytes formerly got from toByteArray().
      ArrayLongCompressed​(int size, int leadingClearBits, int trailingClearBits)
      Create LongArrayCompressed from number of longs to be stored, the number of leading and trailing clear bits.
      ArrayLongCompressed​(long[] longs)
      Create LongArrayCompressed from longs representing the data to be stored in compressed form.
      ArrayLongCompressed​(long[] longs, int offset, int length)
      Create LongArrayCompressed from longs representing the data to be stored in compressed form (from offset to offset+length).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long get​(int index)
      Get value from the given index.
      void set​(int index, long value)
      Set value at the given index.
      byte[] toByteArray()
      Get bytes representing the internal data structure with which an LongArrayCompressed can be reconstructed.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayLongCompressed

        public ArrayLongCompressed​(byte[] bytes)
        Create LongArrayCompressed from bytes formerly got from toByteArray().
        Parameters:
        bytes - bytes formerly got from toByteArray()
      • ArrayLongCompressed

        public ArrayLongCompressed​(int size,
                                   int leadingClearBits,
                                   int trailingClearBits)
        Create LongArrayCompressed from number of longs to be stored, the number of leading and trailing clear bits. Everything else is stored in the internal data structure.
        Parameters:
        size - number of longs to be stored
        leadingClearBits - number of leading clear bits
        trailingClearBits - number of trailing clear bits
      • ArrayLongCompressed

        public ArrayLongCompressed​(long[] longs)
        Create LongArrayCompressed from longs representing the data to be stored in compressed form.
        Parameters:
        longs - longs representing the data to be stored in compressed form
      • ArrayLongCompressed

        public ArrayLongCompressed​(long[] longs,
                                   int offset,
                                   int length)
        Create LongArrayCompressed from longs representing the data to be stored in compressed form (from offset to offset+length).
        Parameters:
        longs - longs representing the data to be stored in compressed form
        offset - offset from which on to compress the longs
        length - number of longs to compress from the given array
    • Method Detail

      • set

        public void set​(int index,
                        long value)
        Set value at the given index.
        Parameters:
        index - index at which the value should be set
        value - value to be set at the given index
      • get

        public long get​(int index)
        Get value from the given index.
        Parameters:
        index - index at which the value should be set
        Returns:
        value found at the given index
      • toByteArray

        public byte[] toByteArray()
        Get bytes representing the internal data structure with which an LongArrayCompressed can be reconstructed.
        Returns:
        bytes representing the internal data structure with which an LongArrayCompressed can be reconstructed