Skip to content

Commit e4d44ff

Browse files
committed
u
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 4011628 commit e4d44ff

4 files changed

Lines changed: 54 additions & 1 deletion

File tree

vortex-array/public-api.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Documenting vortex-array v0.1.0 (/Users/joeisaacs/git/spiraldb/vortex/vortex-array)
2-
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.75s
2+
Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.03s
33
pub mod vortex_array
44
pub mod vortex_array::accessor
55
pub trait vortex_array::accessor::ArrayAccessor<Item: ?core::marker::Sized>
@@ -63,6 +63,8 @@ impl vortex_array::expr::CastReduce for vortex_array::arrays::DictVTable
6363
pub fn vortex_array::arrays::DictVTable::cast(array: &vortex_array::arrays::DictArray, dtype: &vortex_dtype::dtype::DType) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
6464
impl vortex_array::expr::FillNullKernel for vortex_array::arrays::DictVTable
6565
pub fn vortex_array::arrays::DictVTable::fill_null(array: &vortex_array::arrays::DictArray, fill_value: &vortex_scalar::scalar::Scalar, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
66+
impl vortex_array::expr::LikeReduce for vortex_array::arrays::DictVTable
67+
pub fn vortex_array::arrays::DictVTable::like(array: &vortex_array::arrays::DictArray, pattern: &dyn vortex_array::Array, options: vortex_array::expr::LikeOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
6668
impl vortex_array::vtable::BaseArrayVTable<vortex_array::arrays::DictVTable> for vortex_array::arrays::DictVTable
6769
pub fn vortex_array::arrays::DictVTable::array_eq(array: &vortex_array::arrays::DictArray, other: &vortex_array::arrays::DictArray, precision: vortex_array::Precision) -> bool
6870
pub fn vortex_array::arrays::DictVTable::array_hash<H: core::hash::Hasher>(array: &vortex_array::arrays::DictArray, state: &mut H, precision: vortex_array::Precision)
@@ -569,6 +571,8 @@ impl vortex_array::expr::CastReduce for vortex_array::arrays::DictVTable
569571
pub fn vortex_array::arrays::DictVTable::cast(array: &vortex_array::arrays::DictArray, dtype: &vortex_dtype::dtype::DType) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
570572
impl vortex_array::expr::FillNullKernel for vortex_array::arrays::DictVTable
571573
pub fn vortex_array::arrays::DictVTable::fill_null(array: &vortex_array::arrays::DictArray, fill_value: &vortex_scalar::scalar::Scalar, _ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
574+
impl vortex_array::expr::LikeReduce for vortex_array::arrays::DictVTable
575+
pub fn vortex_array::arrays::DictVTable::like(array: &vortex_array::arrays::DictArray, pattern: &dyn vortex_array::Array, options: vortex_array::expr::LikeOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
572576
impl vortex_array::vtable::BaseArrayVTable<vortex_array::arrays::DictVTable> for vortex_array::arrays::DictVTable
573577
pub fn vortex_array::arrays::DictVTable::array_eq(array: &vortex_array::arrays::DictArray, other: &vortex_array::arrays::DictArray, precision: vortex_array::Precision) -> bool
574578
pub fn vortex_array::arrays::DictVTable::array_hash<H: core::hash::Hasher>(array: &vortex_array::arrays::DictArray, state: &mut H, precision: vortex_array::Precision)
@@ -4571,6 +4575,8 @@ pub trait vortex_array::expr::LikeKernel: vortex_array::vtable::VTable
45714575
pub fn vortex_array::expr::LikeKernel::like(array: &Self::Array, pattern: &dyn vortex_array::Array, options: vortex_array::expr::LikeOptions, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
45724576
pub trait vortex_array::expr::LikeReduce: vortex_array::vtable::VTable
45734577
pub fn vortex_array::expr::LikeReduce::like(array: &Self::Array, pattern: &dyn vortex_array::Array, options: vortex_array::expr::LikeOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
4578+
impl vortex_array::expr::LikeReduce for vortex_array::arrays::DictVTable
4579+
pub fn vortex_array::arrays::DictVTable::like(array: &vortex_array::arrays::DictArray, pattern: &dyn vortex_array::Array, options: vortex_array::expr::LikeOptions) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
45744580
pub trait vortex_array::expr::NotKernel: vortex_array::vtable::VTable
45754581
pub fn vortex_array::expr::NotKernel::invert(array: &Self::Array, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<vortex_array::ArrayRef>>
45764582
pub trait vortex_array::expr::NotReduce: vortex_array::vtable::VTable
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_error::VortexResult;
5+
6+
use super::DictArray;
7+
use super::DictVTable;
8+
use crate::Array;
9+
use crate::ArrayRef;
10+
use crate::IntoArray;
11+
use crate::arrays::ConstantArray;
12+
use crate::expr::LikeOptions;
13+
use crate::expr::LikeReduce;
14+
use crate::expr::like::arrow_like;
15+
16+
impl LikeReduce for DictVTable {
17+
fn like(
18+
array: &DictArray,
19+
pattern: &dyn Array,
20+
options: LikeOptions,
21+
) -> VortexResult<Option<ArrayRef>> {
22+
// If we have more values than codes, it is faster to canonicalize first.
23+
if array.values().len() > array.codes().len() {
24+
return Ok(None);
25+
}
26+
if let Some(pattern) = pattern.as_constant() {
27+
let pattern = ConstantArray::new(pattern, array.values().len()).into_array();
28+
let values = arrow_like(array.values(), &pattern, options)?;
29+
30+
// SAFETY: LIKE preserves the len of the values, so codes are still pointing at
31+
// valid positions.
32+
// Preserve all_values_referenced since codes are unchanged.
33+
unsafe {
34+
Ok(Some(
35+
DictArray::new_unchecked(array.codes().clone(), values)
36+
.set_all_values_referenced(array.has_all_values_referenced())
37+
.into_array(),
38+
))
39+
}
40+
} else {
41+
Ok(None)
42+
}
43+
}
44+
}

vortex-array/src/arrays/dict/compute/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod compare;
66
mod fill_null;
77
mod is_constant;
88
mod is_sorted;
9+
mod like;
910
mod min_max;
1011
pub(crate) mod rules;
1112
mod slice;

vortex-array/src/arrays/dict/compute/rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::arrays::SliceReduceAdaptor;
1919
use crate::builtins::ArrayBuiltins;
2020
use crate::compute::CastReduceAdaptor;
2121
use crate::expr::Cast;
22+
use crate::expr::LikeReduceAdaptor;
2223
use crate::expr::Pack;
2324
use crate::optimizer::ArrayOptimizer;
2425
use crate::optimizer::rules::ArrayParentReduceRule;
@@ -27,6 +28,7 @@ use crate::optimizer::rules::ParentRuleSet;
2728
pub(crate) const PARENT_RULES: ParentRuleSet<DictVTable> = ParentRuleSet::new(&[
2829
ParentRuleSet::lift(&FilterReduceAdaptor(DictVTable)),
2930
ParentRuleSet::lift(&CastReduceAdaptor(DictVTable)),
31+
ParentRuleSet::lift(&LikeReduceAdaptor(DictVTable)),
3032
ParentRuleSet::lift(&DictionaryScalarFnValuesPushDownRule),
3133
ParentRuleSet::lift(&DictionaryScalarFnCodesPullUpRule),
3234
ParentRuleSet::lift(&SliceReduceAdaptor(DictVTable)),

0 commit comments

Comments
 (0)