IOUtil
class instead.public class CompactInt extends Object
CompactInt
utility class provides algorithms for compact
serialization of integer numbers. It uses encoding scheme with variable-length
two's complement big-endian format capable to encode 64-bits signed numbers.
The following table defines used serial format (the first byte is given in bits with 'x' representing payload bit; the remaining bytes are given in bit count):
0xxxxxxx - for -64 <= N < 64 10xxxxxx 8x - for -8192 <= N < 8192 110xxxxx 16x - for -1048576 <= N < 1048576 1110xxxx 24x - for -134217728 <= N < 134217728 11110xxx 32x - for -17179869184 <= N < 17179869184 (includes whole range of signed int) 111110xx 40x - for -2199023255552 <= N < 2199023255552 1111110x 48x - for -281474976710656 <= N < 281474976710656 11111110 56x - for -36028797018963968 <= N < 36028797018963968 11111111 64x - for -9223372036854775808 <= N < 9223372036854775808 (the range of signed long)
Note: this class is deprecated and is replaced by IOUtil
class.
See IOUtil
class, section CompactInt, and individual methods for documentation.
Modifier and Type | Method and Description |
---|---|
static int |
readInt(DataInput in)
Deprecated.
Use
IOUtil.readCompactInt(java.io.DataInput) method instead. |
static long |
readLong(DataInput in)
Deprecated.
Use
IOUtil.readCompactLong(java.io.DataInput) method instead. |
static void |
writeInt(DataOutput out,
int n)
Deprecated.
Use
IOUtil.writeCompactInt(java.io.DataOutput, int) method instead. |
static void |
writeLong(DataOutput out,
long l)
Deprecated.
Use
IOUtil.writeCompactLong(java.io.DataOutput, long) method instead. |
public static void writeInt(DataOutput out, int n) throws IOException
IOUtil.writeCompactInt(java.io.DataOutput, int)
method instead.IOException
public static int readInt(DataInput in) throws IOException
IOUtil.readCompactInt(java.io.DataInput)
method instead.int
data type,
then loss of precision occurs as it is type casted into
int
; the number is read entirely in this case.IOException
public static void writeLong(DataOutput out, long l) throws IOException
IOUtil.writeCompactLong(java.io.DataOutput, long)
method instead.IOException
public static long readLong(DataInput in) throws IOException
IOUtil.readCompactLong(java.io.DataInput)
method instead.IOException
Copyright © 2002–2025 Devexperts LLC. All rights reserved.