pub struct Column {
pub logical_type: LogicalTypeID,
pub physical_type: PhysicalTypeID,
pub table_id: u64,
pub col_idx: u32,
pub file_name: String,
pub file_handle: FileHandle,
pub buffer_manager: Arc<Mutex<BufferManager>>,
pub compression_type: CompressionType,
pub value_size: usize,
pub num_values: u64,
pub num_pages: u64,
pub page_row_offsets: Vec<u64>,
}Expand description
A column stores values of a single type across multiple pages.
The column owns a dedicated file (named col_{table_id}_{col_idx}) and
uses the BufferManager for all page-level I/O with automatic caching.
Fields§
§logical_type: LogicalTypeIDThe logical type of values stored in this column.
physical_type: PhysicalTypeIDPhysical type derived from logical_type.
table_id: u64The owning table ID (used to construct the file name).
col_idx: u32The column index within the table.
file_name: StringFile name used in the BufferManager’s file registry.
file_handle: FileHandleFile handle for low-level page I/O.
buffer_manager: Arc<Mutex<BufferManager>>Shared buffer manager for page caching and eviction.
compression_type: CompressionTypeCompression algorithm applied to serialized values.
value_size: usizeByte size of the serialized primitive value (0 for variable-length types).
num_values: u64Total number of values stored.
num_pages: u64Number of pages allocated.
page_row_offsets: Vec<u64>Cumulative value count per page (for binary-search lookup).
page_row_offsets[i] = the global row index of the first value in page i.
Implementations§
Source§impl Column
impl Column
Sourcepub fn new(
logical_type: LogicalTypeID,
table_id: u64,
col_idx: u32,
db_path: &Path,
buffer_manager: Arc<Mutex<BufferManager>>,
page_size: usize,
) -> Self
pub fn new( logical_type: LogicalTypeID, table_id: u64, col_idx: u32, db_path: &Path, buffer_manager: Arc<Mutex<BufferManager>>, page_size: usize, ) -> Self
Create a new column backed by a file in db_path.
The file is named col_{table_id}_{col_idx} and registered with
the BufferManager automatically.
compression_type determines the compression algorithm applied to
serialized values. Use CompressionType::Uncompressed for no compression.
Sourcepub fn with_compression(
logical_type: LogicalTypeID,
table_id: u64,
col_idx: u32,
db_path: &Path,
buffer_manager: Arc<Mutex<BufferManager>>,
page_size: usize,
compression_type: CompressionType,
) -> Self
pub fn with_compression( logical_type: LogicalTypeID, table_id: u64, col_idx: u32, db_path: &Path, buffer_manager: Arc<Mutex<BufferManager>>, page_size: usize, compression_type: CompressionType, ) -> Self
Create a new column with a specific compression algorithm.
Sourcepub fn append_value(&mut self, value: &Value) -> Result<()>
pub fn append_value(&mut self, value: &Value) -> Result<()>
Append a single value to the column.
Append a single value to the column.
Automatically allocates a new page when the current one is full or when the current page has reached the maximum values per page (256).
Serialized values are compressed according to self.compression_type.
Sourcepub fn scan_values(&self, start: u64, count: u64) -> Result<Vec<Value>>
pub fn scan_values(&self, start: u64, count: u64) -> Result<Vec<Value>>
Scan a range of values (inclusive of start, exclusive of start + count).
Sourcepub fn read_value_bytes(&self, row_idx: u64) -> Result<Vec<u8>>
pub fn read_value_bytes(&self, row_idx: u64) -> Result<Vec<u8>>
Read the raw serialised bytes of a single value (useful for compression).
Sourcepub fn save_metadata(&self) -> Result<()>
pub fn save_metadata(&self) -> Result<()>
Save column metadata to a .meta sidecar file so it can be
reconstructed after a crash or restart without scanning every page.
Layout (all little-endian): magic: 4 bytes b“CMET“ version: u32 logical_type: u32 table_id: u64 col_idx: u32 num_values: u64 num_pages: u64 page_row_offsets: [u64; num_pages]
Sourcepub fn load_metadata(&mut self) -> Result<bool>
pub fn load_metadata(&mut self) -> Result<bool>
Load column metadata from a .meta sidecar file.
Returns Ok(true) if metadata was loaded successfully,
Ok(false) if no metadata file exists (fresh column).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Column
impl RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnsafeUnpin for Column
impl UnwindSafe for Column
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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