Skip to content

Commit 8f2d3e9

Browse files
committed
Flat Layout Execution
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 42ccb91 commit 8f2d3e9

File tree

8 files changed

+58
-41
lines changed

8 files changed

+58
-41
lines changed

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

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

44
use std::fmt::Formatter;
55

6-
use arrow_array::cast::AsArray;
76
use prost::Message;
87
use vortex_dtype::DType;
98
use vortex_error::vortex_bail;
@@ -121,10 +120,6 @@ impl VTable for Like {
121120
let child: Box<dyn arrow_array::Datum> = child.try_into()?;
122121
let pattern: Box<dyn arrow_array::Datum> = pattern.try_into()?;
123122

124-
let array = pattern.get().0;
125-
let sv = array.as_string_view();
126-
println!("STRING VIEW PATTERN: {:?}", sv);
127-
128123
let array = match (options.negated, options.case_insensitive) {
129124
(false, false) => arrow_string::like::like(child.as_ref(), pattern.as_ref()),
130125
(false, true) => arrow_string::like::ilike(child.as_ref(), pattern.as_ref()),

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ use std::fmt::Formatter;
55
use std::ops::BitOr;
66

77
use vortex_dtype::DType;
8-
use vortex_error::VortexResult;
98
use vortex_error::vortex_bail;
9+
use vortex_error::VortexResult;
1010
use vortex_vector::Datum;
1111

12-
use crate::ArrayRef;
1312
use crate::compute::list_contains as compute_list_contains;
13+
use crate::expr::exprs::binary::and;
14+
use crate::expr::exprs::binary::gt;
15+
use crate::expr::exprs::binary::lt;
16+
use crate::expr::exprs::binary::or;
17+
use crate::expr::exprs::literal::lit;
18+
use crate::expr::exprs::literal::Literal;
1419
use crate::expr::Arity;
1520
use crate::expr::ChildName;
1621
use crate::expr::EmptyOptions;
@@ -20,12 +25,7 @@ use crate::expr::Expression;
2025
use crate::expr::StatsCatalog;
2126
use crate::expr::VTable;
2227
use crate::expr::VTableExt;
23-
use crate::expr::exprs::binary::and;
24-
use crate::expr::exprs::binary::gt;
25-
use crate::expr::exprs::binary::lt;
26-
use crate::expr::exprs::binary::or;
27-
use crate::expr::exprs::literal::Literal;
28-
use crate::expr::exprs::literal::lit;
28+
use crate::ArrayRef;
2929

3030
pub struct ListContains;
3131

@@ -100,8 +100,8 @@ impl VTable for ListContains {
100100
compute_list_contains(list_array.as_ref(), value_array.as_ref())
101101
}
102102

103-
fn execute(&self, _data: &Self::Options, _args: ExecutionArgs) -> VortexResult<Datum> {
104-
todo!()
103+
fn execute(&self, options: &Self::Options, args: ExecutionArgs) -> VortexResult<Datum> {
104+
arrow_select::todo!()
105105
}
106106

107107
fn stat_falsification(
@@ -179,9 +179,6 @@ mod tests {
179179
use vortex_utils::aliases::hash_set::HashSet;
180180

181181
use super::list_contains;
182-
use crate::Array;
183-
use crate::ArrayRef;
184-
use crate::IntoArray;
185182
use crate::arrays::BoolArray;
186183
use crate::arrays::ListArray;
187184
use crate::arrays::PrimitiveArray;
@@ -196,6 +193,9 @@ mod tests {
196193
use crate::expr::pruning::checked_pruning_expr;
197194
use crate::expr::stats::Stat;
198195
use crate::validity::Validity;
196+
use crate::Array;
197+
use crate::ArrayRef;
198+
use crate::IntoArray;
199199

200200
fn test_array() -> ArrayRef {
201201
ListArray::try_new(

vortex-mask/src/mask_mut.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ impl MaskMut {
4444
Self(Inner::Empty { capacity })
4545
}
4646

47+
/// Creates a new mask with the specified capacity.
48+
pub fn new(len: usize, value: bool) -> Self {
49+
Self(Inner::Constant {
50+
value,
51+
len,
52+
capacity: len,
53+
})
54+
}
55+
4756
/// Creates a new mask with all values set to `true`.
4857
pub fn new_true(len: usize) -> Self {
4958
Self(Inner::Constant {

vortex-vector/src/binaryview/scalar.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::binaryview::BinaryViewVectorMut;
88
use crate::binaryview::StringType;
99
use crate::Scalar;
1010
use crate::ScalarOps;
11+
use crate::VectorMut;
1112
use crate::VectorMutOps;
1213

1314
/// A scalar value for types that implement [`BinaryViewType`].
@@ -39,14 +40,11 @@ impl<T: BinaryViewType> ScalarOps for BinaryViewScalar<T> {
3940
}
4041
}
4142

42-
fn repeat(&self, n: usize) -> crate::VectorMut {
43+
fn repeat(&self, n: usize) -> VectorMut {
4344
let mut vec = BinaryViewVectorMut::<T>::with_capacity(n);
4445
match self.value() {
4546
None => vec.append_nulls(n),
46-
Some(buf) => {
47-
println!("REPEATING BINARY VIEW SCALAR: {:?}", buf);
48-
vec.append_owned_values(buf.clone(), n)
49-
}
47+
Some(buf) => vec.append_owned_values(buf.clone(), n),
5048
}
5149
vec.into()
5250
}

vortex-vector/src/binaryview/vector_mut.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ use std::sync::Arc;
88
use vortex_buffer::BufferMut;
99
use vortex_buffer::ByteBuffer;
1010
use vortex_buffer::ByteBufferMut;
11+
use vortex_error::vortex_ensure;
1112
use vortex_error::VortexExpect;
1213
use vortex_error::VortexResult;
13-
use vortex_error::vortex_ensure;
1414
use vortex_mask::MaskMut;
1515

16-
use crate::VectorMutOps;
17-
use crate::VectorOps;
18-
use crate::binaryview::BinaryViewScalar;
19-
use crate::binaryview::BinaryViewType;
2016
use crate::binaryview::vector::BinaryViewVector;
21-
use crate::binaryview::view::BinaryView;
2217
use crate::binaryview::view::validate_views;
18+
use crate::binaryview::view::BinaryView;
19+
use crate::binaryview::BinaryViewScalar;
20+
use crate::binaryview::BinaryViewType;
21+
use crate::VectorMutOps;
22+
use crate::VectorOps;
2323

2424
// Default capacity for new string data buffers of 2MiB.
2525
const BUFFER_CAPACITY: usize = 2 * 1024 * 1024;
@@ -194,9 +194,8 @@ impl<T: BinaryViewType> BinaryViewVectorMut<T> {
194194
} else {
195195
self.flush_open_buffer();
196196

197-
let buffer_index = u32::try_from(self.buffers.len())
198-
.vortex_expect("buffer count exceeds u32::MAX")
199-
+ 1;
197+
let buffer_index =
198+
u32::try_from(self.buffers.len()).vortex_expect("buffer count exceeds u32::MAX");
200199
self.views
201200
.push_n(BinaryView::make_view(buffer.as_ref(), buffer_index, 0), n);
202201
self.buffers.push(buffer);
@@ -317,17 +316,17 @@ mod tests {
317316
use std::ops::Deref;
318317
use std::sync::Arc;
319318

320-
use vortex_buffer::ByteBuffer;
321319
use vortex_buffer::buffer;
322320
use vortex_buffer::buffer_mut;
321+
use vortex_buffer::ByteBuffer;
323322
use vortex_mask::Mask;
324323
use vortex_mask::MaskMut;
325324

326-
use crate::VectorMutOps;
327-
use crate::VectorOps;
325+
use crate::binaryview::view::BinaryView;
328326
use crate::binaryview::StringVector;
329327
use crate::binaryview::StringVectorMut;
330-
use crate::binaryview::view::BinaryView;
328+
use crate::VectorMutOps;
329+
use crate::VectorOps;
331330

332331
#[test]
333332
fn test_basic() {

vortex-vector/src/bool/scalar.rs

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

4+
use crate::bool::BoolVectorMut;
45
use crate::Scalar;
56
use crate::ScalarOps;
67
use crate::VectorMut;
78
use crate::VectorMutOps;
8-
use crate::bool::BoolVectorMut;
99

1010
/// A scalar value for boolean types.
1111
#[derive(Clone, Debug)]

vortex-vector/src/listview/scalar.rs

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

4+
use crate::listview::ListViewVector;
5+
use crate::listview::ListViewVectorMut;
46
use crate::Scalar;
57
use crate::ScalarOps;
68
use crate::VectorMut;
79
use crate::VectorOps;
8-
use crate::listview::ListViewVector;
10+
use std::sync::Arc;
911
use vortex_mask::Mask;
12+
use vortex_mask::MaskMut;
1013

1114
/// A scalar value for list view types.
1215
///
@@ -42,8 +45,21 @@ impl ScalarOps for ListViewScalar {
4245
}
4346
}
4447

45-
fn repeat(&self, _n: usize) -> VectorMut {
46-
todo!()
48+
fn repeat(&self, n: usize) -> VectorMut {
49+
// Grab the scalar elements.
50+
let elements = self.0.elements.clone();
51+
// Repeat the offset and size n times.
52+
let offsets = self.0.offsets.scalar_at(0).repeat(n).into_primitive();
53+
let sizes = self.0.sizes.scalar_at(0).repeat(n).into_primitive();
54+
unsafe {
55+
ListViewVectorMut::new_unchecked(
56+
Box::new(Arc::unwrap_or_clone(elements).into_mut()),
57+
offsets,
58+
sizes,
59+
MaskMut::new(n, self.is_valid()),
60+
)
61+
}
62+
.into()
4763
}
4864
}
4965

vortex-vector/src/scalar_ops.rs

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

4+
use crate::private;
45
use crate::Scalar;
56
use crate::VectorMut;
6-
use crate::private;
77

88
/// Trait for scalar operations.
99
pub trait ScalarOps: private::Sealed + Sized + Into<Scalar> {

0 commit comments

Comments
 (0)