Skip to content

Commit ecef7da

Browse files
committed
Clarify docs in session accessors
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 6af44bb commit ecef7da

File tree

22 files changed

+160
-126
lines changed

22 files changed

+160
-126
lines changed

vortex-array/src/arrays/chunked/vtable/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ use vortex_buffer::BufferHandle;
66
use vortex_dtype::DType;
77
use vortex_dtype::Nullability;
88
use vortex_dtype::PType;
9+
use vortex_error::VortexResult;
910
use vortex_error::vortex_bail;
1011
use vortex_error::vortex_err;
11-
use vortex_error::VortexResult;
1212
use vortex_mask::Mask;
1313
use vortex_vector::Vector;
1414
use vortex_vector::VectorMut;
1515
use vortex_vector::VectorMutOps;
1616

17+
use crate::EmptyMetadata;
18+
use crate::ToCanonical;
1719
use crate::arrays::ChunkedArray;
1820
use crate::arrays::PrimitiveArray;
1921
use crate::kernel::BindCtx;
@@ -28,8 +30,6 @@ use crate::vtable::ArrayVTable;
2830
use crate::vtable::ArrayVTableExt;
2931
use crate::vtable::NotSupported;
3032
use crate::vtable::VTable;
31-
use crate::EmptyMetadata;
32-
use crate::ToCanonical;
3333

3434
mod array;
3535
mod canonical;

vortex-array/src/arrays/filter/vtable.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ use std::ops::Range;
77
use vortex_buffer::BufferHandle;
88
use vortex_compute::filter::Filter;
99
use vortex_dtype::DType;
10-
use vortex_error::vortex_bail;
1110
use vortex_error::VortexExpect;
1211
use vortex_error::VortexResult;
12+
use vortex_error::vortex_bail;
1313
use vortex_mask::Mask;
1414
use vortex_scalar::Scalar;
1515

16+
use crate::Array;
17+
use crate::ArrayBufferVisitor;
18+
use crate::ArrayChildVisitor;
19+
use crate::ArrayEq;
20+
use crate::ArrayHash;
21+
use crate::ArrayRef;
22+
use crate::Canonical;
23+
use crate::IntoArray;
24+
use crate::Precision;
25+
use crate::arrays::LEGACY_SESSION;
1626
use crate::arrays::filter::array::FilterArray;
1727
use crate::arrays::filter::kernel::FilterKernel;
18-
use crate::arrays::LEGACY_SESSION;
1928
use crate::kernel::BindCtx;
2029
use crate::kernel::KernelRef;
2130
use crate::kernel::PushDownResult;
@@ -33,15 +42,6 @@ use crate::vtable::OperationsVTable;
3342
use crate::vtable::VTable;
3443
use crate::vtable::ValidityVTable;
3544
use crate::vtable::VisitorVTable;
36-
use crate::Array;
37-
use crate::ArrayBufferVisitor;
38-
use crate::ArrayChildVisitor;
39-
use crate::ArrayEq;
40-
use crate::ArrayHash;
41-
use crate::ArrayRef;
42-
use crate::Canonical;
43-
use crate::IntoArray;
44-
use crate::Precision;
4545

4646
vtable!(Filter);
4747

@@ -83,14 +83,15 @@ impl VTable for FilterVTable {
8383
&self,
8484
dtype: &DType,
8585
len: usize,
86-
metadata: &Self::Metadata,
86+
selection_mask: &Mask,
8787
_buffers: &[BufferHandle],
8888
children: &dyn ArrayChildren,
8989
) -> VortexResult<Self::Array> {
90-
let child = children.get(0, dtype, len)?;
90+
assert_eq!(len, selection_mask.true_count());
91+
let child = children.get(0, dtype, selection_mask.len())?;
9192
Ok(FilterArray {
9293
child,
93-
mask: metadata.clone(),
94+
mask: selection_mask.clone(),
9495
stats: Default::default(),
9596
})
9697
}

vortex-array/src/arrays/scalar_fn/vtable/canonical.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
use itertools::Itertools;
55
use vortex_error::VortexExpect;
66

7+
use crate::Array;
8+
use crate::Canonical;
9+
use crate::arrays::LEGACY_SESSION;
710
use crate::arrays::scalar_fn::array::ScalarFnArray;
811
use crate::arrays::scalar_fn::vtable::ScalarFnVTable;
9-
use crate::arrays::LEGACY_SESSION;
1012
use crate::executor::VectorExecutor;
1113
use crate::expr::ExecutionArgs;
1214
use crate::vectors::VectorIntoArray;
1315
use crate::vtable::CanonicalVTable;
14-
use crate::Array;
15-
use crate::Canonical;
1616

