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/05/07 14:34:47 UTC
arrow git commit: ARROW-963: [GLib] Add equal
Repository: arrow
Updated Branches:
refs/heads/master 20228a2be -> c48f6493f
ARROW-963: [GLib] Add equal
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #654 from kou/glib-equal and squashes the following commits:
63f071d [Kouhei Sutou] [GLib] Add equal
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/c48f6493
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/c48f6493
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/c48f6493
Branch: refs/heads/master
Commit: c48f6493fa7301260fce709eb16ce5382bc4673e
Parents: 20228a2
Author: Kouhei Sutou <ko...@clear-code.com>
Authored: Sun May 7 10:34:41 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Sun May 7 10:34:41 2017 -0400
----------------------------------------------------------------------
c_glib/arrow-glib/array.cpp | 66 ++++++++++++++++++++++++++++++++
c_glib/arrow-glib/array.h | 10 +++++
c_glib/arrow-glib/buffer.cpp | 39 +++++++++++++++++++
c_glib/arrow-glib/buffer.h | 5 +++
c_glib/arrow-glib/chunked-array.cpp | 20 ++++++++++
c_glib/arrow-glib/chunked-array.h | 3 ++
c_glib/arrow-glib/column.cpp | 18 +++++++++
c_glib/arrow-glib/column.h | 3 ++
c_glib/arrow-glib/data-type.cpp | 5 ++-
c_glib/arrow-glib/field.cpp | 5 ++-
c_glib/arrow-glib/record-batch.cpp | 20 ++++++++++
c_glib/arrow-glib/record-batch.h | 3 ++
c_glib/arrow-glib/schema.cpp | 18 +++++++++
c_glib/arrow-glib/schema.h | 2 +
c_glib/arrow-glib/table.cpp | 18 +++++++++
c_glib/arrow-glib/table.h | 3 ++
c_glib/arrow-glib/tensor.cpp | 18 +++++++++
c_glib/arrow-glib/tensor.h | 2 +
c_glib/test/test-array.rb | 23 +++++++++++
c_glib/test/test-buffer.rb | 13 +++++++
c_glib/test/test-chunked-array.rb | 13 +++++++
c_glib/test/test-column.rb | 13 +++++++
c_glib/test/test-field.rb | 5 +++
c_glib/test/test-record-batch.rb | 15 ++++++++
c_glib/test/test-schema.rb | 11 ++++++
c_glib/test/test-table.rb | 14 +++++++
c_glib/test/test-tensor.rb | 13 +++++++
27 files changed, 374 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index 3ca860d..8a78984 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -189,6 +189,72 @@ garrow_array_class_init(GArrowArrayClass *klass)
}
/**
+ * garrow_array_equal:
+ * @array: A #GArrowArray.
+ * @other_array: A #GArrowArray to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_array_equal(GArrowArray *array, GArrowArray *other_array)
+{
+ const auto arrow_array = garrow_array_get_raw(array);
+ const auto arrow_other_array = garrow_array_get_raw(other_array);
+ return arrow_array->Equals(arrow_other_array);
+}
+
+/**
+ * garrow_array_equal_approx:
+ * @array: A #GArrowArray.
+ * @other_array: A #GArrowArray to be compared.
+ *
+ * Returns: %TRUE if both of them have the approx same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_array_equal_approx(GArrowArray *array, GArrowArray *other_array)
+{
+ const auto arrow_array = garrow_array_get_raw(array);
+ const auto arrow_other_array = garrow_array_get_raw(other_array);
+ return arrow_array->ApproxEquals(arrow_other_array);
+}
+
+/**
+ * garrow_array_equal_range:
+ * @array: A #GArrowArray.
+ * @start_index: The start index of @array to be used.
+ * @other_array: A #GArrowArray to be compared.
+ * @other_start_index: The start index of @other_array to be used.
+ * @end_index: The end index of @array to be used. The end index of
+ * @other_array is "@other_start_index + (@end_index -
+ * @start_index)".
+ *
+ * Returns: %TRUE if both of them have the same data in the range,
+ * %FALSE otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_array_equal_range(GArrowArray *array,
+ gint64 start_index,
+ GArrowArray *other_array,
+ gint64 other_start_index,
+ gint64 end_index)
+{
+ const auto arrow_array = garrow_array_get_raw(array);
+ const auto arrow_other_array = garrow_array_get_raw(other_array);
+ return arrow_array->RangeEquals(*arrow_other_array,
+ start_index,
+ end_index,
+ other_start_index);
+}
+
+/**
* garrow_array_is_null:
* @array: A #GArrowArray.
* @i: The index of the target value.
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index 9bb502e..f750ee1 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -58,6 +58,16 @@ struct _GArrowArrayClass
GType garrow_array_get_type (void) G_GNUC_CONST;
+gboolean garrow_array_equal (GArrowArray *array,
+ GArrowArray *other_array);
+gboolean garrow_array_equal_approx(GArrowArray *array,
+ GArrowArray *other_array);
+gboolean garrow_array_equal_range (GArrowArray *array,
+ gint64 start_index,
+ GArrowArray *other_array,
+ gint64 other_start_index,
+ gint64 end_index);
+
gboolean garrow_array_is_null (GArrowArray *array,
gint64 i);
gint64 garrow_array_get_length (GArrowArray *array);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/buffer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/buffer.cpp b/c_glib/arrow-glib/buffer.cpp
index 4373ef1..0970128 100644
--- a/c_glib/arrow-glib/buffer.cpp
+++ b/c_glib/arrow-glib/buffer.cpp
@@ -145,6 +145,45 @@ garrow_buffer_new(const guint8 *data, gint64 size)
}
/**
+ * garrow_buffer_equal:
+ * @buffer: A #GArrowBuffer.
+ * @other_buffer: A #GArrowBuffer to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_buffer_equal(GArrowBuffer *buffer, GArrowBuffer *other_buffer)
+{
+ const auto arrow_buffer = garrow_buffer_get_raw(buffer);
+ const auto arrow_other_buffer = garrow_buffer_get_raw(other_buffer);
+ return arrow_buffer->Equals(*arrow_other_buffer);
+}
+
+/**
+ * garrow_buffer_equal_n_bytes:
+ * @buffer: A #GArrowBuffer.
+ * @other_buffer: A #GArrowBuffer to be compared.
+ * @n_bytes: The number of first bytes to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data in the first
+ * `n_bytes`, %FALSE otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_buffer_equal_n_bytes(GArrowBuffer *buffer,
+ GArrowBuffer *other_buffer,
+ gint64 n_bytes)
+{
+ const auto arrow_buffer = garrow_buffer_get_raw(buffer);
+ const auto arrow_other_buffer = garrow_buffer_get_raw(other_buffer);
+ return arrow_buffer->Equals(*arrow_other_buffer, n_bytes);
+}
+
+/**
* garrow_buffer_is_mutable:
* @buffer: A #GArrowBuffer.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/buffer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/buffer.h b/c_glib/arrow-glib/buffer.h
index 22a5e9b..b3f3a2c 100644
--- a/c_glib/arrow-glib/buffer.h
+++ b/c_glib/arrow-glib/buffer.h
@@ -59,6 +59,11 @@ GType garrow_buffer_get_type (void) G_GNUC_CONST;
GArrowBuffer *garrow_buffer_new (const guint8 *data,
gint64 size);
+gboolean garrow_buffer_equal (GArrowBuffer *buffer,
+ GArrowBuffer *other_buffer);
+gboolean garrow_buffer_equal_n_bytes(GArrowBuffer *buffer,
+ GArrowBuffer *other_buffer,
+ gint64 n_bytes);
gboolean garrow_buffer_is_mutable (GArrowBuffer *buffer);
gint64 garrow_buffer_get_capacity (GArrowBuffer *buffer);
GBytes *garrow_buffer_get_data (GArrowBuffer *buffer);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/chunked-array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/chunked-array.cpp b/c_glib/arrow-glib/chunked-array.cpp
index e732ece..62d666f 100644
--- a/c_glib/arrow-glib/chunked-array.cpp
+++ b/c_glib/arrow-glib/chunked-array.cpp
@@ -144,6 +144,26 @@ garrow_chunked_array_new(GList *chunks)
}
/**
+ * garrow_chunked_array_equal:
+ * @chunked_array: A #GArrowChunkedArray.
+ * @other_chunked_array: A #GArrowChunkedArray to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_chunked_array_equal(GArrowChunkedArray *chunked_array,
+ GArrowChunkedArray *other_chunked_array)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+ const auto arrow_other_chunked_array =
+ garrow_chunked_array_get_raw(other_chunked_array);
+ return arrow_chunked_array->Equals(arrow_other_chunked_array);
+}
+
+/**
* garrow_chunked_array_get_length:
* @chunked_array: A #GArrowChunkedArray.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/chunked-array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/chunked-array.h b/c_glib/arrow-glib/chunked-array.h
index 338930b..c5f986a 100644
--- a/c_glib/arrow-glib/chunked-array.h
+++ b/c_glib/arrow-glib/chunked-array.h
@@ -67,6 +67,9 @@ GType garrow_chunked_array_get_type(void) G_GNUC_CONST;
GArrowChunkedArray *garrow_chunked_array_new(GList *chunks);
+gboolean garrow_chunked_array_equal(GArrowChunkedArray *chunked_array,
+ GArrowChunkedArray *other_chunked_array);
+
guint64 garrow_chunked_array_get_length (GArrowChunkedArray *chunked_array);
guint64 garrow_chunked_array_get_n_nulls(GArrowChunkedArray *chunked_array);
guint garrow_chunked_array_get_n_chunks (GArrowChunkedArray *chunked_array);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/column.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/column.cpp b/c_glib/arrow-glib/column.cpp
index 94df640..a7222b1 100644
--- a/c_glib/arrow-glib/column.cpp
+++ b/c_glib/arrow-glib/column.cpp
@@ -161,6 +161,24 @@ garrow_column_new_chunked_array(GArrowField *field,
}
/**
+ * garrow_column_equal:
+ * @column: A #GArrowColumn.
+ * @other_column: A #GArrowColumn to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_column_equal(GArrowColumn *column, GArrowColumn *other_column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ const auto arrow_other_column = garrow_column_get_raw(other_column);
+ return arrow_column->Equals(arrow_other_column);
+}
+
+/**
* garrow_column_get_length:
* @column: A #GArrowColumn.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/column.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/column.h b/c_glib/arrow-glib/column.h
index fba3c26..b649c5f 100644
--- a/c_glib/arrow-glib/column.h
+++ b/c_glib/arrow-glib/column.h
@@ -72,6 +72,9 @@ GArrowColumn *garrow_column_new_array(GArrowField *field,
GArrowColumn *garrow_column_new_chunked_array(GArrowField *field,
GArrowChunkedArray *chunked_array);
+gboolean garrow_column_equal (GArrowColumn *column,
+ GArrowColumn *other_column);
+
guint64 garrow_column_get_length (GArrowColumn *column);
guint64 garrow_column_get_n_nulls (GArrowColumn *column);
GArrowField *garrow_column_get_field (GArrowColumn *column);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/data-type.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/data-type.cpp b/c_glib/arrow-glib/data-type.cpp
index c3c7fdb..9ce8c16 100644
--- a/c_glib/arrow-glib/data-type.cpp
+++ b/c_glib/arrow-glib/data-type.cpp
@@ -164,9 +164,10 @@ garrow_data_type_class_init(GArrowDataTypeClass *klass)
/**
* garrow_data_type_equal:
* @data_type: A #GArrowDataType.
- * @other_data_type: A #GArrowDataType.
+ * @other_data_type: A #GArrowDataType to be compared.
*
- * Returns: Whether they are equal or not.
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
*/
gboolean
garrow_data_type_equal(GArrowDataType *data_type,
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/field.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/field.cpp b/c_glib/arrow-glib/field.cpp
index 5fd0c4d..09c7ca3 100644
--- a/c_glib/arrow-glib/field.cpp
+++ b/c_glib/arrow-glib/field.cpp
@@ -204,9 +204,10 @@ garrow_field_is_nullable(GArrowField *field)
/**
* garrow_field_equal:
* @field: A #GArrowField.
- * @other_field: A #GArrowField.
+ * @other_field: A #GArrowField to be compared.
*
- * Returns: Whether they are equal or not.
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
*/
gboolean
garrow_field_equal(GArrowField *field,
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/record-batch.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/record-batch.cpp b/c_glib/arrow-glib/record-batch.cpp
index 8ac1791..3eed1a0 100644
--- a/c_glib/arrow-glib/record-batch.cpp
+++ b/c_glib/arrow-glib/record-batch.cpp
@@ -154,6 +154,26 @@ garrow_record_batch_new(GArrowSchema *schema,
}
/**
+ * garrow_record_batch_equal:
+ * @record_batch: A #GArrowRecordBatch.
+ * @other_record_batch: A #GArrowRecordBatch to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_record_batch_equal(GArrowRecordBatch *record_batch,
+ GArrowRecordBatch *other_record_batch)
+{
+ const auto arrow_record_batch = garrow_record_batch_get_raw(record_batch);
+ const auto arrow_other_record_batch =
+ garrow_record_batch_get_raw(other_record_batch);
+ return arrow_record_batch->Equals(*arrow_other_record_batch);
+}
+
+/**
* garrow_record_batch_get_schema:
* @record_batch: A #GArrowRecordBatch.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/record-batch.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/record-batch.h b/c_glib/arrow-glib/record-batch.h
index 92eee4d..61e8f3d 100644
--- a/c_glib/arrow-glib/record-batch.h
+++ b/c_glib/arrow-glib/record-batch.h
@@ -70,6 +70,9 @@ GArrowRecordBatch *garrow_record_batch_new(GArrowSchema *schema,
guint32 n_rows,
GList *columns);
+gboolean garrow_record_batch_equal(GArrowRecordBatch *record_batch,
+ GArrowRecordBatch *other_record_batch);
+
GArrowSchema *garrow_record_batch_get_schema (GArrowRecordBatch *record_batch);
GArrowArray *garrow_record_batch_get_column (GArrowRecordBatch *record_batch,
guint i);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/schema.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/schema.cpp b/c_glib/arrow-glib/schema.cpp
index 4d5ae5a..be3ea4b 100644
--- a/c_glib/arrow-glib/schema.cpp
+++ b/c_glib/arrow-glib/schema.cpp
@@ -143,6 +143,24 @@ garrow_schema_new(GList *fields)
}
/**
+ * garrow_schema_equal:
+ * @schema: A #GArrowSchema.
+ * @other_schema: A #GArrowSchema to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_schema_equal(GArrowSchema *schema, GArrowSchema *other_schema)
+{
+ const auto arrow_schema = garrow_schema_get_raw(schema);
+ const auto arrow_other_schema = garrow_schema_get_raw(other_schema);
+ return arrow_schema->Equals(*arrow_other_schema);
+}
+
+/**
* garrow_schema_get_field:
* @schema: A #GArrowSchema.
* @i: The index of the target field.
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/schema.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/schema.h b/c_glib/arrow-glib/schema.h
index 7615634..483d55e 100644
--- a/c_glib/arrow-glib/schema.h
+++ b/c_glib/arrow-glib/schema.h
@@ -67,6 +67,8 @@ GType garrow_schema_get_type (void) G_GNUC_CONST;
GArrowSchema *garrow_schema_new (GList *fields);
+gboolean garrow_schema_equal (GArrowSchema *schema,
+ GArrowSchema *other_schema);
GArrowField *garrow_schema_get_field (GArrowSchema *schema,
guint i);
GArrowField *garrow_schema_get_field_by_name(GArrowSchema *schema,
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/table.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/table.cpp b/c_glib/arrow-glib/table.cpp
index 2aba21b..779f2ef 100644
--- a/c_glib/arrow-glib/table.cpp
+++ b/c_glib/arrow-glib/table.cpp
@@ -149,6 +149,24 @@ garrow_table_new(GArrowSchema *schema,
}
/**
+ * garrow_table_equal:
+ * @table: A #GArrowTable.
+ * @other_table: A #GArrowTable to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_table_equal(GArrowTable *table, GArrowTable *other_table)
+{
+ const auto arrow_table = garrow_table_get_raw(table);
+ const auto arrow_other_table = garrow_table_get_raw(other_table);
+ return arrow_table->Equals(*arrow_other_table);
+}
+
+/**
* garrow_table_get_schema:
* @table: A #GArrowTable.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/table.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/table.h b/c_glib/arrow-glib/table.h
index 9ae0cce..9e21669 100644
--- a/c_glib/arrow-glib/table.h
+++ b/c_glib/arrow-glib/table.h
@@ -69,6 +69,9 @@ GType garrow_table_get_type (void) G_GNUC_CONST;
GArrowTable *garrow_table_new (GArrowSchema *schema,
GList *columns);
+gboolean garrow_table_equal (GArrowTable *table,
+ GArrowTable *other_table);
+
GArrowSchema *garrow_table_get_schema (GArrowTable *table);
GArrowColumn *garrow_table_get_column (GArrowTable *table,
guint i);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/tensor.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/tensor.cpp b/c_glib/arrow-glib/tensor.cpp
index 27af753..89e971c 100644
--- a/c_glib/arrow-glib/tensor.cpp
+++ b/c_glib/arrow-glib/tensor.cpp
@@ -171,6 +171,24 @@ garrow_tensor_new(GArrowDataType *data_type,
}
/**
+ * garrow_tensor_equal:
+ * @tensor: A #GArrowTensor.
+ * @other_tensor: A #GArrowTensor to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE
+ * otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean
+garrow_tensor_equal(GArrowTensor *tensor, GArrowTensor *other_tensor)
+{
+ const auto arrow_tensor = garrow_tensor_get_raw(tensor);
+ const auto arrow_other_tensor = garrow_tensor_get_raw(other_tensor);
+ return arrow_tensor->Equals(*arrow_other_tensor);
+}
+
+/**
* garrow_tensor_get_value_data_type:
* @tensor: A #GArrowTensor.
*
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/arrow-glib/tensor.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/tensor.h b/c_glib/arrow-glib/tensor.h
index 71c6b4e..6529282 100644
--- a/c_glib/arrow-glib/tensor.h
+++ b/c_glib/arrow-glib/tensor.h
@@ -66,6 +66,8 @@ GArrowTensor *garrow_tensor_new (GArrowDataType *data_type,
gsize n_strides,
gchar **dimention_names,
gsize n_dimention_names);
+gboolean garrow_tensor_equal (GArrowTensor *tensor,
+ GArrowTensor *other_tensor);
GArrowDataType *garrow_tensor_get_value_data_type(GArrowTensor *tensor);
GArrowType garrow_tensor_get_value_type (GArrowTensor *tensor);
GArrowBuffer *garrow_tensor_get_buffer (GArrowTensor *tensor);
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-array.rb b/c_glib/test/test-array.rb
index a2a2a1e..ca02fa2 100644
--- a/c_glib/test/test-array.rb
+++ b/c_glib/test/test-array.rb
@@ -16,6 +16,29 @@
# under the License.
class TestArray < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def test_equal
+ assert_equal(build_boolean_array([true, false]),
+ build_boolean_array([true, false]))
+ end
+
+ def test_equal_approx
+ array1 = build_double_array([1.1, 2.2 + Float::EPSILON * 10])
+ array2 = build_double_array([1.1, 2.2])
+ assert do
+ array1.equal_approx(array2)
+ end
+ end
+
+ def test_equal_range
+ array1 = build_int32_array([1, 2, 3, 4, 5])
+ array2 = build_int32_array([-2, -1, 0, 1, 2, 3, 4, 999])
+ assert do
+ array1.equal_range(1, array2, 4, 3)
+ end
+ end
+
def test_is_null
builder = Arrow::BooleanArrayBuilder.new
builder.append_null
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-buffer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-buffer.rb b/c_glib/test/test-buffer.rb
index 9f76a80..39ae631 100644
--- a/c_glib/test/test-buffer.rb
+++ b/c_glib/test/test-buffer.rb
@@ -23,6 +23,19 @@ class TestBuffer < Test::Unit::TestCase
@buffer = Arrow::Buffer.new(@data)
end
+ def test_equal
+ assert_equal(@buffer,
+ Arrow::Buffer.new(@data.dup))
+ end
+
+ def test_equal_n_bytes
+ buffer1 = Arrow::Buffer.new("Hello!")
+ buffer2 = Arrow::Buffer.new("Hello World!")
+ assert do
+ buffer1.equal_n_bytes(buffer2, 5)
+ end
+ end
+
def test_mutable?
assert do
not @buffer.mutable?
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-chunked-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-chunked-array.rb b/c_glib/test/test-chunked-array.rb
index 167d5d1..cde7a8b 100644
--- a/c_glib/test/test-chunked-array.rb
+++ b/c_glib/test/test-chunked-array.rb
@@ -18,6 +18,19 @@
class TestChunkedArray < Test::Unit::TestCase
include Helper::Buildable
+ def test_equal
+ chunks1 = [
+ build_boolean_array([true, false]),
+ build_boolean_array([true]),
+ ]
+ chunks2 = [
+ build_boolean_array([true]),
+ build_boolean_array([false, true]),
+ ]
+ assert_equal(Arrow::ChunkedArray.new(chunks1),
+ Arrow::ChunkedArray.new(chunks2))
+ end
+
def test_length
chunks = [
build_boolean_array([true, false]),
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-column.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-column.rb b/c_glib/test/test-column.rb
index ec75194..96e02b6 100644
--- a/c_glib/test/test-column.rb
+++ b/c_glib/test/test-column.rb
@@ -38,6 +38,19 @@ class TestColumn < Test::Unit::TestCase
end
end
+ def test_equal
+ field1 = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+ array1 = build_boolean_array([true, false])
+ field2 = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+ chunks = [
+ build_boolean_array([true]),
+ build_boolean_array([false]),
+ ]
+ array2 = Arrow::ChunkedArray.new(chunks)
+ assert_equal(Arrow::Column.new(field1, array1),
+ Arrow::Column.new(field2, array2))
+ end
+
def test_length
field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
array = build_boolean_array([true, false])
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-field.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-field.rb b/c_glib/test/test-field.rb
index a20802c..1b9c46e 100644
--- a/c_glib/test/test-field.rb
+++ b/c_glib/test/test-field.rb
@@ -16,6 +16,11 @@
# under the License.
class TestField < Test::Unit::TestCase
+ def test_equal
+ assert_equal(Arrow::Field.new("enabled", Arrow::BooleanDataType.new),
+ Arrow::Field.new("enabled", Arrow::BooleanDataType.new))
+ end
+
def test_name
field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
assert_equal("enabled", field.name)
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-record-batch.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-record-batch.rb b/c_glib/test/test-record-batch.rb
index 941ff35..048f6de 100644
--- a/c_glib/test/test-record-batch.rb
+++ b/c_glib/test/test-record-batch.rb
@@ -46,6 +46,21 @@ class TestTable < Test::Unit::TestCase
@record_batch = Arrow::RecordBatch.new(schema, 5, columns)
end
+ def test_equal
+ fields = [
+ Arrow::Field.new("visible", Arrow::BooleanDataType.new),
+ Arrow::Field.new("valid", Arrow::BooleanDataType.new),
+ ]
+ schema = Arrow::Schema.new(fields)
+ columns = [
+ build_boolean_array([true, false, true, false, true, false]),
+ build_boolean_array([false, true, false, true, false]),
+ ]
+ other_record_batch = Arrow::RecordBatch.new(schema, 5, columns)
+ assert_equal(@record_batch,
+ other_record_batch)
+ end
+
def test_schema
assert_equal(["visible", "valid"],
@record_batch.schema.fields.collect(&:name))
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-schema.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-schema.rb b/c_glib/test/test-schema.rb
index c9cbb75..4c09ecb 100644
--- a/c_glib/test/test-schema.rb
+++ b/c_glib/test/test-schema.rb
@@ -16,6 +16,17 @@
# under the License.
class TestSchema < Test::Unit::TestCase
+ def test_equal
+ fields1 = [
+ Arrow::Field.new("enabled", Arrow::BooleanDataType.new),
+ ]
+ fields2 = [
+ Arrow::Field.new("enabled", Arrow::BooleanDataType.new),
+ ]
+ assert_equal(Arrow::Schema.new(fields1),
+ Arrow::Schema.new(fields2))
+ end
+
def test_field
field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
schema = Arrow::Schema.new([field])
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-table.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-table.rb b/c_glib/test/test-table.rb
index da6871e..08dd348 100644
--- a/c_glib/test/test-table.rb
+++ b/c_glib/test/test-table.rb
@@ -66,6 +66,20 @@ class TestTable < Test::Unit::TestCase
@table = Arrow::Table.new(schema, columns)
end
+ def test_equal
+ fields = [
+ Arrow::Field.new("visible", Arrow::BooleanDataType.new),
+ Arrow::Field.new("valid", Arrow::BooleanDataType.new),
+ ]
+ schema = Arrow::Schema.new(fields)
+ columns = [
+ Arrow::Column.new(fields[0], build_boolean_array([true])),
+ Arrow::Column.new(fields[1], build_boolean_array([false])),
+ ]
+ other_table = Arrow::Table.new(schema, columns)
+ assert_equal(@table, other_table)
+ end
+
def test_schema
assert_equal(["visible", "valid"],
@table.schema.fields.collect(&:name))
http://git-wip-us.apache.org/repos/asf/arrow/blob/c48f6493/c_glib/test/test-tensor.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-tensor.rb b/c_glib/test/test-tensor.rb
index 225857b..780c9f1 100644
--- a/c_glib/test/test-tensor.rb
+++ b/c_glib/test/test-tensor.rb
@@ -40,6 +40,19 @@ class TestTensor < Test::Unit::TestCase
names)
end
+ def test_equal
+ data = Arrow::Buffer.new(@raw_data.pack("c*"))
+ strides = []
+ names = ["a", "b", "c"]
+ other_tensor = Arrow::Tensor.new(Arrow::Int8DataType.new,
+ data,
+ @shape,
+ strides,
+ names)
+ assert_equal(@tensor,
+ other_tensor)
+ end
+
def test_value_data_type
assert_equal(Arrow::Int8DataType, @tensor.value_data_type.class)
end