Skip to content

Commit 861e17c

Browse files
authored
Aduffy/more device arrays (#6308)
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent a06184d commit 861e17c

File tree

14 files changed

+280
-123
lines changed

14 files changed

+280
-123
lines changed

vortex-cuda/cudf-test/src/lib.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
//! This file is a simple C-compatible API that is called from the cudf-test-harness at CI time.
5+
//!
6+
//! The flow is
7+
//!
8+
//! * test harness calls `dlopen` in this library
9+
//! * invokes the `export_array` function to get back the device array
10+
//! * pass the arrays to `cudf`'s `from_arrow_device_column`
11+
//! * run some operations on the loaded column view
12+
//! * call `array->release()` to drop the data allocated from the Rust side
513
614
#![allow(clippy::unwrap_used, clippy::expect_used)]
715

@@ -11,10 +19,13 @@ use arrow_schema::ffi::FFI_ArrowSchema;
1119
use futures::executor::block_on;
1220
use vortex::array::Array;
1321
use vortex::array::IntoArray;
22+
use vortex::array::arrays::DecimalArray;
1423
use vortex::array::arrays::PrimitiveArray;
1524
use vortex::array::arrays::StructArray;
25+
use vortex::array::arrays::VarBinViewArray;
1626
use vortex::array::session::ArraySession;
1727
use vortex::array::validity::Validity;
28+
use vortex::dtype::DecimalDType;
1829
use vortex::dtype::FieldNames;
1930
use vortex::expr::session::ExprSession;
2031
use vortex::io::session::RuntimeSession;
@@ -35,7 +46,6 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
3546
.with::<CudaSession>()
3647
});
3748

38-
/// External array
3949
#[unsafe(no_mangle)]
4050
pub extern "C" fn export_array(
4151
schema_ptr: &mut FFI_ArrowSchema,
@@ -44,10 +54,17 @@ pub extern "C" fn export_array(
4454
let mut ctx = CudaSession::create_execution_ctx(&SESSION).unwrap();
4555

4656
let primitive = PrimitiveArray::from_iter(0u32..1024);
57+
let string =
58+
VarBinViewArray::from_iter_str((0..1024).map(|idx| format!("this is string {idx}")));
59+
let decimal = DecimalArray::from_iter(0i64..1024, DecimalDType::new(19, 2));
4760

4861
let array = StructArray::new(
49-
FieldNames::from_iter(["a"]),
50-
vec![primitive.into_array()],
62+
FieldNames::from_iter(["prims", "strings", "decimals"]),
63+
vec![
64+
primitive.into_array(),
65+
string.into_array(),
66+
decimal.into_array(),
67+
],
5168
1024,
5269
Validity::NonNullable,
5370
)

0 commit comments

Comments
 (0)