Interface CompressedStore<T>

  • Type Parameters:
    T -
    All Known Implementing Classes:
    CompressedStoreImpl

    public interface CompressedStore<T>
    Implementation of this compressed store is not thread safe. Hence writing by multiple threads should be synchronized on this objects monitor. Since the store is immutable, reading a previously written object back can be done asynchronously and in parallel with writing7.
    Author:
    bfvdonge
    • Field Detail

      • BLOCKSIZE

        static final int BLOCKSIZE
        size of each block. Defaults to 512 kBytes. Better to have more blocks when doing parallel processing
        See Also:
        Constant Field Values
    • Method Detail

      • addToStorage

        long addToStorage​(T object)
                   throws StorageException
        Adds a deflated version of the provided object to the storate. The returned index is the location where this object can be retrieved from.
        Parameters:
        object -
        Returns:
        the index of the first byte in the store
        Throws:
        StorageException
      • getStreamForObject

        FastByteArrayInputStream getStreamForObject​(long index)
        Retrieves the byte representation of an object at a the given index
        Parameters:
        index - the start index of the object, provided when storing
        Returns:
        the byte[] representation of the object
      • getOutputStreamForObject

        SkippableOutputStream getOutputStreamForObject​(long index)
        This method returns an output stream for overwriting a previously stored object. It is essential that this method is used with caution, as no checks are performed to avoid writing into the memory space of the next object!
        Parameters:
        index -
        Returns:
      • getObject

        T getObject​(long index)
             throws StorageException
        Retrieves the object at a the given index.
        Parameters:
        index - the start index of the object, provided when storing
        Returns:
        the object
        Throws:
        StorageException
      • getSize

        long getSize()
        Returns the number of bytes stored in the store
        Returns:
      • getMemory

        long getMemory()
        Returns the used memory by this storage
      • getWastedMemory

        long getWastedMemory()
        Returns the wasted memory by this storage
      • getUnusedMemory

        long getUnusedMemory()
        Returns the unused memory by this storage
      • getInflater

        Inflater<? extends T> getInflater()
        Returns the inflater of this store;
        Returns:
      • getAlignment

        int getAlignment()
        Returns the alignment of this store
        Returns:
      • removeAll

        void removeAll()
        Removes all elements from the store and resets it to it's initial state
      • getBlocksInUse

        int getBlocksInUse()
        Returns the number of blocks in use
        Returns: