Package nl.tue.astar.impl
Class AbstractCompressor<H>
- java.lang.Object
-
- nl.tue.astar.impl.AbstractCompressor<H>
-
-
Field Summary
Fields Modifier and Type Field Description protected static int[]POWER
-
Constructor Summary
Constructors Constructor Description AbstractCompressor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckIntOnByteArray(java.io.InputStream stream, int i)protected booleancheckShortOnByteArray(java.io.InputStream stream, short i)protected voiddeflate(short[] object, java.io.OutputStream stream, int length)protected voiddeflate(ShortShortMultiset object, java.io.OutputStream stream, int length)protected booleandeflateWithCheck(ShortShortMultiset object, int length, java.io.InputStream input)protected booleanequalsDeflating(H head, CompressedStore<?> store, long l)static intgetBitsPerVar(byte[] vars)static intgetBitsPerVar(short[] vars)protected ShortShortMultisetinflateContent(java.io.InputStream stream, int[] ids, short length)protected short[]inflateContentToArray(java.io.InputStream stream, int[] ids, short length)protected static BitMaskmakeBitMask(int size, short[] values)protected static BitMaskmakeBitMask(int size, ShortShortMultiset indices)protected static BitMaskmakeShortListBitMask(int size, short[] marking)protected booleanreadBooleanFromStream(java.io.InputStream stream)protected doublereadDoubleFromStream(java.io.InputStream stream)Return the first eight bytes as an longprotected intreadIntFromStream(java.io.InputStream stream)Return the first four bytes as an integerstatic voidreadInto(byte[] toRead, byte[] vars, int bitsPerVar)reads a byte[] of vars from a byte[] toRead, where each element of vars is encoded using precisely bitsPerVar bits.static voidreadInto(byte[] toRead, short[] vars, int bitsPerVar)reads a byte[] of vars from a byte[] toRead, where each element of vars is encoded using precisely bitsPerVar bits.protected longreadLongFromStream(java.io.InputStream stream)Return the first eight bytes as an longprotected BitMaskreadMask(java.io.InputStream stream, int length, int numBytes)protected shortreadShortFromStream(java.io.InputStream stream)protected voidwriteBooleanToByteArray(java.io.OutputStream stream, boolean b)protected voidwriteDoubleToByteArray(java.io.OutputStream stream, double v)Write 4 bytes of an integerprotected voidwriteIntToByteArray(java.io.OutputStream out, int v)Write 4 bytes of an integerprotected voidwriteLongToByteArray(java.io.OutputStream stream, long v)protected voidwriteShortToByteArray(java.io.OutputStream stream, short i)static voidwriteTo(byte[] toWrite, byte[] vars, int bitsPerVar)writes a byte[] of vars into a byte[] toWrite, where each element of vars is encoded using precisely bitsPerVar bits.static voidwriteTo(byte[] toWrite, short[] vars, int bitsPerVar)writes a byte[] of vars into a byte[] toWrite, where each element of vars is encoded using precisely bitsPerVar bits.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface nl.tue.storage.Deflater
deflate, getMaxByteCount
-
-
-
-
Method Detail
-
readMask
protected BitMask readMask(java.io.InputStream stream, int length, int numBytes) throws java.io.IOException
- Throws:
java.io.IOException
-
inflateContent
protected ShortShortMultiset inflateContent(java.io.InputStream stream, int[] ids, short length) throws java.io.IOException
- Throws:
java.io.IOException
-
inflateContentToArray
protected short[] inflateContentToArray(java.io.InputStream stream, int[] ids, short length) throws java.io.IOException- Throws:
java.io.IOException
-
writeShortToByteArray
protected void writeShortToByteArray(java.io.OutputStream stream, short i) throws java.io.IOException- Throws:
java.io.IOException
-
writeBooleanToByteArray
protected void writeBooleanToByteArray(java.io.OutputStream stream, boolean b) throws java.io.IOException- Throws:
java.io.IOException
-
checkShortOnByteArray
protected boolean checkShortOnByteArray(java.io.InputStream stream, short i) throws java.io.IOException- Throws:
java.io.IOException
-
readShortFromStream
protected short readShortFromStream(java.io.InputStream stream) throws java.io.IOException- Throws:
java.io.IOException
-
writeIntToByteArray
protected void writeIntToByteArray(java.io.OutputStream out, int v) throws java.io.IOExceptionWrite 4 bytes of an integer- Parameters:
stream-next-- Throws:
java.io.IOException
-
writeLongToByteArray
protected void writeLongToByteArray(java.io.OutputStream stream, long v) throws java.io.IOException- Throws:
java.io.IOException
-
writeDoubleToByteArray
protected void writeDoubleToByteArray(java.io.OutputStream stream, double v) throws java.io.IOExceptionWrite 4 bytes of an integer- Parameters:
stream-next-- Throws:
java.io.IOException
-
checkIntOnByteArray
protected boolean checkIntOnByteArray(java.io.InputStream stream, int i) throws java.io.IOException- Throws:
java.io.IOException
-
readDoubleFromStream
protected double readDoubleFromStream(java.io.InputStream stream) throws java.io.IOExceptionReturn the first eight bytes as an long- Parameters:
stream-- Returns:
- Throws:
java.io.IOException
-
readLongFromStream
protected long readLongFromStream(java.io.InputStream stream) throws java.io.IOExceptionReturn the first eight bytes as an long- Parameters:
stream-- Returns:
- Throws:
java.io.IOException
-
readIntFromStream
protected int readIntFromStream(java.io.InputStream stream) throws java.io.IOExceptionReturn the first four bytes as an integer- Parameters:
stream-- Returns:
- Throws:
java.io.IOException
-
readBooleanFromStream
protected boolean readBooleanFromStream(java.io.InputStream stream) throws java.io.IOException- Throws:
java.io.IOException
-
deflate
protected void deflate(ShortShortMultiset object, java.io.OutputStream stream, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
deflate
protected void deflate(short[] object, java.io.OutputStream stream, int length) throws java.io.IOException- Throws:
java.io.IOException
-
deflateWithCheck
protected boolean deflateWithCheck(ShortShortMultiset object, int length, java.io.InputStream input) throws java.io.IOException
- Throws:
java.io.IOException
-
makeBitMask
protected static BitMask makeBitMask(int size, ShortShortMultiset indices)
-
makeBitMask
protected static BitMask makeBitMask(int size, short[] values)
-
makeShortListBitMask
protected static BitMask makeShortListBitMask(int size, short[] marking)
-
equalsDeflating
protected boolean equalsDeflating(H head, CompressedStore<?> store, long l)
-
writeTo
public static void writeTo(byte[] toWrite, byte[] vars, int bitsPerVar)writes a byte[] of vars into a byte[] toWrite, where each element of vars is encoded using precisely bitsPerVar bits. If bitsPerVar == 8, the result is identical to the input- Parameters:
toWrite- the byte[] to write to. The size should be at least Math.ceil(vars.length/8*bitsPerVar)vars- the byte[] to encode.bitsPerVar- the number of bits per element of var. For all i: vars[i] < (1 << bitsPerVar)
-
readInto
public static void readInto(byte[] toRead, byte[] vars, int bitsPerVar)reads a byte[] of vars from a byte[] toRead, where each element of vars is encoded using precisely bitsPerVar bits.- Parameters:
toRead- the byte[] to read from. The size should be at least Math.ceil(vars.length/8*bitsPerVar)vars- the byte[] to fill.bitsPerVar- the number of bits per element of var. For all i: vars[i] < (1 << bitsPerVar)
-
getBitsPerVar
public static int getBitsPerVar(byte[] vars)
-
getBitsPerVar
public static int getBitsPerVar(short[] vars)
-
writeTo
public static void writeTo(byte[] toWrite, short[] vars, int bitsPerVar)writes a byte[] of vars into a byte[] toWrite, where each element of vars is encoded using precisely bitsPerVar bits. If bitsPerVar == 8, the result is identical to the input- Parameters:
toWrite- the byte[] to write to. The size should be at least Math.ceil(vars.length/8*bitsPerVar)vars- the byte[] to encode.bitsPerVar- the number of bits per element of var. For all i: vars[i] < (1 << bitsPerVar)
-
readInto
public static void readInto(byte[] toRead, short[] vars, int bitsPerVar)reads a byte[] of vars from a byte[] toRead, where each element of vars is encoded using precisely bitsPerVar bits.- Parameters:
toRead- the byte[] to read from. The size should be at least Math.ceil(vars.length/8*bitsPerVar)vars- the byte[] to fill.bitsPerVar- the number of bits per element of var. For all i: vars[i] < (1 << bitsPerVar)
-
-