Package nl.tue.storage.compressor
Class CompressableCompressor<C extends Compressable>
- java.lang.Object
-
- nl.tue.storage.compressor.CompressableCompressor<C>
-
- Type Parameters:
C-
- All Implemented Interfaces:
Deflater<C>,EqualOperation<C>,HashOperation<C>,Inflater<C>
public class CompressableCompressor<C extends Compressable> extends java.lang.Object implements HashOperation<C>, EqualOperation<C>, Deflater<C>, Inflater<C>
A CompressableCompressor implements all the necessary interfaces to efficiently store objects in a CompressedHashSet.- Author:
- bfvdonge
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface nl.tue.storage.EqualOperation
EqualOperation.Default<K>
-
Nested classes/interfaces inherited from interface nl.tue.storage.HashOperation
HashOperation.Default<K>
-
-
Constructor Summary
Constructors Constructor Description CompressableCompressor(java.lang.Class<C> clazz)The compressor needs to be able to instantiate objects of the class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeflate(C object, java.io.OutputStream stream)deflate the given object into the provided stream.booleanequals(C object, CompressedStore<C> store, long l)Check for equality between a given object and a location in the store.intgetHashCode(C object)Return the hashCode of the objectintgetHashCode(CompressedStore<C> store, long l)Retrieve the object from the store and return its hashCode.intgetMaxByteCount()the method is called before each call to deflate.Cinflate(java.io.InputStream stream)read an object from a stream.
-
-
-
Constructor Detail
-
CompressableCompressor
public CompressableCompressor(java.lang.Class<C> clazz)
The compressor needs to be able to instantiate objects of the class. Therefore, the class needs to be provided in the constructor and this class should have an empty constructor, i.e. a constructor without parameters. - Parameters:
clazz-
-
-
Method Detail
-
inflate
public C inflate(java.io.InputStream stream) throws java.io.IOException
Description copied from interface:Inflaterread an object from a stream. The inflater should know when to stop reading and should NOT close the stream;- Specified by:
inflatein interfaceInflater<C extends Compressable>- Returns:
- Throws:
java.io.IOException
-
deflate
public void deflate(C object, java.io.OutputStream stream) throws java.io.IOException
Description copied from interface:Deflaterdeflate the given object into the provided stream. This method should NOT close the stream.- Specified by:
deflatein interfaceDeflater<C extends Compressable>- Throws:
java.io.IOException
-
equals
public boolean equals(C object, CompressedStore<C> store, long l) throws StorageException, java.io.IOException
Description copied from interface:EqualOperationCheck for equality between a given object and a location in the store. Should return true, if and only if the given object is indeed stored at index l in the store.- Specified by:
equalsin interfaceEqualOperation<C extends Compressable>- Returns:
- Throws:
StorageExceptionjava.io.IOException
-
getHashCode
public int getHashCode(C object)
Return the hashCode of the object- Specified by:
getHashCodein interfaceHashOperation<C extends Compressable>- Parameters:
object-- Returns:
-
getHashCode
public int getHashCode(CompressedStore<C> store, long l) throws StorageException
Retrieve the object from the store and return its hashCode. Requires the store to have a non-null inflater- Specified by:
getHashCodein interfaceHashOperation<C extends Compressable>- Parameters:
store-l-- Returns:
- Throws:
StorageException
-
getMaxByteCount
public int getMaxByteCount()
Description copied from interface:Deflaterthe method is called before each call to deflate. The call to deflate should not write more than the number of bytes returned by this method! It may write less. If a negative value is returned, then a resizeable buffer is used- Specified by:
getMaxByteCountin interfaceDeflater<C extends Compressable>- Returns:
-
-