1717
impl CanonicalVTable<ScalarFnVTable> for ScalarFnVTable {
1818
fn canonicalize(array: &ScalarFnArray) -> Canonical {

vortex-array/src/arrays/scalar_fn/vtable/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ use std::ops::Deref;
1313
use itertools::Itertools;
1414
use vortex_buffer::BufferHandle;
1515
use vortex_dtype::DType;
16+
use vortex_error::VortexResult;
1617
use vortex_error::vortex_bail;
1718
use vortex_error::vortex_ensure;
18-
use vortex_error::VortexResult;
1919

20+
use crate::Array;
21+
use crate::ArrayRef;
22+
use crate::IntoArray;
23+
use crate::arrays::ConstantVTable;
2024
use crate::arrays::scalar_fn::array::ScalarFnArray;
2125
use crate::arrays::scalar_fn::kernel::KernelInput;
2226
use crate::arrays::scalar_fn::kernel::ScalarFnKernel;
2327
use crate::arrays::scalar_fn::metadata::ScalarFnMetadata;
24-
use crate::arrays::ConstantVTable;
2528
use crate::expr;
2629
use crate::expr::ExprVTable;
2730
use crate::expr::ScalarFn;
@@ -36,9 +39,6 @@ use crate::vtable::ArrayVTable;
3639
use crate::vtable::ArrayVTableExt;
3740
use crate::vtable::NotSupported;
3841
use crate::vtable::VTable;
39-
use crate::Array;
40-
use crate::ArrayRef;
41-
use crate::IntoArray;
4242

4343
vtable!(ScalarFn);
4444

vortex-array/src/arrays/struct_/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod compute;
77
mod rules;
88

99
mod vtable;
10-
pub use rules::*;
10+
pub(crate) use rules::*;
1111
pub use vtable::StructVTable;
1212

1313
#[cfg(test)]

vortex-array/src/arrays/struct_/rules.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
use vortex_error::VortexResult;
55

6+
use crate::Array;
7+
use crate::ArrayRef;
8+
use crate::IntoArray;
69
use crate::arrays::ConstantArray;
710
use crate::arrays::ExactScalarFn;
811
use crate::arrays::ScalarFnArrayExt;
@@ -16,9 +19,6 @@ use crate::optimizer::rules::ArrayParentReduceRule;
1619
use crate::optimizer::rules::Exact;
1720
use crate::validity::Validity;
1821
use crate::vtable::ValidityHelper;
19-
use crate::Array;
20-
use crate::ArrayRef;
21-
use crate::IntoArray;
2222

2323
#[derive(Debug)]
2424
pub(crate) struct StructGetItemRule;

vortex-array/src/executor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
use vortex_error::vortex_ensure;
54
use vortex_error::VortexResult;
5+
use vortex_error::vortex_ensure;
66
use vortex_session::VortexSession;
77
use vortex_vector::Datum;
88
use vortex_vector::Vector;
99
use vortex_vector::VectorOps;
1010

11+
use crate::Array;
12+
use crate::ArrayRef;
1113
use crate::arrays::ConstantVTable;
1214
use crate::kernel::BindCtx;
1315
use crate::session::ArraySessionExt;
14-
use crate::Array;
15-
use crate::ArrayRef;
1616

1717
/// Executor for exporting a Vortex [`Vector`] or [`Datum`] from an [`ArrayRef`].
1818
pub trait VectorExecutor {

vortex-array/src/expr/exprs/binary.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ use prost::Message;
88
use vortex_compute::arrow::IntoArrow;
99
use vortex_compute::arrow::IntoVector;
1010
use vortex_dtype::DType;
11-
use vortex_error::vortex_bail;
12-
use vortex_error::vortex_err;
1311
use vortex_error::VortexExpect;
1412
use vortex_error::VortexResult;
13+
use vortex_error::vortex_bail;
14+
use vortex_error::vortex_err;
1515
use vortex_proto::expr as pb;
1616
use vortex_vector::Datum;
1717
use vortex_vector::VectorOps;
1818

19+
use crate::ArrayRef;
1920
use crate::compute;
2021
use crate::compute::add;
2122
use crate::compute::and_kleene;
@@ -24,18 +25,17 @@ use crate::compute::div;
2425
use crate::compute::mul;
2526
use crate::compute::or_kleene;
2627
use crate::compute::sub;
27-
use crate::expr::expression::Expression;
28-
use crate::expr::exprs::literal::lit;
29-
use crate::expr::exprs::operators::Operator;
30-
use crate::expr::stats::Stat;
3128
use crate::expr::Arity;
3229
use crate::expr::ChildName;
3330
use crate::expr::ExecutionArgs;
3431
use crate::expr::ExprId;
3532
use crate::expr::StatsCatalog;
3633
use crate::expr::VTable;
3734
use crate::expr::VTableExt;
38-
use crate::ArrayRef;
35+
use crate::expr::expression::Expression;
36+
use crate::expr::exprs::literal::lit;
37+
use crate::expr::exprs::operators::Operator;
38+
use crate::expr::stats::Stat;
3939

4040
pub struct Binary;
4141

@@ -589,10 +589,10 @@ mod tests {
589589
use super::lt_eq;
590590
use super::not_eq;
591591
use super::or;
592+
use crate::expr::Expression;
592593
use crate::expr::exprs::get_item::col;
593594
use crate::expr::exprs::literal::lit;
594595
use crate::expr::test_harness;
595-
use crate::expr::Expression;
596596

597597
#[test]
598598
fn and_collect_left_assoc() {

vortex-array/src/expr/exprs/get_item.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use vortex_dtype::DType;
99
use vortex_dtype::FieldName;
1010
use vortex_dtype::FieldPath;
1111
use vortex_dtype::Nullability;
12-
use vortex_error::vortex_err;
1312
use vortex_error::VortexExpect;
1413
use vortex_error::VortexResult;
14+
use vortex_error::vortex_err;
1515
use vortex_mask::Mask;
1616
use vortex_proto::expr as pb;
1717
use vortex_vector::Datum;
1818
use vortex_vector::ScalarOps;
1919
use vortex_vector::VectorOps;
2020

21+
use crate::ArrayRef;
22+
use crate::ToCanonical;
2123
use crate::compute::mask;
22-
use crate::expr::exprs::root::root;
23-
use crate::expr::stats::Stat;
2424
use crate::expr::Arity;
2525
use crate::expr::ChildName;
2626
use crate::expr::ExecutionArgs;
@@ -31,8 +31,8 @@ use crate::expr::SimplifyCtx;
3131
use crate::expr::StatsCatalog;
3232
use crate::expr::VTable;
3333
use crate::expr::VTableExt;
34-
use crate::ArrayRef;
35-
use crate::ToCanonical;
34+
use crate::expr::exprs::root::root;
35+
use crate::expr::stats::Stat;
3636

3737
pub struct GetItem;
3838

@@ -232,15 +232,15 @@ mod tests {
232232
use vortex_dtype::StructFields;
233233
use vortex_scalar::Scalar;
234234

235+
use crate::Array;
236+
use crate::IntoArray;
235237
use crate::arrays::StructArray;
236238
use crate::expr::exprs::binary::checked_add;
237239
use crate::expr::exprs::get_item::get_item;
238240
use crate::expr::exprs::literal::lit;
239241
use crate::expr::exprs::pack::pack;
240242
use crate::expr::exprs::root::root;
241243
use crate::validity::Validity;
242-
use crate::Array;
243-
use crate::IntoArray;
244244

245245
fn test_array() -> StructArray {
246246
StructArray::from_fields(&[

vortex-array/src/expr/exprs/like.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use vortex_error::vortex_bail;
1212
use vortex_error::vortex_err;
1313
use vortex_proto::expr as pb;
1414
use vortex_vector::Datum;
15+
use vortex_vector::VectorOps;
1516

1617
use crate::ArrayRef;
1718
use crate::compute::LikeOptions;
@@ -128,6 +129,12 @@ impl VTable for Like {
128129
(true, true) => arrow_string::like::nilike(child.as_ref(), pattern.as_ref()),
129130
}?;
130131

132+
let vector = array.into_vector()?;
133+
if vector.len() == 1 && args.row_count != 1 {
134+
// Arrow returns a scalar datum result
135+
return Ok(Datum::Scalar(vector.scalar_at(0).into()));
136+
}
137+
131138
Ok(Datum::Vector(array.into_vector()?.into()))
132139
}
133140

0 commit comments

Comments
 (0)