You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/04/22 14:49:22 UTC
arrow git commit: ARROW-877: [GLib] Add garrow_array_get_null_bitmap()
Repository: arrow
Updated Branches:
refs/heads/master 76dfd9878 -> 578b0ff15
ARROW-877: [GLib] Add garrow_array_get_null_bitmap()
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #582 from kou/glib-array-null-bitmap and squashes the following commits:
7f679f6 [Kouhei Sutou] [GLib] Add garrow_array_get_null_bitmap()
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/578b0ff1
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/578b0ff1
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/578b0ff1
Branch: refs/heads/master
Commit: 578b0ff15ebc2d3751c9b4ee87d9e31f1c7ae0b6
Parents: 76dfd98
Author: Kouhei Sutou <ko...@clear-code.com>
Authored: Sat Apr 22 10:49:17 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Sat Apr 22 10:49:17 2017 -0400
----------------------------------------------------------------------
c_glib/arrow-glib/array.cpp | 19 +++++++++++++++++++
c_glib/arrow-glib/array.h | 2 ++
c_glib/test/test-array.rb | 11 +++++++++++
3 files changed, 32 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/578b0ff1/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index dc1386b..1229f27 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -22,6 +22,7 @@
#endif
#include <arrow-glib/array.hpp>
+#include <arrow-glib/buffer.hpp>
#include <arrow-glib/data-type.hpp>
#include <arrow-glib/type.hpp>
@@ -243,6 +244,24 @@ garrow_array_get_n_nulls(GArrowArray *array)
}
/**
+ * garrow_array_get_null_bitmap:
+ * @array: A #GArrowArray.
+ *
+ * Returns: (transfer full) (nullable): The bitmap that indicates null
+ * value indexes for the array as #GArrowBuffer or %NULL when
+ * garrow_array_get_n_nulls() returns 0.
+ *
+ * Since: 0.3.0
+ */
+GArrowBuffer *
+garrow_array_get_null_bitmap(GArrowArray *array)
+{
+ auto arrow_array = garrow_array_get_raw(array);
+ auto arrow_null_bitmap = arrow_array->null_bitmap();
+ return garrow_buffer_new_raw(&arrow_null_bitmap);
+}
+
+/**
* garrow_array_get_value_data_type:
* @array: A #GArrowArray.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/578b0ff1/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index 7406456..f08ab84 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -19,6 +19,7 @@
#pragma once
+#include <arrow-glib/buffer.h>
#include <arrow-glib/data-type.h>
G_BEGIN_DECLS
@@ -62,6 +63,7 @@ gboolean garrow_array_is_null (GArrowArray *array,
gint64 garrow_array_get_length (GArrowArray *array);
gint64 garrow_array_get_offset (GArrowArray *array);
gint64 garrow_array_get_n_nulls (GArrowArray *array);
+GArrowBuffer *garrow_array_get_null_bitmap(GArrowArray *array);
GArrowDataType *garrow_array_get_value_data_type(GArrowArray *array);
GArrowType garrow_array_get_value_type(GArrowArray *array);
GArrowArray *garrow_array_slice (GArrowArray *array,
http://git-wip-us.apache.org/repos/asf/arrow/blob/578b0ff1/c_glib/test/test-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-array.rb b/c_glib/test/test-array.rb
index 06102eb..a2a2a1e 100644
--- a/c_glib/test/test-array.rb
+++ b/c_glib/test/test-array.rb
@@ -40,6 +40,17 @@ class TestArray < Test::Unit::TestCase
assert_equal(2, array.n_nulls)
end
+ def test_null_bitmap
+ builder = Arrow::BooleanArrayBuilder.new
+ builder.append_null
+ builder.append(true)
+ builder.append(false)
+ builder.append_null
+ builder.append(false)
+ array = builder.finish
+ assert_equal(0b10110, array.null_bitmap.data.to_s.unpack("c*")[0])
+ end
+
def test_value_data_type
builder = Arrow::BooleanArrayBuilder.new
array = builder.finish