pub struct Record {
pub offset: i64,
pub timestamp: i64,
pub key: Option<Bytes>,
pub value: Option<Bytes>,
pub headers: Vec<Header>,
}Expand description
One record inside a magic-v2 batch.
std::fmt::Display is Java DefaultRecord.toString (key=N bytes; null is
0 bytes, not keySize -1).
Fields§
§offset: i64Log offset after decode; relative to the batch base when building with
RecordBatch::from_records.
timestamp: i64Timestamp in milliseconds since the Unix epoch.
key: Option<Bytes>Optional key.
value: Option<Bytes>Optional value.
headers: Vec<Header>Record headers.
Implementations§
Source§impl Record
impl Record
Sourcepub const EMPTY_HEADERS: &'static [Header]
pub const EMPTY_HEADERS: &'static [Header]
Java Record.EMPTY_HEADERS.
Sourcepub const MAX_RECORD_OVERHEAD: i32 = 21
pub const MAX_RECORD_OVERHEAD: i32 = 21
Java DefaultRecord.MAX_RECORD_OVERHEAD (max bytes excluding key, value, and headers).
Sourcepub fn value_size(&self) -> i32
pub fn value_size(&self) -> i32
Java Record.valueSize (-1 when the value is null).
Sourcepub fn last_header(&self, key: &str) -> Option<&Header>
pub fn last_header(&self, key: &str) -> Option<&Header>
Java Headers.lastHeader.
Sourcepub fn headers_for_key<'a>(
&'a self,
key: &'a str,
) -> impl Iterator<Item = &'a Header> + 'a
pub fn headers_for_key<'a>( &'a self, key: &'a str, ) -> impl Iterator<Item = &'a Header> + 'a
Java Headers.headers(String).
Sourcepub fn has_magic(&self, magic: i8) -> bool
pub fn has_magic(&self, magic: i8) -> bool
Java Record.hasMagic. Magic-v2 is true when magic is 2 or greater.
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Java DefaultRecord.isCompressed (always false; compression is on the batch).
Sourcepub fn has_timestamp_type(&self, _timestamp_type: TimestampType) -> bool
pub fn has_timestamp_type(&self, _timestamp_type: TimestampType) -> bool
Java DefaultRecord.hasTimestampType (always false; timestamp type is on the batch).
Sourcepub fn size_of_body_in_bytes(
&self,
offset_delta: i32,
timestamp_delta: i64,
) -> Result<i32>
pub fn size_of_body_in_bytes( &self, offset_delta: i32, timestamp_delta: i64, ) -> Result<i32>
Java DefaultRecord.sizeOfBodyInBytes (no length-prefix varint).
offset_delta / timestamp_delta are the magic-v2 relative fields
(offset - baseOffset, timestamp - baseTimestamp).
Sourcepub fn size_in_bytes(
&self,
offset_delta: i32,
timestamp_delta: i64,
) -> Result<i32>
pub fn size_in_bytes( &self, offset_delta: i32, timestamp_delta: i64, ) -> Result<i32>
Java DefaultRecord.sizeInBytes(int, long, ByteBuffer, ByteBuffer, Header[]).
Body size plus the zigzag varint that prefixes the body on the wire.
Sourcepub fn record_size_upper_bound(&self) -> Result<i32>
pub fn record_size_upper_bound(&self) -> Result<i32>
Java DefaultRecord.recordSizeUpperBound (MAX_RECORD_OVERHEAD plus
key, value, and headers; not the on-wire size).
Sourcepub fn from_end_transaction_marker(
timestamp: i64,
marker: &EndTransactionMarker,
) -> Result<Self>
pub fn from_end_transaction_marker( timestamp: i64, marker: &EndTransactionMarker, ) -> Result<Self>
Control record for EndTransactionMarker (Java
MemoryRecordsBuilder.appendEndTxnMarker).