use std::sync::Arc;
use async_trait::async_trait;
use lance_core::Result;
use lance_core::utils::mask::RowAddrMask;
#[async_trait]
pub trait FilterLoader: Send + 'static {
async fn load(self: Box<Self>) -> Result<RowAddrMask>;
}
#[async_trait]
pub trait PreFilter: Send + Sync {
async fn wait_for_ready(&self) -> Result<()>;
fn is_empty(&self) -> bool;
fn mask(&self) -> Arc<RowAddrMask>;
fn filter_row_ids<'a>(&self, row_ids: Box<dyn Iterator<Item = &'a u64> + 'a>) -> Vec<u64>;
}
pub struct NoFilter;
#[async_trait]
impl PreFilter for NoFilter {
async fn wait_for_ready(&self) -> Result<()> {
Ok(())
}
fn is_empty(&self) -> bool {
true
}
fn mask(&self) -> Arc<RowAddrMask> {
Arc::new(RowAddrMask::all_rows())
}
fn filter_row_ids<'a>(&self, row_ids: Box<dyn Iterator<Item = &'a u64> + 'a>) -> Vec<u64> {
row_ids.enumerate().map(|(i, _)| i as u64).collect()
}
}