1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Bridge definitions for libcudf reduction operations.
//!
//! Provides GPU-accelerated reduce, scan, and segmented reduce functions
//! for columns.
#[cxx::bridge(namespace = "cudf_shims")]
pub mod ffi {
unsafe extern "C++" {
include!("column_shim.h");
include!("scalar_shim.h");
include!("reduction_shim.h");
type OwnedColumn = crate::column::ffi::OwnedColumn;
type OwnedScalar = crate::scalar::ffi::OwnedScalar;
/// Reduce a column to a single scalar value.
/// agg_kind: 0=sum, 1=product, 2=min, 3=max, 4=sum_of_squares,
/// 5=mean, 6=variance, 7=std, 8=any, 9=all, 10=median
fn reduce(
col: &OwnedColumn,
agg_kind: i32,
output_type_id: i32,
) -> Result<UniquePtr<OwnedScalar>>;
/// Prefix scan (cumulative operation).
/// agg_kind: 0=sum, 1=product, 2=min, 3=max, 4=count_valid, 5=count_all
/// inclusive: true for inclusive scan, false for exclusive
fn scan(
col: &OwnedColumn,
agg_kind: i32,
inclusive: bool,
) -> Result<UniquePtr<OwnedColumn>>;
/// Segmented reduce: reduce within segments defined by offsets.
fn segmented_reduce(
col: &OwnedColumn,
offsets: &OwnedColumn,
agg_kind: i32,
output_type_id: i32,
include_nulls: bool,
) -> Result<UniquePtr<OwnedColumn>>;
// ── MinMax ────────────────────────────────────────────────
/// Opaque result holding min and max scalars.
type MinMaxResult;
/// Compute min and max of a column simultaneously.
fn minmax(col: &OwnedColumn) -> Result<UniquePtr<MinMaxResult>>;
/// Move min scalar out of MinMaxResult.
fn minmax_take_min(result: Pin<&mut MinMaxResult>) -> Result<UniquePtr<OwnedScalar>>;
/// Move max scalar out of MinMaxResult.
fn minmax_take_max(result: Pin<&mut MinMaxResult>) -> Result<UniquePtr<OwnedScalar>>;
/// Reduce with an initial value.
fn reduce_with_init(
col: &OwnedColumn,
agg_kind: i32,
output_type_id: i32,
init: &OwnedScalar,
) -> Result<UniquePtr<OwnedScalar>>;
/// Check if a reduction aggregation is valid for a given source data type.
fn is_valid_reduction_aggregation(source_type_id: i32, agg_kind: i32) -> Result<bool>;
/// Reduce: variance with custom ddof.
fn reduce_var_with_ddof(
col: &OwnedColumn,
ddof: i32,
output_type_id: i32,
) -> Result<UniquePtr<OwnedScalar>>;
/// Reduce: standard deviation with custom ddof.
fn reduce_std_with_ddof(
col: &OwnedColumn,
ddof: i32,
output_type_id: i32,
) -> Result<UniquePtr<OwnedScalar>>;
}
}