Constructor and Description |
---|
RunCodec(int k,
Codec aCodec,
Codec bCodec) |
Modifier and Type | Method and Description |
---|---|
int |
decode(InputStream in)
Decode a sequence of bytes from the given input stream, returning the value as a long.
|
int |
decode(InputStream in,
long last)
Decode a sequence of bytes from the given input stream, returning the value as a long.
|
int[] |
decodeInts(int n,
InputStream in)
Decodes a sequence of
n values from in . |
byte[] |
encode(int value)
Encode a single value into a sequence of bytes.
|
byte[] |
encode(int value,
int last)
Encode a single value into a sequence of bytes.
|
Codec |
getACodec() |
Codec |
getBCodec() |
int |
getK() |
String |
toString() |
decodeInts, encode
public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception
Pack200Exception
public int decode(InputStream in) throws IOException, Pack200Exception
Codec
decode
in class Codec
in
- the input stream to read fromIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if the encoding is a delta encodingpublic int decode(InputStream in, long last) throws IOException, Pack200Exception
Codec
long last = 0; while (condition) { last = codec.decode(in, last); // do something with last }
decode
in class Codec
in
- the input stream to read fromlast
- the previous value read, which must be supplied if the codec is a delta encodingIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if there is a problem decoding the value or that the value is invalidpublic int[] decodeInts(int n, InputStream in) throws IOException, Pack200Exception
Codec
n
values from in
. This should probably be used in most cases,
since some codecs (such as PopulationCodec
) only work when the number of values to be read is known.decodeInts
in class Codec
n
- the number of values to decodein
- the input stream to read fromint
values corresponding to values decodedIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if there is a problem decoding the value or that the value is invalidpublic byte[] encode(int value, int last) throws Pack200Exception
Codec
encode
in class Codec
value
- the value to encodelast
- the previous value encoded (for delta encodings)Pack200Exception
- TODOpublic byte[] encode(int value) throws Pack200Exception
Codec
encode
in class Codec
value
- the value to encodePack200Exception
- TODOpublic int getK()
Copyright © 2002–2022 The Apache Software Foundation. All rights reserved.