|
1 | 1 | // SPDX-License-Identifier: Apache-2.0 |
2 | 2 | // SPDX-FileCopyrightText: Copyright the Vortex contributors |
3 | 3 |
|
4 | | -use std::any::Any; |
5 | 4 | use std::fmt::Debug; |
6 | | -use std::hash::{Hash, Hasher}; |
7 | | -use std::sync::Arc; |
8 | 5 |
|
9 | | -use async_trait::async_trait; |
10 | | -use futures::try_join; |
11 | | -use itertools::Itertools; |
12 | 6 | use vortex_array::compute::{BetweenOptions, StrictComparison, between as between_compute}; |
13 | | -use vortex_array::operator::{ |
14 | | - BatchBindCtx, BatchExecution, BatchExecutionRef, BatchOperator, LengthBounds, Operator, |
15 | | - OperatorEq, OperatorHash, OperatorId, OperatorRef, |
16 | | -}; |
17 | | -use vortex_array::{Array, ArrayRef, Canonical, DeserializeMetadata, IntoArray, ProstMetadata}; |
| 7 | +use vortex_array::{ArrayRef, DeserializeMetadata, ProstMetadata}; |
18 | 8 | use vortex_dtype::DType; |
19 | 9 | use vortex_dtype::DType::Bool; |
20 | | -use vortex_error::{VortexExpect, VortexResult, vortex_bail}; |
| 10 | +use vortex_error::{VortexResult, vortex_bail}; |
21 | 11 | use vortex_proto::expr as pb; |
22 | 12 |
|
23 | 13 | use crate::display::{DisplayAs, DisplayFormat}; |
@@ -137,23 +127,6 @@ impl VTable for BetweenVTable { |
137 | 127 | arr_dt.nullability() | lower_dt.nullability() | upper_dt.nullability(), |
138 | 128 | )) |
139 | 129 | } |
140 | | - |
141 | | - fn operator(expr: &Self::Expr, scope: &OperatorRef) -> VortexResult<Option<OperatorRef>> { |
142 | | - let Some(arr) = expr.arr.operator(scope)? else { |
143 | | - return Ok(None); |
144 | | - }; |
145 | | - let Some(lower) = expr.lower.operator(scope)? else { |
146 | | - return Ok(None); |
147 | | - }; |
148 | | - let Some(upper) = expr.upper.operator(scope)? else { |
149 | | - return Ok(None); |
150 | | - }; |
151 | | - Ok(Some(Arc::new(BetweenOperator { |
152 | | - children: [arr, lower, upper], |
153 | | - dtype: expr.return_dtype(scope.dtype())?, |
154 | | - options: expr.options.clone(), |
155 | | - }))) |
156 | | - } |
157 | 130 | } |
158 | 131 |
|
159 | 132 | impl BetweenExpr { |
@@ -245,119 +218,6 @@ pub fn between(arr: ExprRef, lower: ExprRef, upper: ExprRef, options: BetweenOpt |
245 | 218 | BetweenExpr::new(arr, lower, upper, options).into_expr() |
246 | 219 | } |
247 | 220 |
|
248 | | -#[derive(Debug)] |
249 | | -pub struct BetweenOperator { |
250 | | - children: [OperatorRef; 3], |
251 | | - dtype: DType, |
252 | | - options: BetweenOptions, |
253 | | -} |
254 | | - |
255 | | -impl OperatorHash for BetweenOperator { |
256 | | - fn operator_hash<H: Hasher>(&self, state: &mut H) { |
257 | | - for child in &self.children { |
258 | | - child.operator_hash(state); |
259 | | - } |
260 | | - self.dtype.hash(state); |
261 | | - self.options.hash(state); |
262 | | - } |
263 | | -} |
264 | | - |
265 | | -impl OperatorEq for BetweenOperator { |
266 | | - fn operator_eq(&self, other: &Self) -> bool { |
267 | | - self.children.len() == other.children.len() |
268 | | - && self |
269 | | - .children |
270 | | - .iter() |
271 | | - .zip(other.children.iter()) |
272 | | - .all(|(a, b)| a.operator_eq(b)) |
273 | | - && self.dtype == other.dtype |
274 | | - && self.options == other.options |
275 | | - } |
276 | | -} |
277 | | - |
278 | | -impl Operator for BetweenOperator { |
279 | | - fn id(&self) -> OperatorId { |
280 | | - OperatorId::from("vortex.between") |
281 | | - } |
282 | | - |
283 | | - fn as_any(&self) -> &dyn Any { |
284 | | - self |
285 | | - } |
286 | | - |
287 | | - fn dtype(&self) -> &DType { |
288 | | - &self.dtype |
289 | | - } |
290 | | - |
291 | | - fn bounds(&self) -> LengthBounds { |
292 | | - self.children[0].bounds() |
293 | | - } |
294 | | - |
295 | | - fn children(&self) -> &[OperatorRef] { |
296 | | - &self.children |
297 | | - } |
298 | | - |
299 | | - fn with_children(self: Arc<Self>, children: Vec<OperatorRef>) -> VortexResult<OperatorRef> { |
300 | | - let (arr, lower, upper) = children |
301 | | - .into_iter() |
302 | | - .tuples() |
303 | | - .next() |
304 | | - .vortex_expect("expected 3 children"); |
305 | | - |
306 | | - Ok(Arc::new(BetweenOperator { |
307 | | - children: [arr, lower, upper], |
308 | | - dtype: self.dtype.clone(), |
309 | | - options: self.options.clone(), |
310 | | - })) |
311 | | - } |
312 | | - |
313 | | - fn is_selection_target(&self, _child_idx: usize) -> Option<bool> { |
314 | | - // All children are position preserving. |
315 | | - Some(true) |
316 | | - } |
317 | | -} |
318 | | - |
319 | | -impl BatchOperator for BetweenOperator { |
320 | | - fn bind(&self, ctx: &mut dyn BatchBindCtx) -> VortexResult<BatchExecutionRef> { |
321 | | - let arr = ctx.child(0)?; |
322 | | - let lower = ctx.child(1)?; |
323 | | - let upper = ctx.child(2)?; |
324 | | - Ok(Box::new(BetweenExecution { |
325 | | - arr, |
326 | | - lower, |
327 | | - upper, |
328 | | - options: self.options.clone(), |
329 | | - })) |
330 | | - } |
331 | | -} |
332 | | - |
333 | | -struct BetweenExecution { |
334 | | - arr: BatchExecutionRef, |
335 | | - lower: BatchExecutionRef, |
336 | | - upper: BatchExecutionRef, |
337 | | - options: BetweenOptions, |
338 | | -} |
339 | | - |
340 | | -#[async_trait] |
341 | | -impl BatchExecution for BetweenExecution { |
342 | | - async fn execute(self: Box<Self>) -> VortexResult<Canonical> { |
343 | | - let (arr, lower, upper) = try_join!( |
344 | | - self.arr.execute(), |
345 | | - self.lower.execute(), |
346 | | - self.upper.execute() |
347 | | - )?; |
348 | | - let result = between_compute( |
349 | | - arr.into_array().as_ref(), |
350 | | - lower.into_array().as_ref(), |
351 | | - upper.into_array().as_ref(), |
352 | | - &self.options, |
353 | | - )?; |
354 | | - Ok(result.to_canonical()) |
355 | | - } |
356 | | -} |
357 | | - |
358 | | -// TODO(ngates): we need scalar variants for batch execution. Although really it should be |
359 | | -// pipelined? |
360 | | - |
361 | 221 | #[cfg(test)] |
362 | 222 | mod tests { |
363 | 223 | use vortex_array::compute::{BetweenOptions, StrictComparison}; |
|
0 commit comments