Top Description Constructors Methods
org.HdrHistogram

pack-priv Class ZigZagEncoding

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer

This class provides encoding and decoding methods for writing and reading ZigZag-encoded LEB128-64b9B-variant (Little Endian Base 128) values to/from a ByteBuffer. LEB128's variable length encoding provides for using a smaller nuber of bytes for smaller values, and the use of ZigZag encoding allows small (closer to zero) negative values to use fewer bytes. Details on both LEB128 and ZigZag can be readily found elsewhere. The LEB128-64b9B-variant encoding used here diverges from the "original" LEB128 as it extends to 64 bit values: In the original LEB128, a 64 bit value can take up to 10 bytes in the stream, where this variant's encoding of a 64 bit values will max out at 9 bytes. As such, this encoder/decoder should NOT be used for encoding or decoding "standard" LEB128 formats (e.g. Google Protocol Buffers).

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

the value read from the buffer
getInt
(ByteBuffer
the buffer to read from
buffer
)

Read an LEB128-64b9B ZigZag encoded int value from the given buffer

pack-priv static long

Returns:

the value read from the buffer
getLong
(ByteBuffer
the buffer to read from
buffer
)

Read an LEB128-64b9B ZigZag encoded long value from the given buffer

pack-priv static void
putInt(ByteBuffer
the buffer to write to
buffer
,
int
the value to write to the buffer
value
)

Writes an int value to the given buffer in LEB128-64b9B ZigZag encoded format

pack-priv static void
putLong(ByteBuffer
the buffer to write to
buffer
,
long
the value to write to the buffer
value
)

Writes a long value to the given buffer in LEB128 ZigZag encoded format

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ZigZagEncodingback to summary
pack-priv ZigZagEncoding()

Method Detail

getIntback to summary
pack-priv static int getInt(ByteBuffer buffer)

Read an LEB128-64b9B ZigZag encoded int value from the given buffer

Parameters
buffer:ByteBuffer

the buffer to read from

Returns:int

the value read from the buffer

getLongback to summary
pack-priv static long getLong(ByteBuffer buffer)

Read an LEB128-64b9B ZigZag encoded long value from the given buffer

Parameters
buffer:ByteBuffer

the buffer to read from

Returns:long

the value read from the buffer

putIntback to summary
pack-priv static void putInt(ByteBuffer buffer, int value)

Writes an int value to the given buffer in LEB128-64b9B ZigZag encoded format

Parameters
buffer:ByteBuffer

the buffer to write to

value:int

the value to write to the buffer

putLongback to summary
pack-priv static void putLong(ByteBuffer buffer, long value)

Writes a long value to the given buffer in LEB128 ZigZag encoded format

Parameters
buffer:ByteBuffer

the buffer to write to

value:long

the value to write to the buffer