Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Jun 25, 2024
1 parent 3214287 commit 62a186f
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 118 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vortex-array/src/array/bool/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::compute::compare::CompareFn;
use crate::{Array, ArrayTrait, IntoArray, IntoArrayVariant};

impl CompareFn for BoolArray {
// TODO(aduffy): replace these with Arrow compute kernels.
fn compare(&self, other: &Array, op: Operator) -> VortexResult<Array> {
let flattened = other.clone().into_bool()?;
let lhs = self.boolean_buffer();
Expand Down
3 changes: 3 additions & 0 deletions vortex-array/src/array/constant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::impl_encoding;
use crate::stats::Stat;
use crate::validity::{ArrayValidity, LogicalValidity};
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};

mod compute;
mod flatten;
mod stats;
Expand All @@ -25,6 +26,8 @@ impl ConstantArray {
Scalar: From<S>,
{
let scalar: Scalar = scalar.into();
// TODO(aduffy): add stats for bools, ideally there should be a
// StatsSet::constant(Scalar) constructor that does this for us, like StatsSet::nulls.
let stats = StatsSet::from(HashMap::from([
(Stat::Max, scalar.clone()),
(Stat::Min, scalar.clone()),
Expand Down
13 changes: 11 additions & 2 deletions vortex-array/src/array/struct_/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use vortex_dtype::{FieldName, FieldNames, Nullability, StructDType};
use vortex_error::{vortex_bail, vortex_err};
use vortex_error::vortex_bail;

use crate::stats::ArrayStatisticsCompute;
use crate::validity::{ArrayValidity, LogicalValidity, Validity, ValidityMetadata};
Expand All @@ -27,6 +27,15 @@ impl StructArray {
self.array().child(idx, dtype)
}

pub fn field_by_name(&self, name: &str) -> Option<Array> {
let field_idx = self
.names()
.iter()
.position(|field_name| field_name.as_ref() == name);

field_idx.and_then(|field_idx| self.field(field_idx))
}

pub fn names(&self) -> &FieldNames {
let DType::Struct(st, _) = self.dtype() else {
unreachable!()
Expand Down Expand Up @@ -126,7 +135,7 @@ impl StructArray {
for column_idx in projection {
children.push(
self.field(*column_idx)
.ok_or_else(|| vortex_err!(InvalidArgument: "column index out of bounds"))?,
.expect("column must not exceed bounds"),
);
names.push(self.names()[*column_idx].clone());
}
Expand Down
31 changes: 31 additions & 0 deletions vortex-array/src/stats/statsset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::HashMap;

use enum_iterator::all;
use itertools::Itertools;

use vortex_dtype::DType;
use vortex_error::VortexError;
use vortex_scalar::Scalar;
Expand All @@ -27,6 +28,36 @@ impl StatsSet {
}
}

// pub fn constant(len: usize, scalar: &Scalar) -> Self {
// let mut stats = HashMap::from([
// (Stat::Max, scalar.clone()),
// (Stat::Min, scalar.clone()),
// (Stat::IsConstant, true.into()),
// (Stat::IsSorted, true.into()),
// (Stat::RunCount, 1.into()),
// ]);
//
// match scalar.dtype() {
// DType::Bool(_) => {
// stats.insert(Stat::TrueCount, 0.into());
// }
// DType::Primitive(ptype, _) => {
// ptype.byte_width();
// stats.insert(
// Stat::BitWidthFreq,
// vec![0; ptype.byte_width() * 8 + 1].into(),
// );
// stats.insert(
// Stat::TrailingZeroFreq,
// vec![ptype.byte_width() * 8; ptype.byte_width() * 8 + 1].into(),
// );
// }
// _ => {}
// }
//
// Self::from(stats)
// }

/// Specialized constructor for the case where the StatsSet represents
/// an array consisting entirely of [null](vortex_dtype::DType::Null) values.
pub fn nulls(len: usize, dtype: &DType) -> Self {
Expand Down
9 changes: 7 additions & 2 deletions vortex-datafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ rust-version.workspace = true
[dependencies]
vortex-array = { path = "../vortex-array" }
vortex-dtype = { path = "../vortex-dtype" }
vortex-expr = { path = "../vortex-expr" }
vortex-error = { path = "../vortex-error" }
vortex-scalar = { path = "../vortex-scalar" }

arrow-array = { workspace = true }
arrow-schema = { workspace = true }
Expand All @@ -26,10 +28,13 @@ datafusion-execution = { workspace = true }
datafusion-physical-expr = { workspace = true }
datafusion-physical-plan = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
lazy_static = { workspace = true }
pin-project = { workspace = true }

[dev-dependencies]
tokio = { workspace = true, features = ["test-util"] }

[lints]
workspace = true
# TODO(aduffy): re-enable
#[lints]
#workspace = true
Loading

0 comments on commit 62a186f

Please sign in to comment.