Skip to content

Commit

Permalink
remove some old execute methods
Browse files Browse the repository at this point in the history
  • Loading branch information
scsmithr committed Jan 10, 2025
1 parent b1501b8 commit 82080c8
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 356 deletions.
1 change: 1 addition & 0 deletions crates/rayexec_execution/src/arrays/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ impl Array {
/// Takes into account any existing selection. This allows for repeated
/// selection (filtering) against the same array.
// TODO: Add test for selecting on logically empty array.
#[deprecated]
pub fn select_mut2(&mut self, selection: impl Into<LogicalSelection>) {
let selection = selection.into();
match self.selection_vector() {
Expand Down
6 changes: 6 additions & 0 deletions crates/rayexec_execution/src/arrays/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::arrays::row::ScalarRow;
use crate::arrays::selection::SelectionVector;

/// A batch of same-length arrays.
// TODO: Remove Clone, PartialEq
#[derive(Debug, Clone, PartialEq)]
pub struct Batch {
/// Arrays making up the batch.
Expand Down Expand Up @@ -135,6 +136,7 @@ impl Batch {
/// Concat multiple batches into one.
///
/// Batches are requried to have the same logical schemas.
#[deprecated]
pub fn concat(batches: &[Batch]) -> Result<Self> {
let num_cols = match batches.first() {
Some(batch) => batch.num_arrays(),
Expand Down Expand Up @@ -177,6 +179,7 @@ impl Batch {
}

// TODO: Owned variant
#[deprecated]
pub fn project(&self, indices: &[usize]) -> Self {
let cols = indices
.iter()
Expand All @@ -191,6 +194,7 @@ impl Batch {
}

// TODO: Remove
#[deprecated]
pub fn slice(&self, offset: usize, count: usize) -> Self {
let cols = self.arrays.iter().map(|c| c.slice(offset, count)).collect();
Batch {
Expand All @@ -205,6 +209,7 @@ impl Batch {
///
/// This accepts an Arc selection as it'll be cloned for each array in the
/// batch.
#[deprecated]
pub fn select(&self, selection: Arc<SelectionVector>) -> Batch {
let cols = self
.arrays
Expand All @@ -224,6 +229,7 @@ impl Batch {
}

/// Get the row at some index.
#[deprecated]
pub fn row(&self, idx: usize) -> Option<ScalarRow> {
if idx >= self.num_rows {
return None;
Expand Down
90 changes: 0 additions & 90 deletions crates/rayexec_execution/src/arrays/compute/cast/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,96 +77,6 @@ use crate::arrays::executor::builder::{ArrayBuilder, PrimitiveBuffer};
use crate::arrays::executor::scalar::UnaryExecutor;
use crate::arrays::executor::OutBuffer;
use crate::arrays::scalar::decimal::{Decimal128Type, Decimal64Type, DecimalType};
use crate::arrays::storage::{AddressableStorage, PrimitiveStorage};

// TODO: Remove
pub fn cast_decimal_to_float_old<'a, S, F>(
arr: &'a Array,
to: DataType,
_behavior: CastFailBehavior,
) -> Result<Array>
where
S: PhysicalStorage,
F: Float + Default + Copy,
<<S as PhysicalStorage>::Storage<'a> as AddressableStorage>::T: ToPrimitive,
ArrayData2: From<PrimitiveStorage<F>>,
{
let decimal_meta = arr.datatype().try_get_decimal_type_meta()?;

let scale = <F as NumCast>::from((10.0).powi(decimal_meta.scale as i32)).ok_or_else(|| {
RayexecError::new(format!(
"Failed to cast scale {} to float",
decimal_meta.scale
))
})?;

let builder = ArrayBuilder {
datatype: to,
buffer: PrimitiveBuffer::<F>::with_len(arr.logical_len()),
};

let output =
UnaryExecutor::execute2::<S, _, _>(arr, builder, |v, buf| match <F as NumCast>::from(v) {
Some(v) => {
let scaled = v.div(scale);
buf.put(&scaled);
}
None => (),
})?;

Ok(output)
}

pub fn decimal_rescale_old<'a, S, D>(
arr: &'a Array,
to: DataType,
_behavior: CastFailBehavior,
) -> Result<Array>
where
S: PhysicalStorage,
D: DecimalType,
S::Type<'a>: PrimInt,
ArrayData2: From<PrimitiveStorage<D::Primitive>>,
{
let new_meta = to.try_get_decimal_type_meta()?;
let arr_meta = arr.datatype().try_get_decimal_type_meta()?;

let scale_amount = <D::Primitive as NumCast>::from(
10.pow((arr_meta.scale - new_meta.scale).unsigned_abs() as u32),
)
.expect("to be in range");

let output = UnaryExecutor::execute2::<S, _, _>(
arr,
ArrayBuilder {
datatype: to,
buffer: PrimitiveBuffer::with_len(arr.logical_len()),
},
|v, buf| {
// Convert to decimal primitive.
let v = match <D::Primitive as NumCast>::from(v) {
Some(v) => v,
None => {
return;
}
};

if arr_meta.scale < new_meta.scale {
match v.checked_mul(&scale_amount) {
Some(v) => buf.put(&v),
None => (),
}
} else {
match v.checked_div(&scale_amount) {
Some(v) => buf.put(&v),
None => (),
}
}
},
)?;

Ok(output)
}

/// Casts an array to another array.
///
Expand Down
77 changes: 0 additions & 77 deletions crates/rayexec_execution/src/arrays/executor/scalar/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,83 +146,6 @@ impl BinaryExecutor {

Ok(())
}

pub fn execute2<'a, S1, S2, B, Op>(
array1: &'a Array,
array2: &'a Array,
builder: ArrayBuilder<B>,
mut op: Op,
) -> Result<Array>
where
Op: FnMut(S1::Type<'a>, S2::Type<'a>, &mut OutputBuffer<B>),
S1: PhysicalStorage,
S2: PhysicalStorage,
B: ArrayDataBuffer,
{
let len = validate_logical_len(&builder.buffer, array1)?;
let _ = validate_logical_len(&builder.buffer, array2)?;

let selection1 = array1.selection_vector();
let selection2 = array2.selection_vector();

let validity1 = array1.validity();
let validity2 = array2.validity();

let mut out_validity = None;

let mut output_buffer = OutputBuffer {
idx: 0,
buffer: builder.buffer,
};

if validity1.is_some() || validity2.is_some() {
let values1 = S1::get_storage(&array1.data2)?;
let values2 = S2::get_storage(&array2.data2)?;

let mut out_validity_builder = Bitmap::new_with_all_true(len);

for idx in 0..len {
let sel1 = unsafe { selection::get_unchecked(selection1, idx) };
let sel2 = unsafe { selection::get_unchecked(selection2, idx) };

if check_validity(sel1, validity1) && check_validity(sel2, validity2) {
let val1 = unsafe { values1.get_unchecked(sel1) };
let val2 = unsafe { values2.get_unchecked(sel2) };

output_buffer.idx = idx;
op(val1, val2, &mut output_buffer);
} else {
out_validity_builder.set_unchecked(idx, false);
}
}

out_validity = Some(out_validity_builder.into())
} else {
let values1 = S1::get_storage(&array1.data2)?;
let values2 = S2::get_storage(&array2.data2)?;

for idx in 0..len {
let sel1 = unsafe { selection::get_unchecked(selection1, idx) };
let sel2 = unsafe { selection::get_unchecked(selection2, idx) };

let val1 = unsafe { values1.get_unchecked(sel1) };
let val2 = unsafe { values2.get_unchecked(sel2) };

output_buffer.idx = idx;
op(val1, val2, &mut output_buffer);
}
}

let data = output_buffer.buffer.into_data();

Ok(Array {
datatype: builder.datatype,
selection2: None,
validity2: out_validity,
data2: data,
next: None,
})
}
}

#[cfg(test)]
Expand Down
91 changes: 0 additions & 91 deletions crates/rayexec_execution/src/arrays/executor/scalar/ternary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,97 +193,6 @@ impl TernaryExecutor {

Ok(())
}

pub fn execute2<'a, S1, S2, S3, B, Op>(
array1: &'a Array,
array2: &'a Array,
array3: &'a Array,
builder: ArrayBuilder<B>,
mut op: Op,
) -> Result<Array>
where
Op: FnMut(S1::Type<'a>, S2::Type<'a>, S3::Type<'a>, &mut OutputBuffer<B>),
S1: PhysicalStorage,
S2: PhysicalStorage,
S3: PhysicalStorage,
B: ArrayDataBuffer,
{
let len = validate_logical_len(&builder.buffer, array1)?;
let _ = validate_logical_len(&builder.buffer, array2)?;
let _ = validate_logical_len(&builder.buffer, array3)?;

let selection1 = array1.selection_vector();
let selection2 = array2.selection_vector();
let selection3 = array3.selection_vector();

let validity1 = array1.validity();
let validity2 = array2.validity();
let validity3 = array3.validity();

let mut out_validity = None;

let mut output_buffer = OutputBuffer {
idx: 0,
buffer: builder.buffer,
};

if validity1.is_some() || validity2.is_some() || validity3.is_some() {
let values1 = S1::get_storage(&array1.data2)?;
let values2 = S2::get_storage(&array2.data2)?;
let values3 = S3::get_storage(&array3.data2)?;

let mut out_validity_builder = Bitmap::new_with_all_true(len);

for idx in 0..len {
let sel1 = selection::get(selection1, idx);
let sel2 = selection::get(selection2, idx);
let sel3 = selection::get(selection3, idx);

if check_validity(sel1, validity1)
&& check_validity(sel2, validity2)
&& check_validity(sel3, validity3)
{
let val1 = unsafe { values1.get_unchecked(sel1) };
let val2 = unsafe { values2.get_unchecked(sel2) };
let val3 = unsafe { values3.get_unchecked(sel3) };

output_buffer.idx = idx;
op(val1, val2, val3, &mut output_buffer);
} else {
out_validity_builder.set_unchecked(idx, false);
}
}

out_validity = Some(out_validity_builder.into())
} else {
let values1 = S1::get_storage(&array1.data2)?;
let values2 = S2::get_storage(&array2.data2)?;
let values3 = S3::get_storage(&array3.data2)?;

for idx in 0..len {
let sel1 = selection::get(selection1, idx);
let sel2 = selection::get(selection2, idx);
let sel3 = selection::get(selection3, idx);

let val1 = unsafe { values1.get_unchecked(sel1) };
let val2 = unsafe { values2.get_unchecked(sel2) };
let val3 = unsafe { values3.get_unchecked(sel3) };

output_buffer.idx = idx;
op(val1, val2, val3, &mut output_buffer);
}
}

let data = output_buffer.buffer.into_data();

Ok(Array {
datatype: builder.datatype,
selection2: None,
validity2: out_validity,
data2: data,
next: None,
})
}
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl UnaryExecutor {

// TODO: Remove
/// Executes `op` on every non-null input.
#[deprecated]
pub fn execute2<'a, S, B, Op>(
array: &'a Array,
builder: ArrayBuilder<B>,
Expand Down
Loading

0 comments on commit 82080c8

Please sign in to comment.