Top Description Fields Constructors Methods
io.netty.handler.codec.compression

public final Class Lz4XXHash32

extends ByteBufChecksum
Class Inheritance
Imports
io.netty.buffer.ByteBuf, net.jpountz.xxhash.StreamingXXHash32, .XXHash32, .XXHashFactory, java.nio.ByteBuffer, java.util.zip.Checksum

A special-purpose ByteBufChecksum implementation for use with Lz4FrameEncoder and Lz4FrameDecoder. StreamingXXHash32#asChecksum() has a particularly nasty implementation of Checksum#update(int) that allocates a single-element byte array for every invocation. In addition to that, it doesn't implement an overload that accepts a ByteBuffer as an argument. Combined, this means that we can't use ReflectiveByteBufChecksum at all, and can't use SlowByteBufChecksum because of its atrocious performance with direct byte buffers (allocating an array and making a JNI call for every byte checksummed might be considered sub-optimal by some). Block version of xxHash32 (XXHash32), however, does provide XXHash32#hash(ByteBuffer, int) method that is efficient and does exactly what we need, with a caveat that we can only invoke it once before having to reset. This, however, is fine for our purposes, given the way we use it in Lz4FrameEncoder and Lz4FrameDecoder: reset(), followed by one update(), followed by getValue().

Field Summary

Modifier and TypeField and Description
private final int
private boolean
private int
private static final XXHash32

Constructor Summary

AccessConstructor and Description
public
Lz4XXHash32(int seed)

Method Summary

Modifier and TypeMethod and Description
public long
getValue()

Implements java.util.zip.Checksum.getValue.

Returns the current checksum value.
public void
reset()

Implements java.util.zip.Checksum.reset.

Resets the checksum to its initial value.
public void
update(int
the byte to update the checksum with
b
)

Implements java.util.zip.Checksum.update.

Updates the current checksum with the specified byte.
public void
update(byte[]
the byte array to update the checksum with
b
,
int
the start offset of the data
off
,
int
the number of bytes to use for the update
len
)

Implements java.util.zip.Checksum.update.

Updates the current checksum with the specified array of bytes.
public void
Inherited from io.netty.handler.codec.compression.ByteBufChecksum:
wrapChecksum

Field Detail

seedback to summary
private final int seed
usedback to summary
private boolean used
valueback to summary
private int value
XXHASH32back to summary
private static final XXHash32 XXHASH32

Constructor Detail

Lz4XXHash32back to summary
public Lz4XXHash32(int seed)
Annotations
@SuppressWarnings:WeakerAccess

Method Detail

getValueback to summary
public long getValue()

Implements java.util.zip.Checksum.getValue.

Doc from java.util.zip.Checksum.getValue.

Returns the current checksum value.

Returns:long

the current checksum value

Annotations
@Override
resetback to summary
public void reset()

Implements java.util.zip.Checksum.reset.

Doc from java.util.zip.Checksum.reset.

Resets the checksum to its initial value.

Annotations
@Override
updateback to summary
public void update(int b)

Implements java.util.zip.Checksum.update.

Doc from java.util.zip.Checksum.update.

Updates the current checksum with the specified byte.

Parameters
b:int

the byte to update the checksum with

Annotations
@Override
updateback to summary
public void update(byte[] b, int off, int len)

Implements java.util.zip.Checksum.update.

Doc from java.util.zip.Checksum.update.

Updates the current checksum with the specified array of bytes.

Parameters
b:byte[]

the byte array to update the checksum with

off:int

the start offset of the data

len:int

the number of bytes to use for the update

Annotations
@Override
updateback to summary
public void update(ByteBuf b, int off, int len)

Overrides io.netty.handler.codec.compression.ByteBufChecksum.update.

Annotations
@Override