LogicalFieldId

Struct LogicalFieldId 

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

Globally unique identifier for a column in the storage engine.

A LogicalFieldId combines three components into a single 64-bit value:

  • Namespace (16 bits): Category of data (user, system, MVCC)
  • Table ID (16 bits): Which table the column belongs to
  • Field ID (32 bits): Which column within the table

This design prevents ID collisions across different tables and data categories while keeping identifiers compact and easy to pass around.

§Bit Layout

|-------- 64 bits total --------|
| namespace | table_id | field_id |
|  16 bits  | 16 bits  | 32 bits  |

§Construction

Use the constructor methods rather than directly manipulating bits:

§Thread Safety

LogicalFieldId is Copy and thread-safe.

Implementations§

Source§

impl LogicalFieldId

Source

pub const fn new() -> Self

Returns an instance with zero initialized data.

Source§

impl LogicalFieldId

Source

pub const fn into_bytes(self) -> [u8; 8]

Returns the underlying bits.

§Layout

The returned byte array is layed out in the same way as described here.

Source

pub const fn from_bytes(bytes: [u8; 8]) -> Self

Converts the given bytes directly into the bitfield struct.

Source§

impl LogicalFieldId

Source

pub fn field_id(&self) -> <B32 as Specifier>::InOut

Returns the value of field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn field_id_or_err( &self, ) -> Result<<B32 as Specifier>::InOut, InvalidBitPattern<<B32 as Specifier>::Bytes>>

Returns the value of field_id.

§Errors

If the returned value contains an invalid bit pattern for field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn with_field_id(self, new_val: <B32 as Specifier>::InOut) -> Self

Returns a copy of the bitfield with the value of field_id set to the given value.

§Panics

If the given value is out of bounds for field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn with_field_id_checked( self, new_val: <B32 as Specifier>::InOut, ) -> Result<Self, OutOfBounds>

Returns a copy of the bitfield with the value of field_id set to the given value.

§Errors

If the given value is out of bounds for field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn set_field_id(&mut self, new_val: <B32 as Specifier>::InOut)

Sets the value of field_id to the given value.

§Panics

If the given value is out of bounds for field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn set_field_id_checked( &mut self, new_val: <B32 as Specifier>::InOut, ) -> Result<(), OutOfBounds>

Sets the value of field_id to the given value.

§Errors

If the given value is out of bounds for field_id. Column identifier within the table (32 bits).

Supports up to ~4.3 billion columns per table. Field ID 0 is reserved for row ID columns.

Source

pub fn table_id(&self) -> <B16 as Specifier>::InOut

Returns the value of table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn table_id_or_err( &self, ) -> Result<<B16 as Specifier>::InOut, InvalidBitPattern<<B16 as Specifier>::Bytes>>

Returns the value of table_id.

§Errors

If the returned value contains an invalid bit pattern for table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn with_table_id(self, new_val: <B16 as Specifier>::InOut) -> Self

Returns a copy of the bitfield with the value of table_id set to the given value.

§Panics

If the given value is out of bounds for table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn with_table_id_checked( self, new_val: <B16 as Specifier>::InOut, ) -> Result<Self, OutOfBounds>

Returns a copy of the bitfield with the value of table_id set to the given value.

§Errors

If the given value is out of bounds for table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn set_table_id(&mut self, new_val: <B16 as Specifier>::InOut)

Sets the value of table_id to the given value.

§Panics

If the given value is out of bounds for table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn set_table_id_checked( &mut self, new_val: <B16 as Specifier>::InOut, ) -> Result<(), OutOfBounds>

Sets the value of table_id to the given value.

§Errors

If the given value is out of bounds for table_id. Table identifier (16 bits).

Supports up to 65,535 tables. Table ID 0 is reserved for the system catalog.

Source

pub fn namespace(&self) -> <LogicalStorageNamespace as Specifier>::InOut

Returns the value of namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source

pub fn namespace_or_err( &self, ) -> Result<<LogicalStorageNamespace as Specifier>::InOut, InvalidBitPattern<<LogicalStorageNamespace as Specifier>::Bytes>>

Returns the value of namespace.

§Errors

If the returned value contains an invalid bit pattern for namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source

pub fn with_namespace( self, new_val: <LogicalStorageNamespace as Specifier>::InOut, ) -> Self

Returns a copy of the bitfield with the value of namespace set to the given value.

§Panics

If the given value is out of bounds for namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source

pub fn with_namespace_checked( self, new_val: <LogicalStorageNamespace as Specifier>::InOut, ) -> Result<Self, OutOfBounds>

Returns a copy of the bitfield with the value of namespace set to the given value.

§Errors

If the given value is out of bounds for namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source

