|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.Varint
public final class Varint
Encodes signed and unsigned values using a common variable-length scheme, found for example in Google's Protocol Buffers. It uses fewer bytes to encode smaller values, but will use slightly more bytes to encode large values.
Signed values are further encoded using so-called zig-zag encoding in order to make them "compatible" with variable-length encoding.
Method Summary | |
---|---|
static int |
readSignedVarInt(java.io.DataInput in)
|
static long |
readSignedVarLong(java.io.DataInput in)
|
static int |
readUnsignedVarInt(java.io.DataInput in)
|
static long |
readUnsignedVarLong(java.io.DataInput in)
|
static void |
writeSignedVarInt(int value,
java.io.DataOutput out)
|
static void |
writeSignedVarLong(long value,
java.io.DataOutput out)
Encodes a value using the variable-length encoding from Google Protocol Buffers. |
static void |
writeUnsignedVarInt(int value,
java.io.DataOutput out)
|
static void |
writeUnsignedVarLong(long value,
java.io.DataOutput out)
Encodes a value using the variable-length encoding from Google Protocol Buffers. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void writeSignedVarLong(long value, java.io.DataOutput out) throws java.io.IOException
writeUnsignedVarLong(long, DataOutput)
should be used.
value
- value to encodeout
- to write bytes to
java.io.IOException
- if DataOutput
throws IOException
public static void writeUnsignedVarLong(long value, java.io.DataOutput out) throws java.io.IOException
writeSignedVarLong(long, DataOutput)
instead. This method treats negative input as like a large unsigned value.
value
- value to encodeout
- to write bytes to
java.io.IOException
- if DataOutput
throws IOException
public static void writeSignedVarInt(int value, java.io.DataOutput out) throws java.io.IOException
java.io.IOException
writeSignedVarLong(long, DataOutput)
public static void writeUnsignedVarInt(int value, java.io.DataOutput out) throws java.io.IOException
java.io.IOException
writeUnsignedVarLong(long, DataOutput)
public static long readSignedVarLong(java.io.DataInput in) throws java.io.IOException
in
- to read bytes from
java.io.IOException
- if DataInput
throws IOException
java.lang.IllegalArgumentException
- if variable-length value does not terminate
after 9 bytes have been readwriteSignedVarLong(long, DataOutput)
public static long readUnsignedVarLong(java.io.DataInput in) throws java.io.IOException
in
- to read bytes from
java.io.IOException
- if DataInput
throws IOException
java.lang.IllegalArgumentException
- if variable-length value does not terminate
after 9 bytes have been readwriteUnsignedVarLong(long, DataOutput)
public static int readSignedVarInt(java.io.DataInput in) throws java.io.IOException
java.lang.IllegalArgumentException
- if variable-length value does not terminate
after 5 bytes have been read
java.io.IOException
- if DataInput
throws IOException
readSignedVarLong(DataInput)
public static int readUnsignedVarInt(java.io.DataInput in) throws java.io.IOException
java.lang.IllegalArgumentException
- if variable-length value does not terminate
after 5 bytes have been read
java.io.IOException
- if DataInput
throws IOException
readUnsignedVarLong(DataInput)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |