Skip to content

Commit

Permalink
enable FilterFn on VarBin -> fix issue with FSST filter
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Oct 18, 2024
1 parent 548f63c commit 3c1af26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions encodings/fsst/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::sync::Arc;

use fsst::{Decompressor, Symbol};
use serde::{Deserialize, Serialize};
use vortex::array::VarBinArray;
use vortex::array::{VarBin, VarBinArray};
use vortex::encoding::ids;
use vortex::stats::{ArrayStatisticsCompute, StatsSet};
use vortex::validity::{ArrayValidity, LogicalValidity, Validity};
use vortex::variants::{ArrayVariants, BinaryArrayTrait, Utf8ArrayTrait};
use vortex::visitor::AcceptArrayVisitor;
use vortex::{impl_encoding, Array, ArrayDType, ArrayTrait, IntoCanonical};
use vortex::{impl_encoding, Array, ArrayDType, ArrayDef, ArrayTrait, IntoCanonical};
use vortex_dtype::{DType, Nullability, PType};
use vortex_error::{vortex_bail, VortexExpect, VortexResult};

Expand Down Expand Up @@ -73,6 +73,13 @@ impl FSSTArray {
vortex_bail!(InvalidArgument: "uncompressed_lengths must have integer type and cannot be nullable");
}

if codes.encoding().id() != VarBin::ID {
vortex_bail!(
InvalidArgument: "codes must have varbin encoding, was {}",
codes.encoding().id()
);
}

// Check: strings must be a Binary array.
if !matches!(codes.dtype(), DType::Binary(_)) {
vortex_bail!(InvalidArgument: "codes array must be DType::Binary type");
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/array/varbin/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn filter_select_var_bin_by_slice(
predicate: &dyn BoolArrayTrait,
selection_count: usize,
) -> VortexResult<VarBinArray> {
let offsets = values.offsets().as_primitive();
let offsets = values.offsets().into_primitive()?;
match_each_integer_ptype!(offsets.ptype(), |$O| {
filter_select_var_bin_by_slice_primitive_offset(
values.dtype().clone(),
Expand Down Expand Up @@ -137,7 +137,7 @@ fn filter_select_var_bin_by_index(
predicate: &dyn BoolArrayTrait,
selection_count: usize,
) -> VortexResult<VarBinArray> {
let offsets = values.offsets().as_primitive();
let offsets = values.offsets().into_primitive()?;
match_each_integer_ptype!(offsets.ptype(), |$O| {
filter_select_var_bin_by_index_primitive_offset(
values.dtype().clone(),
Expand Down
6 changes: 5 additions & 1 deletion vortex-array/src/array/varbin/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ use vortex_scalar::Scalar;

use crate::array::varbin::{varbin_scalar, VarBinArray};
use crate::compute::unary::ScalarAtFn;
use crate::compute::{ArrayCompute, SliceFn, TakeFn};
use crate::compute::{ArrayCompute, FilterFn, SliceFn, TakeFn};
use crate::ArrayDType;

mod filter;
mod slice;
mod take;

impl ArrayCompute for VarBinArray {
fn filter(&self) -> Option<&dyn FilterFn> {
Some(self)
}

fn scalar_at(&self) -> Option<&dyn ScalarAtFn> {
Some(self)
}
Expand Down

0 comments on commit 3c1af26

Please sign in to comment.