use std::any::Any;
use std::path::Path;
use polars_core::prelude::*;
use polars_utils::cardinality_sketch::CardinalitySketch;
use polars_utils::hashing::HashPartitioner;
use polars_utils::IdxSize;
use crate::hash_keys::HashKeys;
mod row_encoded;
pub trait Grouper: Any + Send + Sync {
fn new_empty(&self) -> Box<dyn Grouper>;
fn reserve(&mut self, additional: usize);
fn num_groups(&self) -> IdxSize;
fn insert_keys(&mut self, keys: HashKeys, group_idxs: &mut Vec<IdxSize>);
fn combine(&mut self, other: &dyn Grouper, group_idxs: &mut Vec<IdxSize>);
unsafe fn gather_combine(
&mut self,
other: &dyn Grouper,
subset: &[IdxSize],
group_idxs: &mut Vec<IdxSize>,
);
fn gen_partition_idxs(
&self,
partitioner: &HashPartitioner,
partition_idxs: &mut [Vec<IdxSize>],
sketches: &mut [CardinalitySketch],
);
fn get_keys_in_group_order(&self) -> DataFrame;
fn store_ooc(&self, _path: &Path) {
unimplemented!();
}
fn load_ooc(&mut self, _path: &Path) {
unimplemented!();
}
fn as_any(&self) -> &dyn Any;
}
pub fn new_hash_grouper(key_schema: Arc<Schema>) -> Box<dyn Grouper> {
Box::new(row_encoded::RowEncodedHashGrouper::new(key_schema))
}