|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.kafka.common.record.Record
public final class Record
A record: a serialized key and value along with the associated CRC and other fields
Field Summary | |
---|---|
static int |
ATTRIBUTE_LENGTH
|
static int |
ATTRIBUTES_OFFSET
|
static int |
COMPRESSION_CODEC_MASK
Specifies the mask for the compression code. |
static int |
CRC_LENGTH
|
static int |
CRC_OFFSET
The current offset and size for all the fixed-length fields |
static byte |
CURRENT_MAGIC_VALUE
The current "magic" value |
static int |
HEADER_SIZE
The size for the record header |
static int |
KEY_OFFSET
|
static int |
KEY_SIZE_LENGTH
|
static int |
KEY_SIZE_OFFSET
|
static int |
MAGIC_LENGTH
|
static int |
MAGIC_OFFSET
|
static int |
NO_COMPRESSION
Compression code for uncompressed records |
static int |
RECORD_OVERHEAD
The amount of overhead bytes in a record |
static int |
VALUE_SIZE_LENGTH
|
Constructor Summary | |
---|---|
Record(byte[] value)
|
|
Record(byte[] key,
byte[] value)
|
|
Record(byte[] key,
byte[] value,
CompressionType type)
|
|
Record(byte[] key,
byte[] value,
CompressionType type,
int valueOffset,
int valueSize)
A constructor to create a LogRecord. |
|
Record(byte[] value,
CompressionType type)
|
|
Record(java.nio.ByteBuffer buffer)
|
Method Summary | |
---|---|
byte |
attributes()
The attributes stored with this record |
java.nio.ByteBuffer |
buffer()
|
long |
checksum()
Retrieve the previously computed CRC for this record |
CompressionType |
compressionType()
The compression type used with this record |
static byte |
computeAttributes(CompressionType type)
|
long |
computeChecksum()
Compute the checksum of the record from the record contents |
static long |
computeChecksum(byte[] key,
byte[] value,
CompressionType type,
int valueOffset,
int valueSize)
Compute the checksum of the record from the attributes, key and value payloads |
static long |
computeChecksum(java.nio.ByteBuffer buffer,
int position,
int size)
Compute the checksum of the record from the record contents |
void |
ensureValid()
Throw an InvalidRecordException if isValid is false for this record |
boolean |
equals(java.lang.Object other)
|
int |
hashCode()
|
boolean |
hasKey()
Does the record have a key? |
boolean |
isValid()
Returns true if the crc stored with the record matches the crc computed off the record contents |
java.nio.ByteBuffer |
key()
A ByteBuffer containing the message key |
int |
keySize()
The length of the key in bytes |
byte |
magic()
The magic version of this record |
static int |
recordSize(byte[] key,
byte[] value)
|
static int |
recordSize(int keySize,
int valueSize)
|
int |
size()
The complete serialized size of this record in bytes (including crc, header attributes, etc) |
java.lang.String |
toString()
|
java.nio.ByteBuffer |
value()
A ByteBuffer containing the value of this record |
int |
valueSize()
The length of the value in bytes |
static void |
write(java.nio.ByteBuffer buffer,
byte[] key,
byte[] value,
CompressionType type,
int valueOffset,
int valueSize)
|
static void |
write(Compressor compressor,
long crc,
byte attributes,
byte[] key,
byte[] value,
int valueOffset,
int valueSize)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CRC_OFFSET
public static final int CRC_LENGTH
public static final int MAGIC_OFFSET
public static final int MAGIC_LENGTH
public static final int ATTRIBUTES_OFFSET
public static final int ATTRIBUTE_LENGTH
public static final int KEY_SIZE_OFFSET
public static final int KEY_SIZE_LENGTH
public static final int KEY_OFFSET
public static final int VALUE_SIZE_LENGTH
public static final int HEADER_SIZE
public static final int RECORD_OVERHEAD
public static final byte CURRENT_MAGIC_VALUE
public static final int COMPRESSION_CODEC_MASK
public static final int NO_COMPRESSION
Constructor Detail |
---|
public Record(java.nio.ByteBuffer buffer)
public Record(byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize)
key
- The key of the record (null, if none)value
- The record valuetype
- The compression type used on the contents of the record (if any)valueOffset
- The offset into the payload array used to extract payloadvalueSize
- The size of the payload to usepublic Record(byte[] key, byte[] value, CompressionType type)
public Record(byte[] value, CompressionType type)
public Record(byte[] key, byte[] value)
public Record(byte[] value)
Method Detail |
---|
public static void write(java.nio.ByteBuffer buffer, byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize)
public static void write(Compressor compressor, long crc, byte attributes, byte[] key, byte[] value, int valueOffset, int valueSize)
public static int recordSize(byte[] key, byte[] value)
public static int recordSize(int keySize, int valueSize)
public java.nio.ByteBuffer buffer()
public static byte computeAttributes(CompressionType type)
public static long computeChecksum(java.nio.ByteBuffer buffer, int position, int size)
public static long computeChecksum(byte[] key, byte[] value, CompressionType type, int valueOffset, int valueSize)
public long computeChecksum()
public long checksum()
public boolean isValid()
public void ensureValid()
public int size()
public int keySize()
public boolean hasKey()
public int valueSize()
public byte magic()
public byte attributes()
public CompressionType compressionType()
public java.nio.ByteBuffer value()
public java.nio.ByteBuffer key()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |