use std::{ptr, sync::Arc};
use super::{owned::Column, view::ColumnView};
use crate::{
core::error::{self, Result},
runtime::execution_domain::ExecutionDomain,
};
pub(crate) fn copy_view_to_owned(cv: &ColumnView<'_>) -> Result<Column> {
let len = cv.len()?;
if len == 0 {
return Column::empty_with_dtype_in_domain(
cv.data_type()?,
Arc::clone(cv.execution_domain()),
"column::copy_view_to_owned",
);
}
let mut handle = ptr::null_mut();
let exec_options = cv.execution_domain().enter_execution()?;
error::check_status_in(
unsafe { cudf_sys::cudf_column_copy_from_view_ex(cv.raw_handle(), exec_options.options(), &mut handle) },
"column::copy_view_to_owned",
)?;
unsafe { Column::from_raw_with_domain(handle, Arc::clone(cv.execution_domain())) }
}
pub(crate) fn copy_view_in(
cv: &ColumnView<'_>,
output_domain: &Arc<ExecutionDomain>,
exec_options: &cudf_sys::cudf_exec_options_t,
) -> Result<Column> {
let mut handle = ptr::null_mut();
error::check_status_in(
unsafe { cudf_sys::cudf_column_copy_from_view_ex(cv.raw_handle(), exec_options, &mut handle) },
"column::copy_view_in",
)?;
unsafe { Column::from_raw_with_domain(handle, Arc::clone(output_domain)) }
}