Skip to content

Commit

Permalink
Add binding for HISTOGRAM and MERGE_HISTOGRAM aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
ttnghia committed Sep 13, 2023
1 parent 1668c2c commit ee229a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
24 changes: 23 additions & 1 deletion java/src/main/java/ai/rapids/cudf/Aggregation.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ enum Kind {
DENSE_RANK(29),
PERCENT_RANK(30),
TDIGEST(31), // This can take a delta argument for accuracy level
MERGE_TDIGEST(32); // This can take a delta argument for accuracy level
MERGE_TDIGEST(32), // This can take a delta argument for accuracy level
HISTOGRAM(33),
MERGE_HISTOGRAM(34);

final int nativeId;

Expand Down Expand Up @@ -918,6 +920,26 @@ static TDigestAggregation mergeTDigest(int delta) {
return new TDigestAggregation(Kind.MERGE_TDIGEST, delta);
}

static final class HistogramAggregation extends NoParamAggregation {
private HistogramAggregation() {
super(Kind.HISTOGRAM);
}
}

static final class MergeHistogramAggregation extends NoParamAggregation {
private MergeHistogramAggregation() {
super(Kind.MERGE_HISTOGRAM);
}
}

static HistogramAggregation histogram() {
return new HistogramAggregation();
}

static MergeHistogramAggregation mergeHistogram() {
return new MergeHistogramAggregation();
}

/**
* Create one of the aggregations that only needs a kind, no other parameters. This does not
* work for all types and for code safety reasons each kind is added separately.
Expand Down
8 changes: 8 additions & 0 deletions java/src/main/java/ai/rapids/cudf/GroupByAggregation.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,12 @@ public static GroupByAggregation createTDigest(int delta) {
public static GroupByAggregation mergeTDigest(int delta) {
return new GroupByAggregation(Aggregation.mergeTDigest(delta));
}

public static GroupByAggregation histogram() {
return new GroupByAggregation(Aggregation.histogram());
}

public static GroupByAggregation mergeHistogram() {
return new GroupByAggregation(Aggregation.mergeHistogram());
}
}
5 changes: 5 additions & 0 deletions java/src/main/native/src/AggregationJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv
case 30: // ANSI SQL PERCENT_RANK
return cudf::make_rank_aggregation(cudf::rank_method::MIN, {}, cudf::null_policy::INCLUDE,
{}, cudf::rank_percentage::ONE_NORMALIZED);
case 33: // HISTOGRAM
return cudf::make_histogram_aggregation();
case 34: // MERGE_HISTOGRAM
return cudf::make_merge_histogram_aggregation();

default: throw std::logic_error("Unsupported No Parameter Aggregation Operation");
}
}();
Expand Down

0 comments on commit ee229a0

Please sign in to comment.