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;
1119use futures:: executor:: block_on;
1220use vortex:: array:: Array ;
1321use vortex:: array:: IntoArray ;
22+ use vortex:: array:: arrays:: DecimalArray ;
1423use vortex:: array:: arrays:: PrimitiveArray ;
1524use vortex:: array:: arrays:: StructArray ;
25+ use vortex:: array:: arrays:: VarBinViewArray ;
1626use vortex:: array:: session:: ArraySession ;
1727use vortex:: array:: validity:: Validity ;
28+ use vortex:: dtype:: DecimalDType ;
1829use vortex:: dtype:: FieldNames ;
1930use vortex:: expr:: session:: ExprSession ;
2031use 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) ]
4050pub 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