You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2021/09/05 19:09:38 UTC
[arrow] branch master updated: ARROW-13909: [GLib] Add
GArrowVarianceOptions
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 5d38723 ARROW-13909: [GLib] Add GArrowVarianceOptions
5d38723 is described below
commit 5d3872388f10f181206e145fdf3b7cae662088ae
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Mon Sep 6 04:08:06 2021 +0900
ARROW-13909: [GLib] Add GArrowVarianceOptions
Closes #11086 from kou/glib-variance-options
Authored-by: Sutou Kouhei <ko...@clear-code.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
c_glib/arrow-glib/compute.cpp | 164 +++++++++++++++++++++++++++++++++++++
c_glib/arrow-glib/compute.h | 16 ++++
c_glib/arrow-glib/compute.hpp | 4 +
c_glib/arrow-glib/input-stream.cpp | 4 +-
c_glib/arrow-glib/input-stream.h | 2 +-
5 files changed, 187 insertions(+), 3 deletions(-)
diff --git a/c_glib/arrow-glib/compute.cpp b/c_glib/arrow-glib/compute.cpp
index b083979..40d7002 100644
--- a/c_glib/arrow-glib/compute.cpp
+++ b/c_glib/arrow-glib/compute.cpp
@@ -168,6 +168,9 @@ G_BEGIN_DECLS
* #GArrowSetLookupOptions is a class to customize the `is_in` function
* and `index_in` function.
*
+ * #GArrowVarianceOptions is a class to customize the `stddev` function
+ * and `variance` function.
+ *
* There are many functions to compute data on an array.
*/
@@ -2571,6 +2574,161 @@ garrow_set_lookup_options_new(GArrowDatum *value_set)
}
+enum {
+ PROP_VARIANCE_OPTIONS_DDOF = 1,
+ PROP_VARIANCE_OPTIONS_SKIP_NULLS,
+ PROP_VARIANCE_OPTIONS_MIN_COUNT,
+};
+
+G_DEFINE_TYPE(GArrowVarianceOptions,
+ garrow_variance_options,
+ GARROW_TYPE_FUNCTION_OPTIONS)
+
+#define GARROW_VARIANCE_OPTIONS_GET_PRIVATE(object) \
+ static_cast<GArrowVarianceOptionsPrivate *>( \
+ garrow_variance_options_get_instance_private( \
+ GARROW_VARIANCE_OPTIONS(object)))
+
+static void
+garrow_variance_options_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto options =
+ garrow_variance_options_get_raw(GARROW_VARIANCE_OPTIONS(object));
+
+ switch (prop_id) {
+ case PROP_VARIANCE_OPTIONS_DDOF:
+ options->ddof = g_value_get_int(value);
+ break;
+ case PROP_VARIANCE_OPTIONS_SKIP_NULLS:
+ options->skip_nulls = g_value_get_boolean(value);
+ break;
+ case PROP_VARIANCE_OPTIONS_MIN_COUNT:
+ options->min_count = g_value_get_uint(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_variance_options_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto options =
+ garrow_variance_options_get_raw(GARROW_VARIANCE_OPTIONS(object));
+
+ switch (prop_id) {
+ case PROP_VARIANCE_OPTIONS_DDOF:
+ g_value_set_int(value, options->ddof);
+ break;
+ case PROP_VARIANCE_OPTIONS_SKIP_NULLS:
+ g_value_set_boolean(value, options->skip_nulls);
+ break;
+ case PROP_VARIANCE_OPTIONS_MIN_COUNT:
+ g_value_set_uint(value, options->min_count);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_variance_options_init(GArrowVarianceOptions *object)
+{
+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE(object);
+ priv->options = static_cast<arrow::compute::FunctionOptions *>(
+ new arrow::compute::VarianceOptions());
+}
+
+static void
+garrow_variance_options_class_init(GArrowVarianceOptionsClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->set_property = garrow_variance_options_set_property;
+ gobject_class->get_property = garrow_variance_options_get_property;
+
+
+ arrow::compute::VarianceOptions options;
+
+ GParamSpec *spec;
+ /**
+ * GArrowVarianceOptions:ddof:
+ *
+ * The Delta Degrees of Freedom (ddof) to be used.
+ *
+ * Since: 6.0.0
+ */
+ spec = g_param_spec_int("ddof",
+ "Delta Degrees of Freedom",
+ "The Delta Degrees of Freedom (ddof) to be used",
+ G_MININT,
+ G_MAXINT,
+ options.ddof,
+ static_cast<GParamFlags>(G_PARAM_READWRITE));
+ g_object_class_install_property(gobject_class,
+ PROP_VARIANCE_OPTIONS_DDOF,
+ spec);
+
+ /**
+ * GArrowVarianceOptions:skip-nulls:
+ *
+ * Whether NULLs are skipped or not.
+ *
+ * Since: 6.0.0
+ */
+ spec = g_param_spec_boolean("skip-nulls",
+ "Skip NULLs",
+ "Whether NULLs are skipped or not",
+ options.skip_nulls,
+ static_cast<GParamFlags>(G_PARAM_READWRITE));
+ g_object_class_install_property(gobject_class,
+ PROP_VARIANCE_OPTIONS_SKIP_NULLS,
+ spec);
+
+ /**
+ * GArrowVarianceOptions:min-count:
+ *
+ * If less than this many non-null values are observed, emit null.
+ *
+ * Since: 6.0.0
+ */
+ spec = g_param_spec_uint("min-count",
+ "Min count",
+ "If less than this many non-null values "
+ "are observed, emit null",
+ 0,
+ G_MAXUINT,
+ options.min_count,
+ static_cast<GParamFlags>(G_PARAM_READWRITE));
+ g_object_class_install_property(gobject_class,
+ PROP_VARIANCE_OPTIONS_MIN_COUNT,
+ spec);
+
+}
+
+/**
+ * garrow_variance_options_new:
+ *
+ * Returns: A newly created #GArrowVarianceOptions.
+ *
+ * Since: 6.0.0
+ */
+GArrowVarianceOptions *
+garrow_variance_options_new(void)
+{
+ return GARROW_VARIANCE_OPTIONS(
+ g_object_new(GARROW_TYPE_VARIANCE_OPTIONS, NULL));
+}
+
+
/**
* garrow_array_cast:
* @array: A #GArrowArray.
@@ -3918,3 +4076,9 @@ garrow_set_lookup_options_get_raw(GArrowSetLookupOptions *options)
}
+arrow::compute::VarianceOptions *
+garrow_variance_options_get_raw(GArrowVarianceOptions *options)
+{
+ return static_cast<arrow::compute::VarianceOptions *>(
+ garrow_function_options_get_raw(GARROW_FUNCTION_OPTIONS(options)));
+}
diff --git a/c_glib/arrow-glib/compute.h b/c_glib/arrow-glib/compute.h
index 239cc50..0c7424c 100644
--- a/c_glib/arrow-glib/compute.h
+++ b/c_glib/arrow-glib/compute.h
@@ -452,6 +452,22 @@ GArrowSetLookupOptions *
garrow_set_lookup_options_new(GArrowDatum *value_set);
+#define GARROW_TYPE_VARIANCE_OPTIONS (garrow_variance_options_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowVarianceOptions,
+ garrow_variance_options,
+ GARROW,
+ VARIANCE_OPTIONS,
+ GArrowFunctionOptions)
+struct _GArrowVarianceOptionsClass
+{
+ GArrowFunctionOptionsClass parent_class;
+};
+
+GARROW_AVAILABLE_IN_6_0
+GArrowVarianceOptions *
+garrow_variance_options_new(void);
+
+
GArrowArray *garrow_array_cast(GArrowArray *array,
GArrowDataType *target_data_type,
GArrowCastOptions *options,
diff --git a/c_glib/arrow-glib/compute.hpp b/c_glib/arrow-glib/compute.hpp
index c616f6c..4adea18 100644
--- a/c_glib/arrow-glib/compute.hpp
+++ b/c_glib/arrow-glib/compute.hpp
@@ -93,3 +93,7 @@ garrow_sort_options_get_raw(GArrowSortOptions *options);
arrow::compute::SetLookupOptions *
garrow_set_lookup_options_get_raw(GArrowSetLookupOptions *options);
+
+
+arrow::compute::VarianceOptions *
+garrow_variance_options_get_raw(GArrowVarianceOptions *options);
diff --git a/c_glib/arrow-glib/input-stream.cpp b/c_glib/arrow-glib/input-stream.cpp
index 57a13e6..37e4702 100644
--- a/c_glib/arrow-glib/input-stream.cpp
+++ b/c_glib/arrow-glib/input-stream.cpp
@@ -681,10 +681,10 @@ garrow_file_input_stream_new(const gchar *path,
* Since: 6.0.0
*/
GArrowFileInputStream *
-garrow_file_input_stream_new_file_descriptor(gint fd,
+garrow_file_input_stream_new_file_descriptor(gint file_descriptor,
GError **error)
{
- auto arrow_stream_result = arrow::io::ReadableFile::Open(fd);
+ auto arrow_stream_result = arrow::io::ReadableFile::Open(file_descriptor);
if (garrow::check(error,
arrow_stream_result,
"[file-input-stream][new-file-descriptor]")) {
diff --git a/c_glib/arrow-glib/input-stream.h b/c_glib/arrow-glib/input-stream.h
index 5ead66b..5f583c8 100644
--- a/c_glib/arrow-glib/input-stream.h
+++ b/c_glib/arrow-glib/input-stream.h
@@ -119,7 +119,7 @@ GArrowFileInputStream *
garrow_file_input_stream_new(const gchar *path,
GError **error);
GArrowFileInputStream *
-garrow_file_input_stream_new_file_descriptor(gint fd,
+garrow_file_input_stream_new_file_descriptor(gint file_descriptor,
GError **error);
gint
garrow_file_input_stream_get_file_descriptor(GArrowFileInputStream *stream);