Skip to main content

Block

Struct Block 

Source
pub(crate) struct Block {
    signal: Signal,
    pub(crate) root: RecordBatch,
    attrs: Option<Attrs>,
    resource_attrs: Option<Attrs>,
    scope_attrs: Option<Attrs>,
    children: Vec<Child>,
    detail: bool,
}
Expand description

The tables of one block, opened and ready to scan.

No Mmap handle is kept: every Arrow buffer read out of a block owns an Arc<Mmap> of its own (see block::open_table), so holding the RecordBatch is what holds the mapping. That is also why row data can be borrowed straight out of these batches with ordinary lifetimes.

Fields§

§signal: Signal§root: RecordBatch§attrs: Option<Attrs>

Record-level attributes; parent_id indexes root directly.

§resource_attrs: Option<Attrs>§scope_attrs: Option<Attrs>§children: Vec<Child>

Rows that hang off a root row rather than being one: a span’s events and its links. Empty for logs.

§detail: bool

Whether the five fields above have been read yet.

They are not read at open. block::open_table CRC32s every byte it maps — that is the guarantee, not overhead — and on this corpus the attribute tables are 42.9% of a logs block and 45.7% of a traces block (log_attrs 768,352 KiB of 1,794,752; span_attrs 780,372 of 1,710,020). A query with no attribute predicate that lands on a block contributing no rows was hashing all of that to read a timestamp column. See Block::detail for who asks for them and when.

Implementations§

Source§

impl Block

Source

fn open(bref: &Src<'_>, signal: Signal) -> Result<Option<Block>>

Source

fn detail(&mut self, bref: &Src<'_>) -> Result<()>

Map everything that is not the root table: the three attribute levels and, for traces, the child tables and their own attributes.

Separate from open because these are the expensive tables and most blocks in a scan need none of them. Two callers ask, both in scan_one: a query carrying an attribute predicate, before select, because the predicate is evaluated against them; and any block that produced a hit, because rendering a row emits its attributes. A block that matches nothing and is asked nothing about attributes never maps them and never hashes them.

Idempotent, so the two callers can both fire without checking.

This does not weaken the checksum: what changes is which tables a query reads, and every table it reads is still verified in full before a byte of it is returned. A corrupt attribute table that no query touches is caught by the first query that touches it.

Source

fn time(&self) -> Option<&[i64]>

The root’s time column as a raw slice, straight out of the mapping.

Source

fn select(&self, q: &Search, bref: &Src<'_>) -> Vec<u32>

Row numbers of root matching the query, ascending.

Source

fn attr_rows(&self, key: &str, op: Op, value: &Value, n: usize) -> Vec<bool>

A bitmap over root rows: does this record carry key op value at any attribute level it has — record, resource, scope, or one of its own child rows?

Source

fn emit_row(&self, j: &mut Json, row: u32)

Write one root row as a JSON object, attributes merged in and child rows nested under it.

Source

fn emit_children(&self, j: &mut Json, c: &Child, row: u32)

The events / links array of one span.

Reads the index built when the block was opened. It used to be a linear pass over the child table per emitted row, on the argument that limit bounds the row count — but the other factor is the block’s event count, so the product is limit × events-in-block, and a block holds hundreds of thousands of events. One pass at open time replaces all of them.

Source

fn fk(&self, row: u32, name: &str) -> Option<u32>

Auto Trait Implementations§

§

impl !RefUnwindSafe for Block

§

impl !UnwindSafe for Block

§

impl Freeze for Block

§

impl Send for Block

§

impl Sync for Block

§

impl Unpin for Block

§

impl UnsafeUnpin for Block

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more