arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1315: [GLib] Add missing status check for arrow::ArrayBuilder::Finish()
Date Wed, 02 Aug 2017 22:27:22 GMT
Repository: arrow
Updated Branches:
  refs/heads/master ee928d223 -> 93b51a039


ARROW-1315: [GLib] Add missing status check for arrow::ArrayBuilder::Finish()

Author: Kouhei Sutou <kou@clear-code.com>

Closes #933 from kou/glib-add-missing-status-check-for-array-builder-finish and squashes the
following commits:

ba98ff54 [Kouhei Sutou] [GLib] Update Go examples to follow Finish() API change
b951b8f6 [Kouhei Sutou] [GLib] Add missing status check for arrow::ArrayBuilder::Finish()


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/93b51a03
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/93b51a03
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/93b51a03

Branch: refs/heads/master
Commit: 93b51a039e8901671e2fee4289e492eaadaa4def
Parents: ee928d2
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Wed Aug 2 18:27:18 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Wed Aug 2 18:27:18 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/array-builder.cpp | 14 +++++---
 c_glib/arrow-glib/array-builder.h   |  3 +-
 c_glib/example/build.c              |  8 ++++-
 c_glib/example/go/write-batch.go    | 60 ++++++++++++++++++++++++++------
 c_glib/example/go/write-stream.go   | 60 ++++++++++++++++++++++++++------
 5 files changed, 119 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/93b51a03/c_glib/arrow-glib/array-builder.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array-builder.cpp b/c_glib/arrow-glib/array-builder.cpp
index 23bc842..1ef4e77 100644
--- a/c_glib/arrow-glib/array-builder.cpp
+++ b/c_glib/arrow-glib/array-builder.cpp
@@ -220,16 +220,22 @@ garrow_array_builder_new(const std::shared_ptr<arrow::DataType>
&type,
 /**
  * garrow_array_builder_finish:
  * @builder: A #GArrowArrayBuilder.
+ * @error: (nullable): Return location for a #GError or %NULL.
  *
- * Returns: (transfer full): The built #GArrowArray.
+ * Returns: (transfer full): The built #GArrowArray on success,
+ *   %NULL on error.
  */
 GArrowArray *
-garrow_array_builder_finish(GArrowArrayBuilder *builder)
+garrow_array_builder_finish(GArrowArrayBuilder *builder, GError **error)
 {
   auto arrow_builder = garrow_array_builder_get_raw(builder);
   std::shared_ptr<arrow::Array> arrow_array;
-  arrow_builder->Finish(&arrow_array);
-  return garrow_array_new_raw(&arrow_array);
+  auto status = arrow_builder->Finish(&arrow_array);
+  if (garrow_error_check(error, status, "[array-builder][finish]")) {
+    return garrow_array_new_raw(&arrow_array);
+  } else {
+    return NULL;
+  }
 }
 
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/93b51a03/c_glib/arrow-glib/array-builder.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array-builder.h b/c_glib/arrow-glib/array-builder.h
index 97cea63..613a5ba 100644
--- a/c_glib/arrow-glib/array-builder.h
+++ b/c_glib/arrow-glib/array-builder.h
@@ -65,7 +65,8 @@ struct _GArrowArrayBuilderClass
 
 GType               garrow_array_builder_get_type (void) G_GNUC_CONST;
 
-GArrowArray        *garrow_array_builder_finish   (GArrowArrayBuilder *builder);
+GArrowArray        *garrow_array_builder_finish   (GArrowArrayBuilder *builder,
+                                                   GError **error);
 
 
 #define GARROW_TYPE_BOOLEAN_ARRAY_BUILDER       \

http://git-wip-us.apache.org/repos/asf/arrow/blob/93b51a03/c_glib/example/build.c
----------------------------------------------------------------------
diff --git a/c_glib/example/build.c b/c_glib/example/build.c
index 2722458..8c6cf74 100644
--- a/c_glib/example/build.c
+++ b/c_glib/example/build.c
@@ -47,7 +47,13 @@ main(int argc, char **argv)
       g_object_unref(builder);
       return EXIT_FAILURE;
     }
-    array = garrow_array_builder_finish(GARROW_ARRAY_BUILDER(builder));
+    array = garrow_array_builder_finish(GARROW_ARRAY_BUILDER(builder), &error);
+    if (!array) {
+      g_print("failed to finish: %s\n", error->message);
+      g_error_free(error);
+      g_object_unref(builder);
+      return EXIT_FAILURE;
+    }
     g_object_unref(builder);
   }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/93b51a03/c_glib/example/go/write-batch.go
