Skip to main content

MeasurementSchema

Struct MeasurementSchema 

Source
pub struct MeasurementSchema { /* private fields */ }
Expand description

Schema for a single measurement (table).

Contains an ordered list of column definitions. The first column is always the timestamp. Tags and fields follow. Columns are private to preserve invariants — use add_tag() and add_field() for modification.

Implementations§

Source§

impl MeasurementSchema

Source

pub fn new(measurement: impl Into<String>) -> Self

Create a new schema with just the timestamp column.

Source

pub fn measurement(&self) -> &str

Returns the measurement name.

Source

pub fn columns(&self) -> &[ColumnDef]

Returns the column definitions (timestamp first, then tags, then fields).

Source

pub fn add_tag(&mut self, name: &str) -> bool

Add a tag column if it doesn’t already exist.

Returns true if the tag was newly added, false if it already exists as a tag. Logs a warning if the name conflicts with an existing field column.

Source

pub fn add_field( &mut self, name: &str, field_value: &FieldValue, ) -> Result<bool, SchemaError>

Add a field column if it doesn’t already exist.

§Errors

Returns SchemaError::TypeConflict if the field already exists with a different type.

Source

pub fn declare_field( &mut self, name: &str, column_type: ColumnType, ) -> Result<bool, SchemaError>

Add a field column with an explicit type.

The type-first form of add_field: it is how a decimal column gets the scale it needs before the first value arrives, and how a batch that introduces a decimal field creates the column at the widest scale the batch carries rather than at whatever scale the first point happened to have.

Returns true if the column was newly added, false if it already existed with exactly this type.

§Errors

SchemaError::TypeConflict if the name already exists as a tag or with a different type — including a decimal with a different scale, which is a different type.

Source

pub fn column(&self, name: &str) -> Option<&ColumnDef>

Look up a column by name — O(1) via the column index.

Source

pub fn push_column(&mut self, col: ColumnDef)

Push a pre-built column definition (e.g. during WAL replay).

Silently ignores duplicates.

Source

pub fn tag_count(&self) -> usize

Returns the number of tag columns.

Source

pub fn field_count(&self) -> usize

Returns the number of field columns.

Source

pub fn tag_names(&self) -> Vec<&str>

Returns the names of all tag columns.

Source

pub fn field_names(&self) -> Vec<&str>

Returns the names of all field columns.

Trait Implementations§

Source§

impl Clone for MeasurementSchema

Source§

fn clone(&self) -> MeasurementSchema

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 MeasurementSchema

Source§

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

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

impl<'de> Deserialize<'de> for MeasurementSchema

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for MeasurementSchema

Source§

impl PartialEq for MeasurementSchema

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 Serialize for MeasurementSchema

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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