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

public final Class Lz4XXHash32

extends BufferChecksum
Class Inheritance
Imports
io.netty5.buffer.Buffer, net.jpountz.xxhash.StreamingXXHash32, .XXHash32, .XXHashFactory, java.nio.ByteBuffer, java.util.zip.Checksum

A special-purpose BufferChecksum implementation for use with Lz4Compressor and Lz4Decompressor. 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 Lz4Compressor and Lz4Decompressor: 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
private void
public long
public void
reset()

Overrides io.netty5.handler.codec.compression.BufferChecksum.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
)

Overrides io.netty5.handler.codec.compression.BufferChecksum.update.

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
)

Overrides io.netty5.handler.codec.compression.BufferChecksum.update.

Implements java.util.zip.Checksum.update.

Updates the current checksum with the specified array of bytes.
public void
update(ByteBuffer
the ByteBuffer to update the checksum with
buffer
)

Overrides default java.util.zip.Checksum.update.

Updates the current checksum with the bytes from the specified buffer.
public void

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

checkUsedback to summary
private void checkUsed()
getValueback to summary
public long getValue()

Overrides io.netty5.handler.codec.compression.BufferChecksum.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()

Overrides io.netty5.handler.codec.compression.BufferChecksum.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)

Overrides io.netty5.handler.codec.compression.BufferChecksum.update.

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)

Overrides io.netty5.handler.codec.compression.BufferChecksum.update.

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(ByteBuffer buffer)

Overrides default java.util.zip.Checksum.update.

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

Updates the current checksum with the bytes from the specified buffer. The checksum is updated with the remaining bytes in the buffer, starting at the buffer's position. Upon return, the buffer's position will be updated to its limit; its limit will not have been changed.

Parameters
buffer:ByteBuffer

the ByteBuffer to update the checksum with

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

Overrides io.netty5.handler.codec.compression.BufferChecksum.update.

Annotations
@Override