----------------------------------------------------------------------
diff --git a/c_glib/example/go/write-batch.go b/c_glib/example/go/write-batch.go
index cda09a9..9dbc3c0 100644
--- a/c_glib/example/go/write-batch.go
+++ b/c_glib/example/go/write-batch.go
@@ -29,7 +29,11 @@ func BuildUInt8Array() *arrow.Array {
 	for _, value := range []uint8{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt16Array() *arrow.Array {
@@ -37,7 +41,11 @@ func BuildUInt16Array() *arrow.Array {
 	for _, value := range []uint16{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt32Array() *arrow.Array {
@@ -45,7 +53,11 @@ func BuildUInt32Array() *arrow.Array {
 	for _, value := range []uint32{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt64Array() *arrow.Array {
@@ -53,7 +65,11 @@ func BuildUInt64Array() *arrow.Array {
 	for _, value := range []uint64{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt8Array() *arrow.Array {
@@ -61,7 +77,11 @@ func BuildInt8Array() *arrow.Array {
 	for _, value := range []int8{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt16Array() *arrow.Array {
@@ -69,7 +89,11 @@ func BuildInt16Array() *arrow.Array {
 	for _, value := range []int16{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt32Array() *arrow.Array {
@@ -77,7 +101,11 @@ func BuildInt32Array() *arrow.Array {
 	for _, value := range []int32{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt64Array() *arrow.Array {
@@ -85,7 +113,11 @@ func BuildInt64Array() *arrow.Array {
 	for _, value := range []int64{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildFloatArray() *arrow.Array {
@@ -93,7 +125,11 @@ func BuildFloatArray() *arrow.Array {
 	for _, value := range []float32{1.1, -2.2, 4.4, -8.8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildDoubleArray() *arrow.Array {
@@ -101,7 +137,11 @@ func BuildDoubleArray() *arrow.Array {
 	for _, value := range []float64{1.1, -2.2, 4.4, -8.8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func main() {

http://git-wip-us.apache.org/repos/asf/arrow/blob/93b51a03/c_glib/example/go/write-stream.go
----------------------------------------------------------------------
diff --git a/c_glib/example/go/write-stream.go b/c_glib/example/go/write-stream.go
index 20cb03e..244741e 100644
--- a/c_glib/example/go/write-stream.go
+++ b/c_glib/example/go/write-stream.go
@@ -29,7 +29,11 @@ func BuildUInt8Array() *arrow.Array {
 	for _, value := range []uint8{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt16Array() *arrow.Array {
@@ -37,7 +41,11 @@ func BuildUInt16Array() *arrow.Array {
 	for _, value := range []uint16{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt32Array() *arrow.Array {
@@ -45,7 +53,11 @@ func BuildUInt32Array() *arrow.Array {
 	for _, value := range []uint32{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildUInt64Array() *arrow.Array {
@@ -53,7 +65,11 @@ func BuildUInt64Array() *arrow.Array {
 	for _, value := range []uint64{1, 2, 4, 8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt8Array() *arrow.Array {
@@ -61,7 +77,11 @@ func BuildInt8Array() *arrow.Array {
 	for _, value := range []int8{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt16Array() *arrow.Array {
@@ -69,7 +89,11 @@ func BuildInt16Array() *arrow.Array {
 	for _, value := range []int16{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt32Array() *arrow.Array {
@@ -77,7 +101,11 @@ func BuildInt32Array() *arrow.Array {
 	for _, value := range []int32{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildInt64Array() *arrow.Array {
@@ -85,7 +113,11 @@ func BuildInt64Array() *arrow.Array {
 	for _, value := range []int64{1, -2, 4, -8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildFloatArray() *arrow.Array {
@@ -93,7 +125,11 @@ func BuildFloatArray() *arrow.Array {
 	for _, value := range []float32{1.1, -2.2, 4.4, -8.8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func BuildDoubleArray() *arrow.Array {
@@ -101,7 +137,11 @@ func BuildDoubleArray() *arrow.Array {
 	for _, value := range []float64{1.1, -2.2, 4.4, -8.8} {
 		builder.Append(value)
 	}
-	return builder.Finish()
+	array, err := builder.Finish()
+		if err != nil {
+		log.Fatalf("Failed to build array: %v", err)
+	}
+	return array
 }
 
 func main() {


Mime
View raw message