1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! A descriptor for a contiguous run of records bytes that live in a segment
//! `.log` file. The zero-copy fetch path (Increment D) uses it.
//!
//! The fetch read returns the `(file, offset, len)` triple instead of a `pread`
//! of the records into an owned `Bytes`, which would copy them out of the page
//! cache into userspace. The broker then `sendfile(2)`s that range straight
//! from the page cache to a plaintext socket and never brings the bytes into
//! userspace. The `Arc<File>` pins the inode through the async send, even if
//! compaction or truncation removes the segment from the log in the meantime.
//! On Unix the open fd keeps the inode alive.
//!
//! `FileRegion` is intentionally pure-`std`: an `Arc<std::fs::File>` and
//! integers. The protocol crate therefore needs no new dependency, and the same
//! type can flow from the log crate's `read_raw_desc` through
//! `RecordsPayload::FileRegions` to the broker's sendfile drainer.
use ;
/// A `[offset, offset+len)` byte range within a segment `.log` file.
///
/// The range holds one or more complete v2 record batches, and it can end with
/// a clipped trailing batch. Byte for byte, these are the records-field bytes
/// that a fetch response would otherwise materialize.