use std::sync::Arc;
use anyhow::Result;
use arrow_array::RecordBatch;
use arrow_schema::Schema as ArrowSchema;
use async_trait::async_trait;
use uni_common::core::schema::TokenizerConfig;
use super::types::{FilterExpr, VectorQueryOpts};
#[async_trait]
pub trait ForkBranching: Send + Sync + 'static {
async fn create_branch(&self, table: &str, branch: &str, parent_version: u64) -> Result<()>;
async fn create_branch_from(
&self,
table: &str,
new_branch: &str,
parent_branch: &str,
parent_version: u64,
) -> Result<()>;
async fn delete_branch(&self, table: &str, branch: &str) -> Result<()>;
async fn list_branches(&self, table: &str) -> Result<Vec<String>>;
async fn current_version(&self, table: &str) -> Result<u64>;
async fn current_version_on_branch(&self, table: &str, branch: &str) -> Result<u64>;
async fn table_exists(&self, table: &str) -> Result<bool>;
async fn create_tag(&self, table: &str, tag: &str, branch: &str) -> Result<()>;
async fn delete_tag(&self, table: &str, tag: &str) -> Result<()>;
async fn list_tags(&self, table: &str) -> Result<Vec<(String, u64)>>;
async fn write_to_branch(
&self,
table: &str,
branch: &str,
batches: Vec<RecordBatch>,
schema: Arc<ArrowSchema>,
) -> Result<()>;
async fn delete_from_branch(
&self,
table: &str,
branch: &str,
filter: &FilterExpr,
) -> Result<()>;
async fn merge_insert_on_branch(
&self,
table: &str,
branch: &str,
on: &[&str],
batches: Vec<RecordBatch>,
schema: Arc<ArrowSchema>,
) -> Result<()>;
async fn replace_branch_tip(
&self,
table: &str,
branch: &str,
batches: Vec<RecordBatch>,
schema: Arc<ArrowSchema>,
) -> Result<()>;
async fn create_empty_table_then_branch(
&self,
table: &str,
branch: &str,
schema: Arc<ArrowSchema>,
) -> Result<()>;
async fn create_scalar_index_on_branch(
&self,
table: &str,
branch: &str,
column: &str,
index_name: &str,
) -> Result<()>;
async fn create_vector_index_on_branch(
&self,
table: &str,
branch: &str,
column: &str,
index_name: &str,
) -> Result<()>;
async fn create_fts_index_on_branch(
&self,
table: &str,
branch: &str,
column: &str,
index_name: &str,
tokenizer: &TokenizerConfig,
) -> Result<()>;
#[allow(clippy::too_many_arguments)]
async fn vector_search_on_branch(
&self,
table: &str,
branch: &str,
column: &str,
query: &[f32],
k: usize,
filter: &FilterExpr,
opts: VectorQueryOpts,
) -> Result<Vec<RecordBatch>>;
#[allow(clippy::too_many_arguments)]
async fn full_text_search_on_branch(
&self,
table: &str,
branch: &str,
column: &str,
query: &str,
k: usize,
filter: &FilterExpr,
) -> Result<Vec<RecordBatch>>;
}