Skip to main content

Section

Struct Section 

Source
pub struct Section {
    pub kind: [u8; 8],
    pub id: u64,
    pub generation: u64,
    pub extents: u32,
    pub extent_page: u64,
    pub extent_bytes: u32,
    pub hash: u64,
    pub flags: u32,
    pub header_bytes: u32,
}
Expand description

One entry in a table’s section table.

The payload is not here. This is the entry that says where the payload is, what it is, and whether it is still current, and it is all a reader needs to decide whether to read the payload at all.

Fields§

§kind: [u8; 8]

Which kind of structure this is: one of KEY_MAP, FORWARD_LINK, ADJACENCY, or something a later build wrote that this one carries through untouched.

§id: u64

Which structure of that kind. For a key map this identifies the column, for a forward link the relationship. The format does not interpret it; rudb-graph assigns it.

§generation: u64

The table generation this section was built against.

A section whose stamp does not match the table’s is stale, and section 3.1 says stale means ignored rather than repaired. So this field is the whole of the maintenance story: there is no repair path in this crate because a mismatch here removes the section from consideration and the query runs the way it ran before the section existed.

§extents: u32

How many extents the payload is split into.

§extent_page: u64

Where the extent table starts.

§extent_bytes: u32

How many bytes the extent table takes.

§hash: u64

Checksum over the extent table, so a torn one is found before it is believed.

§flags: u32

Kind-specific flags. For a key map this carries which of the three forms was chosen, which is why a reader never has to guess a form.

§header_bytes: u32

Bytes of kind-specific header at the front of the first extent, or, when there are no extents, what the structure would have cost. See Self::refused.

Implementations§

Source§

impl Section

Source

pub fn known(&self) -> bool

Whether this build understands this section’s kind.

The five it knows are the three the graph document’s section 3.2 names and the two the statistics document’s sections 3.3 and 3.4 name. Everything else is a section a later build wrote, and the answer is to leave it alone: the entry is carried through a rewrite so that opening a file with an old build and closing it does not silently discard work, and the payload is never read.

Source

pub fn among(&self, kinds: &[&[u8; 8]]) -> bool

Whether this section’s kind is one of these, which is how a budget finds what it owns.

Source

pub fn current(&self, generation: u64) -> bool

Whether this section was built against this table generation.

Source

pub fn usable(&self, generation: u64) -> bool

Whether this section is one this build should read: a kind it knows, at the current generation.

Source

pub fn refused(&self) -> Option<u64>

What this structure would have cost, when the entry is a record of one that did not fit.

Section 3.7 asks for a relationship that did not fit the budget to be recorded with its size rather than forgotten, so that raising graph_budget is a decision somebody can make from a number. An entry with no extents is that record, and the number is in Self::header_bytes, which has nothing else to mean when there is no first extent to have a header at the front of. Self::flags keeps the meaning it has for a built section of the same kind, so a record says which form the structure would have taken as well as what it would have cost.

None for a section that is in the file, which is the ordinary case and is the one where the size is the payload’s own length.

A size past four gigabytes saturates, because the field is a u32. The largest structure this project expects to refuse is a packed forward link over an SF100 lineitem, which is about 2.1 GB, so the saturation is a bound rather than a rounding, and a saturated record still says far more than the budget correctly.

Trait Implementations§

Source§

impl Clone for Section

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Section

Source§

impl Debug for Section

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Section

Source§

impl PartialEq for Section

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Section

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.