pub fn set_namespace( &mut self, new_val: <LogicalStorageNamespace as Specifier>::InOut, )

Sets the value of namespace to the given value.

§Panics

If the given value is out of bounds for namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source

pub fn set_namespace_checked( &mut self, new_val: <LogicalStorageNamespace as Specifier>::InOut, ) -> Result<(), OutOfBounds>

Sets the value of namespace to the given value.

§Errors

If the given value is out of bounds for namespace. Data category (16 bits).

Determines whether this ID refers to user data, system metadata, or MVCC tracking.

Source§

impl LogicalFieldId

Source

pub fn from_parts( namespace: LogicalStorageNamespace, table_id: TableId, field_id: FieldId, ) -> Self

Construct a LogicalFieldId from individual components.

This is the most general constructor. Use the convenience methods (for_user, for_mvcc_created_by, etc.) for common cases.

Source

pub fn for_user(table_id: TableId, field_id: FieldId) -> Self

Create an ID for a user-defined column.

This is the most common constructor for regular table columns. It uses the UserData namespace.

Source

pub fn for_user_table_0(field_id: FieldId) -> Self

Create an ID for a user column in table 0.

This is a convenience method for tests and examples that use the default table ID.

Source

pub fn for_mvcc_created_by(table_id: TableId) -> Self

Create an ID for the MVCC created_by column of a table.

Each table has a created_by column that tracks which transaction inserted each row. The field ID is always u32::MAX as a sentinel value.

Source

pub fn for_mvcc_deleted_by(table_id: TableId) -> Self

Create an ID for the MVCC deleted_by column of a table.

Each table has a deleted_by column that tracks which transaction deleted each row (or TXN_ID_NONE if not deleted). The field ID is always u32::MAX - 1 as a sentinel value.

Trait Implementations§

Source§

impl CheckTotalSizeMultipleOf8 for LogicalFieldId

Source§

type Size = TotalSize<BitCount</// Globally unique identifier for a column in the storage engine. /// /// A `LogicalFieldId` combines three components into a single 64-bit value: /// - **Namespace** (16 bits): Category of data (user, system, MVCC) /// - **Table ID** (16 bits): Which table the column belongs to /// - **Field ID** (32 bits): Which column within the table /// /// This design prevents ID collisions across different tables and data categories while /// keeping identifiers compact and easy to pass around. /// /// # Bit Layout /// /// ```text /// |-------- 64 bits total --------| /// | namespace | table_id | field_id | /// | 16 bits | 16 bits | 32 bits | /// ``` /// /// # Construction /// /// Use the constructor methods rather than directly manipulating bits: /// - [`LogicalFieldId::for_user`] - User-defined columns /// - [`LogicalFieldId::for_mvcc_created_by`] - MVCC created_by metadata /// - [`LogicalFieldId::for_mvcc_deleted_by`] - MVCC deleted_by metadata /// - [`LogicalFieldId::from_parts`] - Custom construction /// /// # Thread Safety /// /// `LogicalFieldId` is `Copy` and thread-safe. #[bitfield] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)] #[repr(u64)] pub struct LogicalFieldId { /// Column identifier within the table (32 bits). /// /// Supports up to ~4.3 billion columns per table. Field ID `0` is reserved for /// row ID columns. pub field_id: B32, /// Table identifier (16 bits). /// /// Supports up to 65,535 tables. Table ID `0` is reserved for the system catalog. pub table_id: B16, /// Data category (16 bits). /// /// Determines whether this ID refers to user data, system metadata, or MVCC tracking. pub namespace: LogicalStorageNamespace, }>>

Source§

impl Clone for LogicalFieldId

Source§

fn clone(&self) -> LogicalFieldId

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LogicalFieldId

Source§

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

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

impl Default for LogicalFieldId

Source§

fn default() -> LogicalFieldId

Returns the “default value” for a type. Read more
Source§

impl From<[u8; 8]> for LogicalFieldId

Source§

fn from(bytes: [u8; 8]) -> Self

Converts to this type from the input type.
Source§

impl From<LogicalFieldId> for [u8; 8]

Source§

fn from(bytes: LogicalFieldId) -> Self

Converts to this type from the input type.
Source§

impl From<LogicalFieldId> for u64
where BitCount<{ _ }>: IsU64Compatible,

Source§

fn from(__bf_bitfield: LogicalFieldId) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for LogicalFieldId
where BitCount<{ _ }>: IsU64Compatible,

Source§

fn from(__bf_prim: u64) -> Self

Converts to this type from the input type.
Source§

impl Hash for LogicalFieldId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LogicalFieldId

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for LogicalFieldId

Source§

impl Eq for LogicalFieldId

Source§

impl StructuralPartialEq for LogicalFieldId

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

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