kou commented on code in PR #46894:
URL: https://github.com/apache/arrow/pull/46894#discussion_r2165202227
##########
c_glib/test/test-array-statistics.rb:
##########
@@ -48,4 +48,12 @@ def setup
test("#null_count") do
assert_equal(1, @statistics.null_count)
end
+
+ test("#distinct_count") do
Review Comment:
We should use method name for `#XXX` test name.
##########
c_glib/test/test-array-statistics.rb:
##########
@@ -48,4 +48,12 @@ def setup
test("#null_count") do
assert_equal(1, @statistics.null_count)
end
+
+ test("#distinct_count") do
+ assert_equal(false, @statistics.has_distinct_count?)
Review Comment:
We should use power assert for predicate for easy to debug on error like we
did for `has_null_count?`:
https://github.com/apache/arrow/blob/f5e868e4694a11a1033170b2633dc5dd7160e857/c_glib/test/test-array-statistics.rb#L43-L45
##########
c_glib/arrow-glib/basic-array.cpp:
##########
@@ -476,6 +476,59 @@
garrow_array_statistics_get_null_count(GArrowArrayStatistics *statistics)
}
}
+/**
+ * garrow_array_statistics_has_distinct_count:
+ * @statistics: A #GArrowArrayStatistics.
+ *
+ * Returns: %TRUE if the distinct count is available, %FALSE otherwise.
+ *
+ * Since: 21.0.0
+ */
+gboolean
+garrow_array_statistics_has_distinct_count(GArrowArrayStatistics *statistics)
+{
+ auto priv = GARROW_ARRAY_STATISTICS_GET_PRIVATE(statistics);
+ return priv->statistics.distinct_count.has_value();
+}
+
+/**
+ * garrow_array_statistics_get_distinct_count:
+ * @statistics: A #GArrowArrayStatistics.
+ *
+ * Returns: 0 or larger value if @statistics has a valid distinct count value,
+ * -1 otherwise.
+ *
+ * Since: 21.0.0
+ */
+gint64
+garrow_array_statistics_get_distinct_count(GArrowArrayStatistics *statistics)
+{
+ auto priv = GARROW_ARRAY_STATISTICS_GET_PRIVATE(statistics);
+ const auto &distinct_count = priv->statistics.distinct_count;
+ if (distinct_count) {
+ return distinct_count.value();
+ } else {
+ return -1;
+ }
+}
+
+/**
+ * garrow_array_statistics_set_distinct_count:
+ * @statistics: A #GArrowArrayStatistics.
+ * @distinct_count: The distinct count value to set.
+ *
+ * Sets the distinct count for the array statistics.
+ *
+ * Since: 21.0.0
+ */
+void
+garrow_array_statistics_set_distinct_count(GArrowArrayStatistics *statistics,
+ gint64 distinct_count)
+{
+ auto priv = GARROW_ARRAY_STATISTICS_GET_PRIVATE(statistics);
+ priv->statistics.distinct_count = distinct_count;
+}
Review Comment:
Could you remove this?
We can't unset distinct count with this API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]