public class DebugInputBitStream extends InputBitStream
This class can be used to wrap an input bit stream. The semantics of the
resulting read operations is unchanged, but each operation will be logged. The
conventions are the same as those of DebugOutputBitStream
,
with the following additions:
avail, buffer, DEFAULT_BUFFER_SIZE, DELTA, fileChannel, fill, GAMMA, is, pos, position, repositionableStream, SHIFTED_GAMMA, wrapping, ZETA_3
Constructor and Description |
---|
DebugInputBitStream(InputBitStream ibs)
Creates a new debug input bit stream wrapping a given input bit stream and logging on standard error.
|
DebugInputBitStream(InputBitStream ibs,
PrintStream pw)
Creates a new debug input bit stream wrapping a given input bit stream and logging on a given writer.
|
Modifier and Type | Method and Description |
---|---|
void |
align()
Aligns the stream.
|
long |
available()
Returns the number of bits that can be read (or skipped over) from this
bit stream without blocking by the next caller of a method.
|
void |
close()
Closes the bit stream.
|
void |
flush()
Flushes the bit stream.
|
void |
position(long position)
Sets this stream bit position, if it is based on a
RepositionableStream or on a FileChannel . |
void |
read(byte[] bits,
int len)
Reads a sequence of bits.
|
int |
readBit()
Reads a bit.
|
long |
readBits()
Returns the number of bits read from this bit stream.
|
void |
readBits(long readBits)
Sets the number of bits read from this bit stream.
|
int |
readDelta()
Reads a natural number in δ coding.
|
int |
readGamma()
Reads a natural number in γ coding.
|
int |
readGolomb(int b)
Reads a natural number in Golomb coding.
|
int |
readGolomb(int b,
int log2b)
Reads a natural number in Golomb coding.
|
int |
readInt(int len)
Reads a fixed number of bits into an integer.
|
long |
readLong(int len)
Reads a fixed number of bits into a long.
|
long |
readLongDelta()
Reads a long natural number in δ coding.
|
long |
readLongGamma()
Reads a long natural number in γ coding.
|
long |
readLongGolomb(long b)
Reads a long natural number in Golomb coding.
|
long |
readLongGolomb(long b,
int log2b)
Reads a long natural number in Golomb coding.
|
long |
readLongMinimalBinary(long b)
Reads a long natural number in a limited range using a minimal binary coding.
|
long |
readLongMinimalBinary(long b,
int log2b)
Reads a long natural number in a limited range using a minimal binary coding.
|
long |
readLongNibble()
Reads a long natural number in variable-length nibble coding.
|
long |
readLongSkewedGolomb(long b)
Reads a long natural number in skewed Golomb coding.
|
long |
readLongUnary()
Reads a long natural number in unary coding.
|
long |
readLongZeta(int k)
Reads a long natural number in ζ coding.
|
int |
readMinimalBinary(int b)
Reads a natural number in a limited range using a minimal binary coding.
|
int |
readMinimalBinary(int b,
int log2b)
Reads a natural number in a limited range using a minimal binary coding.
|
int |
readNibble()
Reads a natural number in variable-length nibble coding.
|
int |
readSkewedGolomb(int b)
Reads a natural number in skewed Golomb coding.
|
int |
readUnary()
Reads a natural number in unary coding.
|
int |
readZeta(int k)
Reads a natural number in ζ coding.
|
void |
reset()
Repositions this bit stream to the position at the time the
InputBitStream.mark(int) method was last called. |
int |
skip(int n)
Deprecated.
|
long |
skip(long n)
Skips the given number of bits.
|
hasNext, mark, markSupported, nextBoolean, readDeltas, readGammas, readLongShiftedGamma, readShiftedGamma, readShiftedGammas, readZetas, skipDeltas, skipGammas, skipShiftedGammas, skipZetas
public DebugInputBitStream(InputBitStream ibs, PrintStream pw)
ibs
- the input bit stream to wrap.pw
- a print stream that will receive the logging data.public DebugInputBitStream(InputBitStream ibs)
ibs
- the input bit stream to wrap.public void align()
InputBitStream
align
in class InputBitStream
public long available() throws IOException
InputBitStream
available
in class InputBitStream
IOException
public void close() throws IOException
InputBitStream
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputBitStream
IOException
public void flush()
InputBitStream
This method is provided so that users of this class can easily wrap repositionable
streams (for instance, file-based streams, which can be repositioned using
the underlying FileChannel
). It is guaranteed that after calling
this method the underlying stream can be repositioned, and that the next read
will draw data from the stream.
flush
in interface Flushable
flush
in class InputBitStream
public void position(long position) throws IOException
InputBitStream
RepositionableStream
or on a FileChannel
.
Given an underlying stream that implements RepositionableStream
or that can provide a FileChannel
via the getChannel()
method,
a call to this method has the same semantics of a InputBitStream.flush()
,
followed by a call to position(position / 8)
on
the byte stream, followed by a skip(position % 8)
.
position
in class InputBitStream
position
- the new position expressed as a bit offset.IOException
FileChannel.position(long)
public void read(byte[] bits, int len) throws IOException
InputBitStream
read
in class InputBitStream
bits
- an array of bytes to store the result.len
- the number of bits to read.IOException
public int readBit() throws IOException
InputBitStream
readBit
in class InputBitStream
IOException
public long readBits()
InputBitStream
readBits
in class InputBitStream
public void readBits(long readBits)
InputBitStream
This method is provided so that, for instance, the
user can reset via readBits(0)
the read-bits count
after a InputBitStream.flush()
.
readBits
in class InputBitStream
readBits
- the new value for the number of bits read so far.public int readDelta() throws IOException
InputBitStream
readDelta
in class InputBitStream
IOException
OutputBitStream.writeDelta(int)
,
InputBitStream.skipDeltas(int)
public int readGamma() throws IOException
InputBitStream
readGamma
in class InputBitStream
IOException
OutputBitStream.writeGamma(int)
,
InputBitStream.skipGammas(int)
public int readGolomb(int b, int log2b) throws IOException
InputBitStream
InputBitStream.readGolomb(int)
because it does not
have to compute log2b
.
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readGolomb
in class InputBitStream
b
- the modulus for the coding.log2b
- the floor of the base-2 logarithm of the coding modulus.IOException
OutputBitStream.writeGolomb(int, int)
public int readGolomb(int b) throws IOException
InputBitStream
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readGolomb
in class InputBitStream
b
- the modulus for the coding.IOException
OutputBitStream.writeGolomb(int, int)
public int readInt(int len) throws IOException
InputBitStream
readInt
in class InputBitStream
len
- a bit length.len
bits are taken from the stream; the rest is zeroed.IOException
public long readLong(int len) throws IOException
InputBitStream
readLong
in class InputBitStream
len
- a bit length.len
bits are taken from the stream; the rest is zeroed.IOException
public long readLongDelta() throws IOException
InputBitStream
readLongDelta
in class InputBitStream
IOException
OutputBitStream.writeDelta(int)
,
InputBitStream.skipDeltas(int)
public long readLongGamma() throws IOException
InputBitStream
readLongGamma
in class InputBitStream
IOException
OutputBitStream.writeGamma(int)
,
InputBitStream.skipGammas(int)
public long readLongGolomb(long b, int log2b) throws IOException
InputBitStream
InputBitStream.readLongGolomb(long)
because it does not
have to compute log2b
.
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readLongGolomb
in class InputBitStream
b
- the modulus for the coding.log2b
- the floor of the base-2 logarithm of the coding modulus.IOException
OutputBitStream.writeGolomb(int, int)
public long readLongGolomb(long b) throws IOException
InputBitStream
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readLongGolomb
in class InputBitStream
b
- the modulus for the coding.IOException
OutputBitStream.writeGolomb(int, int)
public long readLongMinimalBinary(long b, int log2b) throws IOException
InputBitStream
InputBitStream.readLongMinimalBinary(long)
because it does not
have to compute log2b
.readLongMinimalBinary
in class InputBitStream
b
- a strict upper bound.log2b
- the floor of the base-2 logarithm of the bound.IOException
OutputBitStream.writeMinimalBinary(int, int)
public long readLongMinimalBinary(long b) throws IOException
InputBitStream
readLongMinimalBinary
in class InputBitStream
b
- a strict upper bound.IOException
OutputBitStream.writeMinimalBinary(int, int)
public long readLongNibble() throws IOException
InputBitStream
readLongNibble
in class InputBitStream
IOException
OutputBitStream.writeNibble(int)
public long readLongSkewedGolomb(long b) throws IOException
InputBitStream
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readLongSkewedGolomb
in class InputBitStream
b
- the modulus for the coding.IOException
OutputBitStream.writeSkewedGolomb(int, int)
public long readLongUnary() throws IOException
InputBitStream
readLongUnary
in class InputBitStream
IOException
OutputBitStream.writeUnary(int)
public long readLongZeta(int k) throws IOException
InputBitStream
readLongZeta
in class InputBitStream
k
- the shrinking factor.IOException
OutputBitStream.writeZeta(int, int)
public int readMinimalBinary(int b, int log2b) throws IOException
InputBitStream
InputBitStream.readMinimalBinary(int)
because it does not
have to compute log2b
.readMinimalBinary
in class InputBitStream
b
- a strict upper bound.log2b
- the floor of the base-2 logarithm of the bound.IOException
OutputBitStream.writeMinimalBinary(int, int)
public int readMinimalBinary(int b) throws IOException
InputBitStream
readMinimalBinary
in class InputBitStream
b
- a strict upper bound.IOException
OutputBitStream.writeMinimalBinary(int, int)
public int readNibble() throws IOException
InputBitStream
readNibble
in class InputBitStream
IOException
OutputBitStream.writeNibble(int)
public int readSkewedGolomb(int b) throws IOException
InputBitStream
This method implements also the case in which b
is 0: in this case,
nothing will be read, and 0 will be returned.
readSkewedGolomb
in class InputBitStream
b
- the modulus for the coding.IOException
OutputBitStream.writeSkewedGolomb(int, int)
public int readUnary() throws IOException
InputBitStream
readUnary
in class InputBitStream
IOException
OutputBitStream.writeUnary(int)
public int readZeta(int k) throws IOException
InputBitStream
readZeta
in class InputBitStream
k
- the shrinking factor.IOException
OutputBitStream.writeZeta(int, int)
public void reset() throws IOException
InputBitStream
InputBitStream.mark(int)
method was last called.
This method will just flush the stream
and delegate
the reset to the underlying InputStream
.
reset
in class InputBitStream
IOException
@Deprecated public int skip(int n)
InputBitStream
skip
in interface it.unimi.dsi.fastutil.booleans.BooleanIterator
skip
in class InputBitStream
n
- the number of bits to skip.public long skip(long n) throws IOException
InputBitStream
skip
in class InputBitStream
n
- the number of bits to skip.IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.