Package nl.tue.storage.impl
Class CompressedStoreImpl<T>
- java.lang.Object
-
- nl.tue.storage.impl.CompressedStoreImpl<T>
-
- All Implemented Interfaces:
CompressedStore<T>
public class CompressedStoreImpl<T> extends java.lang.Object implements CompressedStore<T>
-
-
Field Summary
-
Fields inherited from interface nl.tue.storage.CompressedStore
BLOCKSIZE
-
-
Constructor Summary
Constructors Constructor Description CompressedStoreImpl(int alignment, Deflater<? super T> deflater)CompressedStoreImpl(int alignment, Deflater<? super T> deflater, Inflater<? extends T> inflater)CompressedStoreImpl(int alignment, Deflater<? super T> deflater, Inflater<? extends T> inflater, int blockSize)CompressedStoreImpl(Deflater<? super T> deflater)CompressedStoreImpl(Deflater<? super T> deflater, Inflater<? extends T> inflater)CompressedStoreImpl(Deflater<? super T> deflater, Inflater<? extends T> inflater, int blockSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddToStorage(T object)Adds a deflated version of the provided object to the storate.intgetAlignment()Returns the alignment of this storeintgetBlocksInUse()Returns the number of blocks in useInflater<? extends T>getInflater()Returns the inflater of this store;longgetMemory()Returns the used memory by this storageTgetObject(long index)Retrieves the object at a the given index.SkippableOutputStreamgetOutputStreamForObject(long index)This method returns an output stream for overwriting a previously stored object.longgetSize()Returns the number of bytes stored in the storeFastByteArrayInputStreamgetStreamForObject(long index)Retrieves the byte representation of an object at a the given indexlonggetUnusedMemory()Returns the unused memory by this storagelonggetWastedMemory()Returns the wasted memory by this storagevoidremoveAll()Removes all elements from the store and resets it to it's initial state
-
-
-
Constructor Detail
-
CompressedStoreImpl
public CompressedStoreImpl(Deflater<? super T> deflater, Inflater<? extends T> inflater)
-
CompressedStoreImpl
public CompressedStoreImpl(Deflater<? super T> deflater, Inflater<? extends T> inflater, int blockSize)
-
CompressedStoreImpl
public CompressedStoreImpl(int alignment, Deflater<? super T> deflater, Inflater<? extends T> inflater)
-
-
Method Detail
-
addToStorage
public long addToStorage(T object) throws StorageException
Description copied from interface:CompressedStoreAdds a deflated version of the provided object to the storate. The returned index is the location where this object can be retrieved from.- Specified by:
addToStoragein interfaceCompressedStore<T>- Returns:
- the index of the first byte in the store
- Throws:
StorageException
-
getStreamForObject
public FastByteArrayInputStream getStreamForObject(long index)
Description copied from interface:CompressedStoreRetrieves the byte representation of an object at a the given index- Specified by:
getStreamForObjectin interfaceCompressedStore<T>- Parameters:
index- the start index of the object, provided when storing- Returns:
- the byte[] representation of the object
-
getObject
public T getObject(long index) throws StorageException
Description copied from interface:CompressedStoreRetrieves the object at a the given index.- Specified by:
getObjectin interfaceCompressedStore<T>- Parameters:
index- the start index of the object, provided when storing- Returns:
- the object
- Throws:
StorageException
-
getSize
public long getSize()
Description copied from interface:CompressedStoreReturns the number of bytes stored in the store- Specified by:
getSizein interfaceCompressedStore<T>- Returns:
-
getMemory
public long getMemory()
Description copied from interface:CompressedStoreReturns the used memory by this storage- Specified by:
getMemoryin interfaceCompressedStore<T>
-
getWastedMemory
public long getWastedMemory()
Description copied from interface:CompressedStoreReturns the wasted memory by this storage- Specified by:
getWastedMemoryin interfaceCompressedStore<T>
-
getUnusedMemory
public long getUnusedMemory()
Description copied from interface:CompressedStoreReturns the unused memory by this storage- Specified by:
getUnusedMemoryin interfaceCompressedStore<T>
-
getInflater
public Inflater<? extends T> getInflater()
Description copied from interface:CompressedStoreReturns the inflater of this store;- Specified by:
getInflaterin interfaceCompressedStore<T>- Returns:
-
getAlignment
public int getAlignment()
Description copied from interface:CompressedStoreReturns the alignment of this store- Specified by:
getAlignmentin interfaceCompressedStore<T>- Returns:
-
getOutputStreamForObject
public SkippableOutputStream getOutputStreamForObject(long index)
Description copied from interface:CompressedStoreThis 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!- Specified by:
getOutputStreamForObjectin interfaceCompressedStore<T>- Returns:
-
removeAll
public void removeAll()
Description copied from interface:CompressedStoreRemoves all elements from the store and resets it to it's initial state- Specified by:
removeAllin interfaceCompressedStore<T>
-
getBlocksInUse
public int getBlocksInUse()
Description copied from interface:CompressedStoreReturns the number of blocks in use- Specified by:
getBlocksInUsein interfaceCompressedStore<T>- Returns:
-
-