Skip to main content

Index

Struct Index 

Source
pub struct Index {
    pub name: String,
    pub columns: Vec<String>,
    pub kind: IndexType,
    pub lengths: Vec<(String, i64)>,
    pub orders: Vec<(String, String)>,
    pub method: String,
    pub operator_class: String,
    pub collations: Vec<(String, String)>,
    pub raw_columns: Vec<String>,
    pub algorithm: Option<IndexAlgorithm>,
    pub algorithm_args: Vec<Value>,
    pub granularity: Option<i64>,
}
Expand description

An index of a table: its columns (with per-column lengths, orders and collations), raw expressions, method and operator class, and for ClickHouse data-skipping indexes the algorithm, its arguments and the granularity.

Index::new makes one with defaults; Index::validated runs the checks PHP’s constructor makes.

PHP: Utopia\Query\Schema\Index.

Fields§

§name: String

The name.

§columns: Vec<String>

The columns.

§kind: IndexType

The kind.

§lengths: Vec<(String, i64)>

Prefix lengths, by column.

§orders: Vec<(String, String)>

Orders (ASC / DESC, any case), by column.

§method: String

The method (USING btree), or empty.

§operator_class: String

The operator class applied to every column, or empty.

§collations: Vec<(String, String)>

Collations, by column.

§raw_columns: Vec<String>

Raw SQL expressions appended to the column list, unquoted.

§algorithm: Option<IndexAlgorithm>

The ClickHouse skip-index algorithm, if any.

§algorithm_args: Vec<Value>

The algorithm’s arguments: strings, integers or floats.

§granularity: Option<i64>

The ClickHouse granularity, if set.

Implementations§

Source§

impl Index

Source

pub fn new( name: impl Into<String>, columns: Vec<String>, kind: IndexType, ) -> Self

An index of kind named name over columns, with no other option (not validated: see Index::validated).

Source

pub fn validated(self) -> Result<Self>

The index, after PHP’s constructor checks: a ClickHouse index name is an identifier, there is at least one column or raw expression, the method, operator class and collations are plain words, the granularity is at least 1, and minmax / inverted take no arguments.

PHP: new Index(...), which throws ValidationException.

Source

pub fn auto_name(prefix: &str, columns: &[String]) -> String

The name an unnamed index gets: prefix and the columns joined by _, each with runs of characters outside [A-Za-z0-9_] replaced by one _ (idx_email, uniq_tenant_id_email).

PHP: Table::autoIndexName().

Source

pub fn length(&self, column: &str) -> Option<i64>

The prefix length of column, if set.

Source

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

The order of column, if set.

Source

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

The collation of column, if set.

Trait Implementations§

Source§

impl Clone for Index

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

Source§

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

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

impl PartialEq for Index

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 Index

Auto Trait Implementations§

§

impl Forget for Index

§

impl Freeze for Index

§

impl Move for Index

§

impl RefUnwindSafe for Index

§

impl Send for Index
where RawVecInner: Send, &'static [u8]: Send, Bytes: Send, Arc<Repr<Object>>: Send, BoxRaw<Query>: Send,

§

impl Sync for Index
where RawVecInner: Sync, Bytes: Sync, Arc<Repr<Object>>: Sync, BoxRaw<Query>: Sync,

§

impl Unpin for Index
where *const u8 is !null: Unpin, &'static [u8]: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, Arc<Repr<Object>>: Unpin, Box<Query>: Unpin,

§

impl UnsafeUnpin for Index

§

impl UnwindSafe for Index
where RawVecInner: UnwindSafe, &'static [u8]: UnwindSafe, *const u8: UnwindSafe, Align8<*mut ()>: UnwindSafe, &'static Vtable: UnwindSafe, Arc<Repr<Object>>: UnwindSafe, BoxRaw<Query>: UnwindSafe,

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

Source§

type Output = T

Should always be Self
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.