Top Description Fields Constructors Methods
org.xerial.snappy

pack-priv final Class SnappyFramed

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.nio.ByteBuffer, java.nio.channels.ReadableByteChannel, java.util.function.Supplier, java.util.logging.Level, .Logger, java.util.zip.Checksum

Constants and utilities for implementing x-snappy-framed.
Author
Brett Okken
Since
1.1.0

Field Summary

Modifier and TypeField and Description
private static final Supplier<Checksum>
public static final int
public static final byte[]
HEADER_BYTES

The header consists of the stream identifier flag, 3 bytes indicating a length of 6, and "sNaPpY" in ASCII.

private static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static Checksum
public static int
mask(int crc)

Checksums are not stored directly, but masked, as checksumming data and then its own checksum can be problematic.

public static int
maskedCrc32c(Checksum crc32c, byte[] data, int offset, int length)

pack-priv static final int
pack-priv static int
skip(final ReadableByteChannel source, final int skip, final ByteBuffer buffer)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHECKSUM_SUPPLIERback to summary
private static final Supplier<Checksum> CHECKSUM_SUPPLIER
COMPRESSED_DATA_FLAGback to summary
public static final int COMPRESSED_DATA_FLAG
HEADER_BYTESback to summary
public static final byte[] HEADER_BYTES

The header consists of the stream identifier flag, 3 bytes indicating a length of 6, and "sNaPpY" in ASCII.

MASK_DELTAback to summary
private static final int MASK_DELTA
STREAM_IDENTIFIER_FLAGback to summary
public static final int STREAM_IDENTIFIER_FLAG
UNCOMPRESSED_DATA_FLAGback to summary
public static final int UNCOMPRESSED_DATA_FLAG

Constructor Detail

SnappyFramedback to summary
pack-priv SnappyFramed()

Method Detail

getCRC32Cback to summary
public static Checksum getCRC32C()
maskback to summary
public static int mask(int crc)

Checksums are not stored directly, but masked, as checksumming data and then its own checksum can be problematic. The masking is the same as used in Apache Hadoop: Rotate the checksum by 15 bits, then add the constant 0xa282ead8 (using wraparound as normal for unsigned integers). This is equivalent to the following C code:

uint32_t mask_checksum(uint32_t x) {
    return ((x >> 15) | (x << 17)) + 0xa282ead8;
}
maskedCrc32cback to summary
public static int maskedCrc32c(Checksum crc32c, byte[] data, int offset, int length)
readBytesback to summary
pack-priv static final int readBytes(ReadableByteChannel source, ByteBuffer dest) throws IOException
skipback to summary
pack-priv static int skip(final ReadableByteChannel source, final int skip, final ByteBuffer buffer) throws IOException