use vortex_array::compute::{ComputeVTable, FilterFn, ScalarAtFn, SearchSortedFn, SliceFn, TakeFn};
use vortex_array::ArrayData;
use crate::BitPackedEncoding;
mod filter;
mod scalar_at;
mod search_sorted;
mod slice;
mod take;
impl ComputeVTable for BitPackedEncoding {
fn filter_fn(&self) -> Option<&dyn FilterFn<ArrayData>> {
Some(self)
}
fn scalar_at_fn(&self) -> Option<&dyn ScalarAtFn<ArrayData>> {
Some(self)
}
fn search_sorted_fn(&self) -> Option<&dyn SearchSortedFn<ArrayData>> {
Some(self)
}
fn slice_fn(&self) -> Option<&dyn SliceFn<ArrayData>> {
Some(self)
}
fn take_fn(&self) -> Option<&dyn TakeFn<ArrayData>> {
Some(self)
}
}
fn chunked_indices<F: FnMut(usize, &[usize])>(
mut indices: impl Iterator<Item = usize>,
offset: usize,
mut chunk_fn: F,
) {
let mut indices_within_chunk: Vec<usize> = Vec::with_capacity(1024);
let Some(first_idx) = indices.next() else {
return;
};
let mut current_chunk_idx = (first_idx + offset) / 1024;
indices_within_chunk.push((first_idx + offset) % 1024);
for idx in indices {
let new_chunk_idx = (idx + offset) / 1024;
if new_chunk_idx != current_chunk_idx {
chunk_fn(current_chunk_idx, &indices_within_chunk);
indices_within_chunk.clear();
}
current_chunk_idx = new_chunk_idx;
indices_within_chunk.push((idx + offset) % 1024);
}
if !indices_within_chunk.is_empty() {
chunk_fn(current_chunk_idx, &indices_within_chunk);
}
}