Class StreamFrameV5
java.lang.Object
ch.qos.logback.classic.kryo.StreamFrameV5
V5 record framing. EVENT/CLOSE prefixes are 1 type/crc byte plus an unsigned Kryo
varint length (typically 2 bytes total). Epoch
STWD headers stay 6 bytes.
byte0: type (5) | crc3 (3) then: unsigned varint length then: payload[length]CRC-3 covers type (5 bits), the length varint bytes, and a small payload window: all bytes if
length <= 8, otherwise first and last CRC_WINDOW bytes.
The middle is not covered; the check is for torn writes (process exit / power fail)
where a later session is appended after a truncated EVENT.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intBytes hashed at each end of a payload longer than2 * CRC_WINDOW.static final int1 type/crc byte + at most 3 varint bytes (coversKryoEncoder.MAX_BUFFER_SIZE).static final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]static intcomputeCrc(int type, byte[] lenBytes, byte[] payload, int off, int len) static intcomputeCrc(int type, byte[] lenBuf, int lenOff, int lenLen, byte[] payload, int off, int len) static intcountOccurrences(byte[] haystack, byte[] needle) static booleancrcMatches(int packedByte, byte[] lenBytes, byte[] payload, int off, int len) static intcrcOf(int packedByte) static byte[]encodeUnsignedVarInt(int value) static intindexOfMagic(byte[] buf, int from, int to) static booleanisStreamHeader(byte[] rec) static intpack(int type, int crc3) static inttypeOf(int packedByte) static intunsignedVarIntSize(int value) static byte[]wrapEvent(byte[] payload) static intwriteEventPrefix(byte[] dest, int payloadOff, int payloadLen) Writes the EVENT prefix immediately beforedest[payloadOff].static intwriteUnsignedVarInt(byte[] dest, int off, int value) Kryo unsigned varint intodest[off..].
-
Field Details
-
TYPE_EVENT
- See Also:
-
TYPE_CLOSE
- See Also:
-
TYPE_BITS
- See Also:
-
CRC_BITS
- See Also:
-
TYPE_MASK
- See Also:
-
CRC_MASK
- See Also:
-
MAX_PREFIX
1 type/crc byte + at most 3 varint bytes (coversKryoEncoder.MAX_BUFFER_SIZE).- See Also:
-
CRC_WINDOW
Bytes hashed at each end of a payload longer than2 * CRC_WINDOW.- See Also:
-
-
Method Details
-
isStreamHeader
-
indexOfMagic
-
countOccurrences
-
pack
-
typeOf
-
crcOf
-
unsignedVarIntSize
-
writeUnsignedVarInt
Kryo unsigned varint intodest[off..]. Returns bytes written. -
encodeUnsignedVarInt
-
writeEventPrefix
Writes the EVENT prefix immediately beforedest[payloadOff]. Payload bytes must already occupydest[payloadOff .. payloadOff + payloadLen).- Returns:
- prefix length in bytes (2–4)
-
wrapEvent
-
closeCode
-
computeCrc
-
computeCrc
public static int computeCrc(int type, byte[] lenBuf, int lenOff, int lenLen, byte[] payload, int off, int len) -
crcMatches
-