pub struct LeanBatch {
pub base_offset: i64,
pub producer_id: i64,
pub transactional: bool,
pub control: bool,
pub records: Vec<LeanRecord>,
/* private fields */
}Expand description
One batch, with the facts that belong to the batch held once.
Fields§
§base_offset: i64§producer_id: i64§transactional: bool§control: boolA control batch carries markers, not caller data. Batch-level in the format, which is why it is stored here and not per record.
records: Vec<LeanRecord>Implementations§
Source§impl LeanBatch
impl LeanBatch
Sourcepub fn key(&self, record: &LeanRecord) -> Option<Bytes>
pub fn key(&self, record: &LeanRecord) -> Option<Bytes>
This record’s key, as a slice of the batch buffer.
Sourcepub fn value(&self, record: &LeanRecord) -> Option<Bytes>
pub fn value(&self, record: &LeanRecord) -> Option<Bytes>
This record’s value, as a slice of the batch buffer.
The Bytes is built here rather than at decode time. Every slice of
one buffer increments the same atomic refcount, so materialising two per
record up front is two million read-modify-writes on one cache line for
a million records — self-contended, and measurably as expensive as
copying the bytes outright. A caller that skips a record never pays for
it.
Sourcepub fn headers(
&self,
record: &LeanRecord,
) -> Result<Vec<(Bytes, Option<Bytes>)>>
pub fn headers( &self, record: &LeanRecord, ) -> Result<Vec<(Bytes, Option<Bytes>)>>
This record’s headers, parsed on demand.
Returns an empty vector when there are none, which is the common case and costs nothing — the region was never touched at decode time.
§Errors
Error::Codec if the header block is malformed.
Sourcepub fn control_type(&self, record: &LeanRecord) -> Option<i16>
pub fn control_type(&self, record: &LeanRecord) -> Option<i16>
The control-marker type, for a control batch. 0 is abort.
Reads the marker’s key, which is where the type lives.