Package org.xerial.snappy
Class SnappyFramed
- java.lang.Object
-
- org.xerial.snappy.SnappyFramed
-
final class SnappyFramed extends java.lang.Object
Constants and utilities for implementing x-snappy-framed.- Since:
- 1.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.function.Supplier<java.util.zip.Checksum>
CHECKSUM_SUPPLIER
static int
COMPRESSED_DATA_FLAG
static byte[]
HEADER_BYTES
The header consists of the stream identifier flag, 3 bytes indicating a length of 6, and "sNaPpY" in ASCII.private static int
MASK_DELTA
static int
STREAM_IDENTIFIER_FLAG
static int
UNCOMPRESSED_DATA_FLAG
-
Constructor Summary
Constructors Constructor Description SnappyFramed()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.zip.Checksum
getCRC32C()
static int
mask(int crc)
Checksums are not stored directly, but masked, as checksumming data and then its own checksum can be problematic.static int
maskedCrc32c(java.util.zip.Checksum crc32c, byte[] data, int offset, int length)
(package private) static int
readBytes(java.nio.channels.ReadableByteChannel source, java.nio.ByteBuffer dest)
(package private) static int
skip(java.nio.channels.ReadableByteChannel source, int skip, java.nio.ByteBuffer buffer)
-
-
-
Field Detail
-
COMPRESSED_DATA_FLAG
public static final int COMPRESSED_DATA_FLAG
- See Also:
- Constant Field Values
-
UNCOMPRESSED_DATA_FLAG
public static final int UNCOMPRESSED_DATA_FLAG
- See Also:
- Constant Field Values
-
STREAM_IDENTIFIER_FLAG
public static final int STREAM_IDENTIFIER_FLAG
- See Also:
- Constant Field Values
-
MASK_DELTA
private static final int MASK_DELTA
- See Also:
- Constant Field Values
-
CHECKSUM_SUPPLIER
private static final java.util.function.Supplier<java.util.zip.Checksum> CHECKSUM_SUPPLIER
-
HEADER_BYTES
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.
-
-
Method Detail
-
getCRC32C
public static java.util.zip.Checksum getCRC32C()
-
maskedCrc32c
public static int maskedCrc32c(java.util.zip.Checksum crc32c, byte[] data, int offset, int length)
-
mask
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; }
-
readBytes
static final int readBytes(java.nio.channels.ReadableByteChannel source, java.nio.ByteBuffer dest) throws java.io.IOException
- Throws:
java.io.IOException
-
skip
static int skip(java.nio.channels.ReadableByteChannel source, int skip, java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
-