From 9f6ccad349215b3ae1760cc6c27ae69c2cf20ff3 Mon Sep 17 00:00:00 2001 From: Raza Jafri Date: Thu, 14 Oct 2021 11:48:26 -0700 Subject: [PATCH 1/2] stddev Java bindings --- .../java/ai/rapids/cudf/RollingAggregation.java | 13 +++++++++++++ .../test/java/ai/rapids/cudf/ColumnVectorTest.java | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java index 07983f77aad..f42df9f159b 100644 --- a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java +++ b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java @@ -82,6 +82,19 @@ public static RollingAggregation max() { return new RollingAggregation(Aggregation.max()); } + /** + * Rolling Window Standard deviation with ddof = 1 + */ + public static RollingAggregation standardDeviation() { + return new RollingAggregation(Aggregation.standardDeviation()); + } + + /** + * Rolling Window Standard deviation with configurable ddof + */ + public static RollingAggregation standardDeviation(int ddof) { + return new RollingAggregation(Aggregation.standardDeviation(ddof)); + } /** * Count number of valid, a.k.a. non-null, elements. diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index d1af0d9a2f6..c767a98b342 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -3085,6 +3085,17 @@ void testWindowStatic() { ColumnVector result = v1.rollingWindow(RollingAggregation.lag(1, defaultOutput), options)) { assertColumnsAreEqual(expected, result); } + + try (ColumnVector expected = ColumnVector.fromBoxedDoubles(0.7071d, 1.5275d, 1.5275d, 1d, 1.4142); + ColumnVector result = v1.rollingWindow(RollingAggregation.standardDeviation(), options)) { + assertColumnsAreEqual(expected, result); + } + + try (ColumnVector expected = + ColumnVector.fromBoxedDoubles(Double.POSITIVE_INFINITY, 2.1602d, 2.1602d, 1.4142d, Double.POSITIVE_INFINITY); + ColumnVector result = v1.rollingWindow(RollingAggregation.standardDeviation(2), options)) { + assertColumnsAreEqual(expected, result); + } } } } From f018c6456d91013684a43ce0cab6670e72aa07a0 Mon Sep 17 00:00:00 2001 From: Raza Jafri Date: Tue, 26 Oct 2021 12:47:58 -0700 Subject: [PATCH 2/2] Addressed review comments --- java/src/main/java/ai/rapids/cudf/RollingAggregation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java index f42df9f159b..408c93ff0a1 100644 --- a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java +++ b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java @@ -83,14 +83,14 @@ public static RollingAggregation max() { } /** - * Rolling Window Standard deviation with ddof = 1 + * Rolling Window Standard Deviation with 1 as delta degrees of freedom(DDOF). */ public static RollingAggregation standardDeviation() { return new RollingAggregation(Aggregation.standardDeviation()); } /** - * Rolling Window Standard deviation with configurable ddof + * Rolling Window Standard Deviation with configurable delta degrees of freedom(DDOF). */ public static RollingAggregation standardDeviation(int ddof) { return new RollingAggregation(Aggregation.standardDeviation(ddof));