#[derive(Debug, Clone)]
pub enum FilterExpr {
Sql(String),
None,
}
impl FilterExpr {
pub fn from_optional(filter: Option<&str>) -> Self {
match filter {
Some(s) => FilterExpr::Sql(s.to_string()),
None => FilterExpr::None,
}
}
pub fn as_sql(&self) -> Option<&str> {
match self {
FilterExpr::Sql(s) => Some(s),
FilterExpr::None => None,
}
}
}
#[derive(Debug, Clone)]
pub enum ColumnProjection {
Columns(Vec<String>),
All,
}
#[derive(Debug, Clone)]
pub struct ScanRequest {
pub table_name: String,
pub columns: ColumnProjection,
pub filter: FilterExpr,
pub limit: Option<usize>,
}
impl ScanRequest {
pub fn all(table_name: impl Into<String>) -> Self {
Self {
table_name: table_name.into(),
columns: ColumnProjection::All,
filter: FilterExpr::None,
limit: None,
}
}
pub fn with_columns(mut self, columns: Vec<String>) -> Self {
self.columns = ColumnProjection::Columns(columns);
self
}
pub fn with_filter(mut self, filter: impl Into<String>) -> Self {
self.filter = FilterExpr::Sql(filter.into());
self
}
pub fn with_optional_filter(mut self, filter: Option<&str>) -> Self {
self.filter = FilterExpr::from_optional(filter);
self
}
pub fn with_limit(mut self, limit: usize) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WriteMode {
Append,
Overwrite,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DistanceMetric {
L2,
Cosine,
Dot,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum VectorIndexType {
IvfPq,
IvfHnswSq,
}
#[derive(Debug, Clone)]
pub struct VectorIndexConfig {
pub metric: DistanceMetric,
pub index_type: VectorIndexType,
pub num_partitions: Option<usize>,
pub num_sub_vectors: Option<usize>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScalarIndexType {
BTree,
Bitmap,
LabelList,
}
#[derive(Debug, Clone)]
pub struct IndexInfo {
pub name: String,
pub columns: Vec<String>,
pub index_type: String,
}