Skip to content

Commit 328fa38

Browse files
committed
fix tests
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent ff2a2ce commit 328fa38

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,13 @@ mod tests {
198198
use arrow_array::ffi::FFI_ArrowSchema;
199199
use arrow_schema::DataType;
200200
use futures::executor::block_on;
201-
use vortex_array::Canonical;
201+
use vortex_array::Array;
202202
use vortex_array::IntoArray;
203203
use vortex_array::arrays::PrimitiveArray;
204204
use vortex_array::validity::Validity;
205205
use vortex_buffer::Buffer;
206206
use vortex_cuda::CudaSession;
207207
use vortex_cuda::arrow::CudaDeviceArrayExecute;
208-
use vortex_cuda::executor::CudaArrayExt;
209208
use vortex_session::VortexSession;
210209

211210
use super::*;
@@ -225,23 +224,24 @@ mod tests {
225224
}
226225

227226
#[test]
228-
fn test_primitive_array_to_cudf_tableview() -> Result<()> {
227+
fn test_primitive_array_to_cudf_columnview() -> Result<()> {
229228
// Create a PrimitiveArray with 100 i64 values
230229
let data: Vec<i64> = (0..100).collect();
231230
let expected_len = data.len();
232231
let primitive_array =
233232
PrimitiveArray::new(Buffer::from(data), Validity::NonNullable).into_array();
234233

235234
// Create CUDA execution context
236-
let mut cuda_ctx = match CudaSession::create_execution_ctx(&VortexSession::empty()).unwrap();
235+
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty()).unwrap();
237236

238-
// Export as ArrowDeviceArray using CudaDeviceArrayExecute
239-
let device_array = block_on(Canonical::execute(
240-
&primitive_array,
241-
primitive_array.clone(),
242-
&mut cuda_ctx,
243-
))
244-
.unwrap();
237+
// Get canonical form and export as ArrowDeviceArray
238+
let canonical = primitive_array.to_canonical().map_err(|e| CudfError {
239+
message: e.to_string(),
240+
})?;
241+
let device_array = block_on(canonical.execute(primitive_array.clone(), &mut cuda_ctx))
242+
.map_err(|e| CudfError {
243+
message: e.to_string(),
244+
})?;
245245

246246
// Synchronize the CUDA stream to ensure the data is ready
247247
cuda_ctx.synchronize_stream().map_err(|e| CudfError {
@@ -257,28 +257,28 @@ mod tests {
257257
// Create cudf context
258258
let cudf_ctx = CudfContext::new()?;
259259

260-
// Import into cudf tableview
261-
let tableview = unsafe {
262-
cudf_ctx.tableview_from_device(
260+
// Import into cudf columnview
261+
let columnview = unsafe {
262+
cudf_ctx.columnview_from_device(
263263
(&raw mut ffi_schema).cast::<ArrowSchema>(),
264264
(&raw const device_array).cast::<ArrowDeviceArray>(),
265265
)?
266266
};
267267

268268
// Verify row count
269-
let num_rows = tableview.num_rows()?;
270-
assert_eq!(num_rows, expected_len as i64, "Row count mismatch");
269+
let size = columnview.size()?;
270+
assert_eq!(size, expected_len as i64, "Size mismatch");
271271
println!(
272-
"Successfully imported PrimitiveArray into cudf tableview with {} rows",
273-
num_rows
272+
"Successfully imported PrimitiveArray into cudf columnview with {} rows",
273+
size
274274
);
275275

276-
// Verify column count (should be 1 for a primitive array)
277-
let num_columns = tableview.num_columns()?;
278-
assert_eq!(num_columns, 1, "Column count mismatch");
279-
println!("Tableview has {} column(s)", num_columns);
276+
// Verify valid count (should be same as length since NonNullable)
277+
let valid_count = columnview.count_valid()?;
278+
assert_eq!(valid_count, expected_len as i64, "Valid count mismatch");
279+
println!("Columnview has {} valid values", valid_count);
280280

281-
// Tableview and cudf_ctx will be deallocated automatically via Drop
281+
// Columnview and cudf_ctx will be deallocated automatically via Drop
282282

283283
Ok(())
284284
}

vortex-cuda/src/arrow/canonical.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@ impl CudaDeviceArrayExecute for Canonical {
4747
}
4848
}
4949

50-
async fn export_primitive(array: PrimitiveArray, ctx: &mut CudaExecutionCtx) -> VortexResult<ArrowArray> {
50+
async fn export_primitive(
51+
array: PrimitiveArray,
52+
ctx: &mut CudaExecutionCtx,
53+
) -> VortexResult<ArrowArray> {
5154
unsafe extern "C" fn release(array: *mut ArrowArray) {
5255
// SAFETY: this is only safe if the caller provides a valid pointer to an `ArrowArray`.
5356
drop(unsafe { Box::from_raw(array) });
5457
}
5558

5659
let len = array.len();
5760
let PrimitiveArrayParts {
58-
buffer,
59-
validity,
60-
..
61+
buffer, validity, ..
6162
} = array.into_parts();
6263

6364
let buffer = if buffer.is_on_device() {

vortex-cuda/src/arrow/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ impl ArrowArray {
100100
}
101101
}
102102

103-
#[expect(unused, reason = "cuda_stream and cuda_buffers need to have deferred drop")]
103+
#[expect(
104+
unused,
105+
reason = "cuda_stream and cuda_buffers need to have deferred drop"
106+
)]
104107
pub(crate) struct CudaPrivateData {
105108
/// Hold a reference to the CudaStream so that it stays alive even after CudaExecutionCtx
106109
/// has been dropped.

0 commit comments

Comments
 (0)