use vortex_array::ArrayRef;
use vortex_array::dtype::PType;
use vortex_array::scalar::Scalar;
use vortex_array::stats::ArrayStats;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
pub mod for_compress;
pub mod for_decompress;
#[derive(Clone, Debug)]
pub struct FoRArray {
pub(super) encoded: ArrayRef,
pub(super) reference: Scalar,
pub(super) stats_set: ArrayStats,
}
impl FoRArray {
pub fn try_new(encoded: ArrayRef, reference: Scalar) -> VortexResult<Self> {
if reference.is_null() {
vortex_bail!("Reference value cannot be null");
}
let reference = reference.cast(
&reference
.dtype()
.with_nullability(encoded.dtype().nullability()),
)?;
Ok(Self {
encoded,
reference,
stats_set: Default::default(),
})
}
pub(crate) unsafe fn new_unchecked(encoded: ArrayRef, reference: Scalar) -> Self {
Self {
encoded,
reference,
stats_set: Default::default(),
}
}
#[inline]
pub fn ptype(&self) -> PType {
self.dtype().as_ptype()
}
#[inline]
pub fn encoded(&self) -> &ArrayRef {
&self.encoded
}
#[inline]
pub fn reference_scalar(&self) -> &Scalar {
&self.reference
}
pub(crate) fn stats_set(&self) -> &ArrayStats {
&self.stats_set
}
}