Skip to main content

Partition

Struct Partition 

Source
pub struct Partition {
    pub view_metadata: ViewMetadata,
    pub insert_time_range: TimeRange,
    pub event_time_range: Option<TimeRange>,
    pub updated: DateTime<Utc>,
    pub file_path: Option<String>,
    pub file_size: i64,
    pub source_data_hash: Vec<u8>,
    pub num_rows: i64,
    pub sort_order: Option<Vec<String>>,
    pub max_sort_key_time: Option<DateTime<Utc>>,
}
Expand description

Partition metadata (without embedded file_metadata for performance) Use load_partition_metadata() to load metadata on-demand when needed

Fields§

§view_metadata: ViewMetadata

Metadata about the view this partition belongs to.

§insert_time_range: TimeRange

The insert time range for this partition.

§event_time_range: Option<TimeRange>

The event time range for this partition. None for empty partitions.

§updated: DateTime<Utc>

The last time this partition was updated.

§file_path: Option<String>

The path to the Parquet file for this partition. None for empty partitions.

§file_size: i64

The size of the Parquet file in bytes. 0 for empty partitions.

§source_data_hash: Vec<u8>

A hash of the source data that generated this partition.

§num_rows: i64

The number of rows in this partition. 0 for empty partitions.

§sort_order: Option<Vec<String>>

The sort guarantee this partition’s rows carry, if any (e.g. Some(["insert_time"])). None means no ordering guarantee is recorded – true for every partition written before this field existed, and for any view/merge that doesn’t declare one. See View::get_merged_partition_sort_order and the blocks_view_ordered_merges_plan.md plan.

§max_sort_key_time: Option<DateTime<Utc>>

The true maximum value of the view’s declared Concatenated leading sort column across this partition’s rows (begin, for thread_spans) – as opposed to max_event_time, which for thread_spans is the max span end and only a loose stand-in for it. None means “not recorded”: every partition written before this field existed, and every partition from a view that doesn’t declare a Concatenated event-time ordering (only ThreadSpansView populates it today). See tasks/completed/thread_spans_segment_boundary_overlap_plan.md, Part B.

Implementations§

Source§

impl Partition

Source

pub fn is_empty(&self) -> bool

Returns true if this partition has no data (num_rows = 0).

Source

pub fn min_event_time(&self) -> Option<DateTime<Utc>>

Returns the min event time, if this partition has data.

Source

pub fn max_event_time(&self) -> Option<DateTime<Utc>>

Returns the max event time, if this partition has data.

Source

pub fn max_sort_key_time(&self) -> Option<DateTime<Utc>>

Returns the recorded true maximum leading-sort-column value, if any. See the field’s doc for what “recorded” means and why it can be None even for a non-empty partition.

Source

pub fn begin_insert_time(&self) -> DateTime<Utc>

Returns the beginning of the insert time range.

Source

pub fn end_insert_time(&self) -> DateTime<Utc>

Returns the end of the insert time range.

Source

pub fn certifies_sort_order(&self, columns: &[ScanSortColumn]) -> bool

True when this partition’s recorded sort_order certifies columns as an ordering its rows already satisfy: columns (ascending-only) must name a prefix of the recorded, ascending-implied sort order. Empty partitions certify vacuously – there are no rows to violate the ordering. An empty (non-empty-partition) columns never certifies: it names no ordering to satisfy, so declaring it certified would let a ScanOrdering::PerFile { columns: vec![] } degrade to Unordered instead of silently planning and recording a vacuous ordering (see ScanOrdering::PerFile).

Source

pub fn validate(&self) -> Result<(), Error>

Validates partition invariants. Returns error if partition is inconsistent.

Invariants:

  • Non-empty partitions (num_rows > 0) MUST have both event_time_range and file_path
  • Empty partitions (num_rows = 0) MUST NOT have event_time_range or file_path
  • num_rows must not be negative
  • A partition with no event_time_range MUST NOT carry a max_sort_key_time (an empty partition has no sort-key bound to record)

Deliberately not checked here: any ordering relationship between max_sort_key_time and min_event_time/max_event_time (e.g. min_event_time <= max_sort_key_time <= max_event_time). That holds by construction for thread_spans today, but two properties of this function rule out asserting it as an invariant:

  1. validate runs only on the read path (its callers are all in partition_cache.rs, propagating with ?); nothing on the write path calls it. A violating partition would therefore be written and committed silently, then hard-fail reads – and since the fetch this feeds is not view-scoped, one bad row would fail materialization for every view, not just the offending one. The invariant must assert only what the writer guarantees by construction, never a hopeful expectation.
  2. The bound would depend on data the writer doesn’t control: min_event_time/ max_event_time derive straight from client-supplied block ticks with no validation anywhere in ingestion or analytics, so a malformed client (e.g. begin_ticks > end_ticks) could make an ordering clause unsatisfiable – turning one bad row into a lakehouse-wide read outage. And the invariant would apply to every future view populating max_sort_key_time, not just thread_spans: BlocksView, for instance, has a Concatenated sort key of insert_time while its event_time_range is [min begin_time, max insert_time], so a client clock skewed ahead of the server could put a block’s begin_time above its insert_time.

The row-level property this plan actually relies on (the partition’s true max begin really is bounded by its event_time_range) is asserted where it is cheap and safe instead: at write time (ensure_begin_non_decreasing) and pinned by a no-DB test (call_tree_tests.rs).

Trait Implementations§

Source§

impl Clone for Partition

Source§

fn clone(&self) -> Partition

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 Debug for Partition

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Scope for T

§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Value for T
where T: Send + Sync + 'static,

§

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