Skip to main content

IndexExtension

Trait IndexExtension 

Source
pub trait IndexExtension: Extension {
    // Required methods
    fn index_type(&self) -> &str;
    fn build(
        &mut self,
        table_id: TableId,
        column_id: u16,
        data: &[(RowId, Vec<u8>)],
    ) -> KernelResult<()>;
    fn insert(&mut self, key: &[u8], row_id: RowId) -> KernelResult<()>;
    fn delete(&mut self, key: &[u8], row_id: RowId) -> KernelResult<()>;
    fn lookup(&self, key: &[u8]) -> KernelResult<Vec<RowId>>;
    fn range(
        &self,
        start: &[u8],
        end: &[u8],
        limit: usize,
    ) -> KernelResult<Vec<RowId>>;
    fn size_bytes(&self) -> u64;

    // Provided method
    fn nearest(
        &self,
        _query: &[u8],
        _k: usize,
    ) -> KernelResult<Vec<(RowId, f32)>> { ... }
}
Expand description

Index extension

Implement this for custom index types (vector, learned, full-text, etc.)

Required Methods§

Source

fn index_type(&self) -> &str

Index type name (e.g., “hnsw”, “learned”, “btree”)

Source

fn build( &mut self, table_id: TableId, column_id: u16, data: &[(RowId, Vec<u8>)], ) -> KernelResult<()>

Build index on existing data

Source

fn insert(&mut self, key: &[u8], row_id: RowId) -> KernelResult<()>

Insert a key-value pair into the index

Source

fn delete(&mut self, key: &[u8], row_id: RowId) -> KernelResult<()>

Delete a key from the index

Source

fn lookup(&self, key: &[u8]) -> KernelResult<Vec<RowId>>

Point lookup

Source

fn range( &self, start: &[u8], end: &[u8], limit: usize, ) -> KernelResult<Vec<RowId>>

Range scan

Source

fn size_bytes(&self) -> u64

Get index size in bytes

Provided Methods§

Source

fn nearest(&self, _query: &[u8], _k: usize) -> KernelResult<Vec<(RowId, f32)>>

Nearest neighbor search (for vector indices)

Implementors§