Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions benchmarks/compress-bench/src/gpu/vortex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use vortex::file::WriteOptionsSessionExt;
use vortex::layout::layouts::chunked::writer::ChunkedLayoutStrategy;
use vortex::layout::layouts::compressed::CompressingStrategy;
use vortex::layout::scan::split_by::SplitBy;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_bench::Format;
use vortex_bench::SESSION;
use vortex_bench::compress::Compressed;
Expand Down Expand Up @@ -303,11 +303,11 @@ fn verify_field(
batch_index: usize,
field_index: usize,
) -> Result<()> {
let expected = SESSION.arrow().execute_arrow(host.clone(), None, ctx)?;
let expected = host.clone().execute_arrow(None, ctx)?;
// Pin the Arrow target type so the two sides cannot land on different but equivalent
// encodings of the same logical values.
let target = Field::new("", expected.data_type().clone(), gpu.dtype().is_nullable());
let actual = SESSION.arrow().execute_arrow(gpu, Some(&target), ctx)?;
let actual = gpu.execute_arrow(Some(&target), ctx)?;

if expected.to_data() == actual.to_data() {
return Ok(());
Expand Down
17 changes: 10 additions & 7 deletions encodings/parquet-variant/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use vortex_array::vtable::child_to_validity;
use vortex_array::vtable::validity_to_child;
use vortex_arrow::ArrowExportOptions;
use vortex_arrow::ArrowSession;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_arrow::to_arrow_null_buffer;
use vortex_buffer::BitBuffer;
use vortex_error::VortexExpect;
Expand Down Expand Up @@ -449,17 +449,16 @@ pub trait ParquetVariantArrayExt:
options: &ArrowExportOptions,
ctx: &mut ExecutionCtx,
) -> VortexResult<ArrowVariantArray> {
let session = ctx.session().clone();
let arrow = session.arrow();
let exporter = arrow.exporter(options);
let metadata = self.metadata();
let len = metadata.len();
let nulls = to_arrow_null_buffer(self.parquet_variant_validity(), len, ctx)?;

let mut fields = Vec::with_capacity(3);
let mut arrays: Vec<ArrowArrayRef> = Vec::with_capacity(3);

let metadata_arrow = exporter.execute_arrow(metadata.clone(), None, ctx)?;
let metadata_arrow = metadata
.clone()
.execute_arrow_with_options(None, options, ctx)?;
fields.push(Arc::new(Field::new(
"metadata",
metadata_arrow.data_type().clone(),
Expand All @@ -468,7 +467,9 @@ pub trait ParquetVariantArrayExt:
arrays.push(metadata_arrow);

if let Some(value) = self.value() {
let value_arrow = exporter.execute_arrow(value.clone(), None, ctx)?;
let value_arrow = value
.clone()
.execute_arrow_with_options(None, options, ctx)?;
fields.push(Arc::new(Field::new(
"value",
value_arrow.data_type().clone(),
Expand All @@ -478,7 +479,9 @@ pub trait ParquetVariantArrayExt:
}

if let Some(typed_value) = self.typed_value() {
let tv_arrow = exporter.execute_arrow(typed_value.clone(), None, ctx)?;
let tv_arrow = typed_value
.clone()
.execute_arrow_with_options(None, options, ctx)?;
fields.push(Arc::new(Field::new(
"typed_value",
tv_arrow.data_type().clone(),
Expand Down
44 changes: 13 additions & 31 deletions encodings/parquet-variant/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use vortex_arrow::ArrowImport;
use vortex_arrow::ArrowImportVTable;
use vortex_arrow::ArrowSession;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_arrow::to_arrow_null_buffer;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
Expand Down Expand Up @@ -84,9 +85,6 @@ pub(crate) fn export_storage_to_target<T: ParquetVariantArrayExt>(
options: &ArrowExportOptions,
ctx: &mut ExecutionCtx,
) -> VortexResult<ArrowArrayRef> {
let session = ctx.session().clone();
let arrow = session.arrow();
let exporter = arrow.exporter(options);
let mut arrays = Vec::with_capacity(target_fields.len());

for field in target_fields {
Expand All @@ -104,7 +102,7 @@ pub(crate) fn export_storage_to_target<T: ParquetVariantArrayExt>(
);
};

arrays.push(exporter.execute_arrow(child, Some(field.as_ref()), ctx)?);
arrays.push(child.execute_arrow_with_options(Some(field.as_ref()), options, ctx)?);
}

let nulls = to_arrow_null_buffer(
Expand Down Expand Up @@ -471,6 +469,7 @@ mod tests {
use vortex_array::scalar::Scalar;
use vortex_array::validity::Validity;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_buffer::BitBuffer;
use vortex_buffer::buffer;
use vortex_error::VortexResult;
Expand All @@ -490,9 +489,7 @@ mod tests {
fn export_variant(session: &VortexSession, array: ArrayRef) -> VortexResult<ArrowVariantArray> {
let mut ctx = session.create_execution_ctx();
let field = session.arrow().to_arrow_field("variant", array.dtype())?;
let result = session
.arrow()
.execute_arrow(array, Some(&field), &mut ctx)?;
let result = array.execute_arrow(Some(&field), &mut ctx)?;

Ok(ArrowVariantArray::try_new(result.as_ref())?)
}
Expand Down Expand Up @@ -784,9 +781,7 @@ mod tests {
assert!(imported.as_opt::<ParquetVariant>().is_some());

let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(imported, Some(&field), &mut ctx)?;
let exported = imported.execute_arrow(Some(&field), &mut ctx)?;
let exported = exported.as_struct();

assert_struct_arrays_eq(exported, &storage);
Expand All @@ -805,9 +800,7 @@ mod tests {
let canonical = VariantArray::try_new(core_storage, None)?.into_array();

let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(canonical, Some(&field), &mut ctx)?;
let exported = canonical.execute_arrow(Some(&field), &mut ctx)?;
let exported = exported.as_struct();

assert_struct_arrays_eq(exported, &storage);
Expand Down Expand Up @@ -855,9 +848,7 @@ mod tests {
.into(),
);

let exported = session
.arrow()
.execute_arrow(canonical, Some(&field), &mut ctx)?;
let exported = canonical.execute_arrow(Some(&field), &mut ctx)?;
assert_eq!(exported.data_type(), field.data_type());

let actual = session.arrow().from_arrow_array(exported, &field)?;
Expand All @@ -883,9 +874,7 @@ mod tests {
let expected = array.clone();

let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(array.clone(), None, &mut ctx)?;
let exported = array.clone().execute_arrow(None, &mut ctx)?;

let field = Field::new(
"",
Expand Down Expand Up @@ -926,9 +915,7 @@ mod tests {
.into_array();

let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(expected.clone(), None, &mut ctx)?;
let exported = expected.clone().execute_arrow(None, &mut ctx)?;

assert_eq!(
exported.data_type(),
Expand Down Expand Up @@ -999,9 +986,7 @@ mod tests {
);

let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(expected.clone(), Some(&field), &mut ctx)?;
let exported = expected.clone().execute_arrow(Some(&field), &mut ctx)?;
assert_eq!(exported.data_type(), field.data_type());

let actual = session.arrow().from_arrow_array(exported, &field)?;
Expand Down Expand Up @@ -1044,9 +1029,8 @@ mod tests {
);

let mut ctx = session.create_execution_ctx();
let err = session
.arrow()
.execute_arrow(array, Some(&field), &mut ctx)
let err = array
.execute_arrow(Some(&field), &mut ctx)
.unwrap_err()
.to_string();
assert!(
Expand Down Expand Up @@ -1094,9 +1078,7 @@ mod tests {
.into(),
);
let mut ctx = session.create_execution_ctx();
let exported = session
.arrow()
.execute_arrow(array, Some(&field), &mut ctx)?;
let exported = array.execute_arrow(Some(&field), &mut ctx)?;
assert_eq!(
exported.data_type(),
field.data_type(),
Expand Down
3 changes: 2 additions & 1 deletion encodings/parquet-variant/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use vortex_array::scalar_fn::fns::variant_get::VariantPathElement;
use vortex_arrow::ArrowExportOptions;
use vortex_arrow::ArrowSession;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_error::VortexResult;
use vortex_error::vortex_ensure_eq;
use vortex_error::vortex_err;
Expand Down Expand Up @@ -154,7 +155,7 @@ fn json_strings_to_variant(
) -> VortexResult<ArrayRef> {
let nullable = parent.dtype().is_nullable();
let session = ctx.session().clone();
let arrow_strings = session.arrow().execute_arrow(strings, None, ctx)?;
let arrow_strings = strings.execute_arrow(None, ctx)?;
// Any row that fails to parse as JSON fails the whole conversion.
let arrow_variant = parquet_variant_compute::json_to_variant(&arrow_strings)?;

Expand Down
17 changes: 7 additions & 10 deletions encodings/pco/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
session
});

use vortex_arrow::ExecuteArrowExt;

use crate::Pco;
#[test]
fn test_compress_decompress() {
Expand Down Expand Up @@ -207,16 +209,11 @@ fn test_serde() -> VortexResult<()> {
&SESSION,
)?;
let data_type = SESSION.arrow().to_arrow_field("", data.dtype())?;
let pco_arrow = SESSION
.arrow()
.execute_arrow(pco, Some(&data_type), &mut ctx)?;
let decoded_arrow = SESSION
.arrow()
.execute_arrow(decoded, Some(&data_type), &mut ctx)?;
let expected_arrow =
SESSION
.arrow()
.execute_arrow(data.into_array(), Some(&data_type), &mut ctx)?;
let pco_arrow = pco.execute_arrow(Some(&data_type), &mut ctx)?;
let decoded_arrow = decoded.execute_arrow(Some(&data_type), &mut ctx)?;
let expected_arrow = data
.into_array()
.execute_arrow(Some(&data_type), &mut ctx)?;
assert_eq!(pco_arrow.as_ref(), expected_arrow.as_ref());
assert_eq!(decoded_arrow.as_ref(), expected_arrow.as_ref());
Ok(())
Expand Down
51 changes: 19 additions & 32 deletions encodings/sparse/src/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ mod test {
use vortex_array::scalar::Scalar;
use vortex_array::validity::Validity;
use vortex_arrow::ArrowSessionExt;
use vortex_arrow::ExecuteArrowExt;
use vortex_buffer::ByteBuffer;
use vortex_buffer::buffer;
use vortex_buffer::buffer_mut;
Expand Down Expand Up @@ -1136,33 +1137,23 @@ mod test {
let sparse_struct =
Sparse::try_new(indices, patch_values, len, fill_scalar, &mut ctx).unwrap();

let expected = SESSION
.arrow()
.execute_arrow(
DecimalArray::new(
buffer![100i128, 200, 123, 123, 123, 123, 123, 300, 4000, 123],
decimal_dtype,
// NB: patch indices: [0, 1, 7, 8]; patch validity: [Valid, Valid, Valid, Invalid]; ergo 0, 1, 7 are valid.
Validity::from_mask(Mask::from_excluded_indices(10, vec![8]), Nullable),
)
.into_array(),
None,
&mut ctx,
)
.unwrap();
let expected = DecimalArray::new(
buffer![100i128, 200, 123, 123, 123, 123, 123, 300, 4000, 123],
decimal_dtype,
// NB: patch indices: [0, 1, 7, 8]; patch validity: [Valid, Valid, Valid, Invalid]; ergo 0, 1, 7 are valid.
Validity::from_mask(Mask::from_excluded_indices(10, vec![8]), Nullable),
)
.into_array()
.execute_arrow(None, &mut ctx)
.unwrap();

let actual = SESSION
.arrow()
.execute_arrow(
sparse_struct
.as_array()
.clone()
.execute::<DecimalArray>(&mut ctx)
.unwrap()
.into_array(),
None,
&mut ctx,
)
let actual = sparse_struct
.as_array()
.clone()
.execute::<DecimalArray>(&mut ctx)
.unwrap()
.into_array()
.execute_arrow(None, &mut ctx)
.unwrap();

assert_eq!(expected.data_type(), actual.data_type());
Expand Down Expand Up @@ -1931,12 +1922,8 @@ mod test {

// Note that the preferred arrow list representation is `List` (not `ListView`).
let arrow_dtype = SESSION.arrow().to_arrow_field("", expected.dtype())?;
let actual = SESSION
.arrow()
.execute_arrow(actual, Some(&arrow_dtype), &mut ctx)?;
let expected = SESSION
.arrow()
.execute_arrow(expected, Some(&arrow_dtype), &mut ctx)?;
let actual = actual.execute_arrow(Some(&arrow_dtype), &mut ctx)?;
let expected = expected.execute_arrow(Some(&arrow_dtype), &mut ctx)?;

assert_eq!(actual.data_type(), expected.data_type());
Ok(())
Expand Down
Loading
Loading