This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new c6b6bfb7bd GH-44758: [GLib] Add garrow_array_validate_full() (#45342)
c6b6bfb7bd is described below
commit c6b6bfb7bd13ba06d43e359bb59f7eb802152fea
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Sat Jan 25 06:26:24 2025 +0900
GH-44758: [GLib] Add garrow_array_validate_full() (#45342)
### Rationale for this change
[Array::ValidateFull](https://arrow.apache.org/docs/cpp/api/array.html#_CPPv4NK5arrow5Array12ValidateFullEv)
available in the C++ API.
But, GLib doesn't support that method yet.
### What changes are included in this PR?
This PR adds a validation method in the array class.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* GitHub Issue: #44758
Authored-by: Hiroyuki Sato <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
c_glib/arrow-glib/basic-array.cpp | 16 ++++++++++++++++
c_glib/arrow-glib/basic-array.h | 4 ++++
c_glib/test/test-array.rb | 26 ++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/c_glib/arrow-glib/basic-array.cpp
b/c_glib/arrow-glib/basic-array.cpp
index 3a7bdfa276..9e9753c4e0 100644
--- a/c_glib/arrow-glib/basic-array.cpp
+++ b/c_glib/arrow-glib/basic-array.cpp
@@ -1033,6 +1033,22 @@ garrow_array_validate(GArrowArray *array, GError **error)
return garrow::check(error, arrow_array->Validate(), "[array][validate]");
}
+/**
+ * garrow_array_validate_full:
+ * @array: A #GArrowArray.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE on error.
+ *
+ * Since: 20.0.0
+ */
+gboolean
+garrow_array_validate_full(GArrowArray *array, GError **error)
+{
+ const auto arrow_array = garrow_array_get_raw(array);
+ return garrow::check(error, arrow_array->ValidateFull(),
"[array][validate_full]");
+}
+
G_DEFINE_TYPE(GArrowNullArray, garrow_null_array, GARROW_TYPE_ARRAY)
static void
diff --git a/c_glib/arrow-glib/basic-array.h b/c_glib/arrow-glib/basic-array.h
index 0f068a0bee..bc597a8a93 100644
--- a/c_glib/arrow-glib/basic-array.h
+++ b/c_glib/arrow-glib/basic-array.h
@@ -130,6 +130,10 @@ GARROW_AVAILABLE_IN_20_0
gboolean
garrow_array_validate(GArrowArray *array, GError **error);
+GARROW_AVAILABLE_IN_20_0
+gboolean
+garrow_array_validate_full(GArrowArray *array, GError **error);
+
#define GARROW_TYPE_NULL_ARRAY (garrow_null_array_get_type())
GARROW_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE(
diff --git a/c_glib/test/test-array.rb b/c_glib/test/test-array.rb
index 107730a1aa..cd62d917cf 100644
--- a/c_glib/test/test-array.rb
+++ b/c_glib/test/test-array.rb
@@ -202,4 +202,30 @@ class TestArray < Test::Unit::TestCase
end
end
end
+
+ sub_test_case("#validate_full") do
+ def test_valid
+ array = build_int32_array([1, 2, 3, 4, 5])
+ assert do
+ array.validate_full
+ end
+ end
+
+ def test_invalid
+ message = "[array][validate_full]: Invalid: Invalid UTF8 sequence at
string index 0"
+
+ # U+3042 HIRAGANA LETTER A, U+3044 HIRAGANA LETTER I
+ data = "\u3042\u3044".b[0..-2]
+ value_offsets = Arrow::Buffer.new([0, data.size].pack("l*"))
+ array = Arrow::StringArray.new(1,
+ value_offsets,
+ Arrow::Buffer.new(data),
+ Arrow::Buffer.new([0b01].pack("C*")),
+ -1)
+
+ assert_raise(Arrow::Error::Invalid.new(message)) do
+ array.validate_full
+ end
+ end
+ end
end