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/26 14:30:31 UTC
arrow git commit: ARROW-904: [GLib] Simplify error check codes
Repository: arrow
Updated Branches:
refs/heads/master 7d433dc27 -> 3ad9d09f3
ARROW-904: [GLib] Simplify error check codes
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #604 from kou/glib-simplify-error-check and squashes the following commits:
1cf6b76 [Kouhei Sutou] [GLib] Simplify error check codes
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/3ad9d09f
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/3ad9d09f
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/3ad9d09f
Branch: refs/heads/master
Commit: 3ad9d09f39ead51266299ec4bbb703724b8ac69d
Parents: 7d433dc
Author: Kouhei Sutou <ko...@clear-code.com>
Authored: Wed Apr 26 10:30:26 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Wed Apr 26 10:30:26 2017 -0400
----------------------------------------------------------------------
c_glib/arrow-glib/array-builder.cpp | 210 +++++---------------------
c_glib/arrow-glib/buffer.cpp | 17 +--
c_glib/arrow-glib/error.cpp | 25 +--
c_glib/arrow-glib/error.hpp | 6 +-
c_glib/arrow-glib/file-output-stream.cpp | 2 +-
c_glib/arrow-glib/file-reader.cpp | 8 +-
c_glib/arrow-glib/file-writer.cpp | 19 +--
c_glib/arrow-glib/file.cpp | 10 +-
c_glib/arrow-glib/memory-mapped-file.cpp | 2 +-
c_glib/arrow-glib/random-access-file.cpp | 10 +-
c_glib/arrow-glib/readable.cpp | 7 +-
c_glib/arrow-glib/stream-reader.cpp | 8 +-
c_glib/arrow-glib/stream-writer.cpp | 19 +--
c_glib/arrow-glib/table.cpp | 6 +-
c_glib/arrow-glib/writeable-file.cpp | 7 +-
c_glib/arrow-glib/writeable.cpp | 14 +-
16 files changed, 90 insertions(+), 280 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/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 97d43e1..30158b0 100644
--- a/c_glib/arrow-glib/array-builder.cpp
+++ b/c_glib/arrow-glib/array-builder.cpp
@@ -237,12 +237,7 @@ garrow_boolean_array_builder_append(GArrowBooleanArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(static_cast<bool>(value));
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[boolean-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[boolean-array-builder][append]");
}
/**
@@ -261,12 +256,9 @@ garrow_boolean_array_builder_append_null(GArrowBooleanArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[boolean-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[boolean-array-builder][append-null]");
}
@@ -318,12 +310,7 @@ garrow_int8_array_builder_append(GArrowInt8ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int8-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int8-array-builder][append]");
}
/**
@@ -342,12 +329,7 @@ garrow_int8_array_builder_append_null(GArrowInt8ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int8-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int8-array-builder][append-null]");
}
@@ -399,12 +381,7 @@ garrow_uint8_array_builder_append(GArrowUInt8ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint8-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[uint8-array-builder][append]");
}
/**
@@ -423,12 +400,7 @@ garrow_uint8_array_builder_append_null(GArrowUInt8ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint8-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[uint8-array-builder][append-null]");
}
@@ -480,12 +452,7 @@ garrow_int16_array_builder_append(GArrowInt16ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int16-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int16-array-builder][append]");
}
/**
@@ -504,12 +471,7 @@ garrow_int16_array_builder_append_null(GArrowInt16ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int16-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int16-array-builder][append-null]");
}
@@ -561,12 +523,7 @@ garrow_uint16_array_builder_append(GArrowUInt16ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint16-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[uint16-array-builder][append]");
}
/**
@@ -585,12 +542,9 @@ garrow_uint16_array_builder_append_null(GArrowUInt16ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint16-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[uint16-array-builder][append-null]");
}
@@ -642,12 +596,7 @@ garrow_int32_array_builder_append(GArrowInt32ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int32-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int32-array-builder][append]");
}
/**
@@ -666,12 +615,7 @@ garrow_int32_array_builder_append_null(GArrowInt32ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int32-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int32-array-builder][append-null]");
}
@@ -723,12 +667,7 @@ garrow_uint32_array_builder_append(GArrowUInt32ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint32-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[uint32-array-builder][append]");
}
/**
@@ -747,12 +686,9 @@ garrow_uint32_array_builder_append_null(GArrowUInt32ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint32-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[uint32-array-builder][append-null]");
}
@@ -804,12 +740,7 @@ garrow_int64_array_builder_append(GArrowInt64ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int64-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int64-array-builder][append]");
}
/**
@@ -828,12 +759,7 @@ garrow_int64_array_builder_append_null(GArrowInt64ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[int64-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[int64-array-builder][append-null]");
}
@@ -885,12 +811,7 @@ garrow_uint64_array_builder_append(GArrowUInt64ArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[uint64-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[uint64-array-builder][append]");
}
/**
@@ -912,7 +833,7 @@ garrow_uint64_array_builder_append_null(GArrowUInt64ArrayBuilder *builder,
if (status.ok()) {
return TRUE;
} else {
- garrow_error_set(error, status, "[uint64-array-builder][append-null]");
+ garrow_error_check(error, status, "[uint64-array-builder][append-null]");
return FALSE;
}
}
@@ -966,12 +887,7 @@ garrow_float_array_builder_append(GArrowFloatArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[float-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[float-array-builder][append]");
}
/**
@@ -990,12 +906,7 @@ garrow_float_array_builder_append_null(GArrowFloatArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[float-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[float-array-builder][append-null]");
}
@@ -1047,12 +958,7 @@ garrow_double_array_builder_append(GArrowDoubleArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[double-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[double-array-builder][append]");
}
/**
@@ -1071,12 +977,9 @@ garrow_double_array_builder_append_null(GArrowDoubleArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[double-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[double-array-builder][append-null]");
}
@@ -1130,12 +1033,7 @@ garrow_binary_array_builder_append(GArrowBinaryArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append(value, length);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[binary-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[binary-array-builder][append]");
}
/**
@@ -1154,12 +1052,9 @@ garrow_binary_array_builder_append_null(GArrowBinaryArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[binary-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[binary-array-builder][append-null]");
}
@@ -1212,12 +1107,7 @@ garrow_string_array_builder_append(GArrowStringArrayBuilder *builder,
auto status = arrow_builder->Append(value,
static_cast<gint32>(strlen(value)));
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[string-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[string-array-builder][append]");
}
@@ -1305,12 +1195,7 @@ garrow_list_array_builder_append(GArrowListArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[list-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[list-array-builder][append]");
}
/**
@@ -1331,12 +1216,7 @@ garrow_list_array_builder_append_null(GArrowListArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[list-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[list-array-builder][append-null]");
}
/**
@@ -1427,12 +1307,7 @@ garrow_struct_array_builder_append(GArrowStructArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->Append();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[struct-array-builder][append]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[struct-array-builder][append]");
}
/**
@@ -1453,12 +1328,9 @@ garrow_struct_array_builder_append_null(GArrowStructArrayBuilder *builder,
garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
auto status = arrow_builder->AppendNull();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[struct-array-builder][append-null]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[struct-array-builder][append-null]");
}
/**
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/buffer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/buffer.cpp b/c_glib/arrow-glib/buffer.cpp
index 5c28daf..4373ef1 100644
--- a/c_glib/arrow-glib/buffer.cpp
+++ b/c_glib/arrow-glib/buffer.cpp
@@ -272,10 +272,9 @@ garrow_buffer_copy(GArrowBuffer *buffer,
auto arrow_buffer = garrow_buffer_get_raw(buffer);
std::shared_ptr<arrow::Buffer> arrow_copied_buffer;
auto status = arrow_buffer->Copy(start, size, &arrow_copied_buffer);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[buffer][copy]")) {
return garrow_buffer_new_raw(&arrow_copied_buffer);
} else {
- garrow_error_set(error, status, "[buffer][copy]");
return NULL;
}
}
@@ -396,12 +395,7 @@ garrow_resizable_buffer_resize(GArrowResizableBuffer *buffer,
auto arrow_resizable_buffer =
std::static_pointer_cast<arrow::ResizableBuffer>(arrow_buffer);
auto status = arrow_resizable_buffer->Resize(new_size);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[resizable-buffer][resize]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[resizable-buffer][resize]");
}
/**
@@ -423,12 +417,7 @@ garrow_resizable_buffer_reserve(GArrowResizableBuffer *buffer,
auto arrow_resizable_buffer =
std::static_pointer_cast<arrow::ResizableBuffer>(arrow_buffer);
auto status = arrow_resizable_buffer->Reserve(new_capacity);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[resizable-buffer][capacity]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[resizable-buffer][capacity]");
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/error.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/error.cpp b/c_glib/arrow-glib/error.cpp
index efbc6ae..e5d2ad6 100644
--- a/c_glib/arrow-glib/error.cpp
+++ b/c_glib/arrow-glib/error.cpp
@@ -63,19 +63,20 @@ garrow_error_code(const arrow::Status &status)
G_END_DECLS
-void
-garrow_error_set(GError **error,
- const arrow::Status &status,
- const char *context)
+gboolean
+garrow_error_check(GError **error,
+ const arrow::Status &status,
+ const char *context)
{
if (status.ok()) {
- return;
+ return TRUE;
+ } else {
+ g_set_error(error,
+ GARROW_ERROR,
+ garrow_error_code(status),
+ "%s: %s",
+ context,
+ status.ToString().c_str());
+ return FALSE;
}
-
- g_set_error(error,
- GARROW_ERROR,
- garrow_error_code(status),
- "%s: %s",
- context,
- status.ToString().c_str());
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/error.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/error.hpp b/c_glib/arrow-glib/error.hpp
index 357d293..dad27bd 100644
--- a/c_glib/arrow-glib/error.hpp
+++ b/c_glib/arrow-glib/error.hpp
@@ -23,6 +23,6 @@
#include <arrow-glib/error.h>
-void garrow_error_set(GError **error,
- const arrow::Status &status,
- const char *context);
+gboolean garrow_error_check(GError **error,
+ const arrow::Status &status,
+ const char *context);
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/file-output-stream.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-output-stream.cpp b/c_glib/arrow-glib/file-output-stream.cpp
index b6ca42a..e1e1e27 100644
--- a/c_glib/arrow-glib/file-output-stream.cpp
+++ b/c_glib/arrow-glib/file-output-stream.cpp
@@ -204,7 +204,7 @@ garrow_file_output_stream_open(const gchar *path,
std::string context("[io][file-output-stream][open]: <");
context += path;
context += ">";
- garrow_error_set(error, status, context.c_str());
+ garrow_error_check(error, status, context.c_str());
return NULL;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/file-reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-reader.cpp b/c_glib/arrow-glib/file-reader.cpp
index c2aeabe..b952b52 100644
--- a/c_glib/arrow-glib/file-reader.cpp
+++ b/c_glib/arrow-glib/file-reader.cpp
@@ -146,10 +146,9 @@ garrow_file_reader_open(GArrowRandomAccessFile *file,
auto status =
arrow::ipc::FileReader::Open(garrow_random_access_file_get_raw(file),
&arrow_file_reader);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[ipc][file-reader][open]")) {
return garrow_file_reader_new_raw(&arrow_file_reader);
} else {
- garrow_error_set(error, status, "[ipc][file-reader][open]");
return NULL;
}
}
@@ -217,10 +216,11 @@ garrow_file_reader_get_record_batch(GArrowFileReader *file_reader,
std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
auto status = arrow_file_reader->GetRecordBatch(i, &arrow_record_batch);
- if (status.ok()) {
+ if (garrow_error_check(error,
+ status,
+ "[ipc][file-reader][get-record-batch]")) {
return garrow_record_batch_new_raw(&arrow_record_batch);
} else {
- garrow_error_set(error, status, "[ipc][file-reader][get-record-batch]");
return NULL;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/file-writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-writer.cpp b/c_glib/arrow-glib/file-writer.cpp
index 68eca2e..e615cf5 100644
--- a/c_glib/arrow-glib/file-writer.cpp
+++ b/c_glib/arrow-glib/file-writer.cpp
@@ -75,10 +75,9 @@ garrow_file_writer_open(GArrowOutputStream *sink,
arrow::ipc::FileWriter::Open(garrow_output_stream_get_raw(sink).get(),
garrow_schema_get_raw(schema),
&arrow_file_writer);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[ipc][file-writer][open]")) {
return garrow_file_writer_new_raw(&arrow_file_writer);
} else {
- garrow_error_set(error, status, "[ipc][file-writer][open]");
return NULL;
}
}
@@ -104,12 +103,9 @@ garrow_file_writer_write_record_batch(GArrowFileWriter *file_writer,
arrow_record_batch.get();
auto status = arrow_file_writer->WriteRecordBatch(*arrow_record_batch_raw);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[ipc][file-writer][write-record-batch]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[ipc][file-writer][write-record-batch]");
}
/**
@@ -127,12 +123,7 @@ garrow_file_writer_close(GArrowFileWriter *file_writer,
garrow_file_writer_get_raw(file_writer);
auto status = arrow_file_writer->Close();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[ipc][file-writer][close]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[ipc][file-writer][close]");
}
G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file.cpp b/c_glib/arrow-glib/file.cpp
index 0d0fe1d..7753393 100644
--- a/c_glib/arrow-glib/file.cpp
+++ b/c_glib/arrow-glib/file.cpp
@@ -60,12 +60,7 @@ garrow_file_close(GArrowFile *file,
auto arrow_file = garrow_file_get_raw(file);
auto status = arrow_file->Close();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][file][close]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][file][close]");
}
/**
@@ -83,10 +78,9 @@ garrow_file_tell(GArrowFile *file,
gint64 position;
auto status = arrow_file->Tell(&position);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[io][file][tell]")) {
return position;
} else {
- garrow_error_set(error, status, "[io][file][tell]");
return -1;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/memory-mapped-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/memory-mapped-file.cpp b/c_glib/arrow-glib/memory-mapped-file.cpp
index a3e1d0c..f9cbf07 100644
--- a/c_glib/arrow-glib/memory-mapped-file.cpp
+++ b/c_glib/arrow-glib/memory-mapped-file.cpp
@@ -260,7 +260,7 @@ garrow_memory_mapped_file_open(const gchar *path,
std::string context("[io][memory-mapped-file][open]: <");
context += path;
context += ">";
- garrow_error_set(error, status, context.c_str());
+ garrow_error_check(error, status, context.c_str());
return NULL;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/random-access-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/random-access-file.cpp b/c_glib/arrow-glib/random-access-file.cpp
index 71f315e..976a80d 100644
--- a/c_glib/arrow-glib/random-access-file.cpp
+++ b/c_glib/arrow-glib/random-access-file.cpp
@@ -61,10 +61,9 @@ garrow_random_access_file_get_size(GArrowRandomAccessFile *file,
int64_t size;
auto status = arrow_random_access_file->GetSize(&size);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[io][random-access-file][get-size]")) {
return size;
} else {
- garrow_error_set(error, status, "[io][random-access-file][get-size]");
return 0;
}
}
@@ -110,12 +109,7 @@ garrow_random_access_file_read_at(GArrowRandomAccessFile *file,
n_bytes,
n_read_bytes,
buffer);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][random-access-file][read-at]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][random-access-file][read-at]");
}
G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/readable.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/readable.cpp b/c_glib/arrow-glib/readable.cpp
index b8c0cd9..d893853 100644
--- a/c_glib/arrow-glib/readable.cpp
+++ b/c_glib/arrow-glib/readable.cpp
@@ -66,12 +66,7 @@ garrow_readable_read(GArrowReadable *readable,
const auto arrow_readable = garrow_readable_get_raw(readable);
auto status = arrow_readable->Read(n_bytes, n_read_bytes, buffer);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][readable][read]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][readable][read]");
}
G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/stream-reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-reader.cpp b/c_glib/arrow-glib/stream-reader.cpp
index c4ccebe..017d5e9 100644
--- a/c_glib/arrow-glib/stream-reader.cpp
+++ b/c_glib/arrow-glib/stream-reader.cpp
@@ -147,10 +147,9 @@ garrow_stream_reader_open(GArrowInputStream *stream,
auto status =
arrow::ipc::StreamReader::Open(garrow_input_stream_get_raw(stream),
&arrow_stream_reader);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[ipc][stream-reader][open]")) {
return garrow_stream_reader_new_raw(&arrow_stream_reader);
} else {
- garrow_error_set(error, status, "[ipc][stream-reader][open]");
return NULL;
}
}
@@ -187,14 +186,15 @@ garrow_stream_reader_get_next_record_batch(GArrowStreamReader *stream_reader,
std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
auto status = arrow_stream_reader->GetNextRecordBatch(&arrow_record_batch);
- if (status.ok()) {
+ if (garrow_error_check(error,
+ status,
+ "[ipc][stream-reader][get-next-record-batch]")) {
if (arrow_record_batch == nullptr) {
return NULL;
} else {
return garrow_record_batch_new_raw(&arrow_record_batch);
}
} else {
- garrow_error_set(error, status, "[ipc][stream-reader][get-next-record-batch]");
return NULL;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/stream-writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-writer.cpp b/c_glib/arrow-glib/stream-writer.cpp
index 016ce93..cc24f26 100644
--- a/c_glib/arrow-glib/stream-writer.cpp
+++ b/c_glib/arrow-glib/stream-writer.cpp
@@ -150,10 +150,9 @@ garrow_stream_writer_open(GArrowOutputStream *sink,
arrow::ipc::StreamWriter::Open(garrow_output_stream_get_raw(sink).get(),
garrow_schema_get_raw(schema),
&arrow_stream_writer);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[ipc][stream-writer][open]")) {
return garrow_stream_writer_new_raw(&arrow_stream_writer);
} else {
- garrow_error_set(error, status, "[ipc][stream-writer][open]");
return NULL;
}
}
@@ -179,12 +178,9 @@ garrow_stream_writer_write_record_batch(GArrowStreamWriter *stream_writer,
arrow_record_batch.get();
auto status = arrow_stream_writer->WriteRecordBatch(*arrow_record_batch_raw);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[ipc][stream-writer][write-record-batch]");
- return FALSE;
- }
+ return garrow_error_check(error,
+ status,
+ "[ipc][stream-writer][write-record-batch]");
}
/**
@@ -202,12 +198,7 @@ garrow_stream_writer_close(GArrowStreamWriter *stream_writer,
garrow_stream_writer_get_raw(stream_writer);
auto status = arrow_stream_writer->Close();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[ipc][stream-writer][close]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[ipc][stream-writer][close]");
}
G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/table.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/table.cpp b/c_glib/arrow-glib/table.cpp
index 1d743b7..2aba21b 100644
--- a/c_glib/arrow-glib/table.cpp
+++ b/c_glib/arrow-glib/table.cpp
@@ -226,10 +226,9 @@ garrow_table_add_column(GArrowTable *table,
const auto arrow_column = garrow_column_get_raw(column);
std::shared_ptr<arrow::Table> arrow_new_table;
auto status = arrow_table->AddColumn(i, arrow_column, &arrow_new_table);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[table][add-column]")) {
return garrow_table_new_raw(&arrow_new_table);
} else {
- garrow_error_set(error, status, "[table][add-column]");
return NULL;
}
}
@@ -253,10 +252,9 @@ garrow_table_remove_column(GArrowTable *table,
const auto arrow_table = garrow_table_get_raw(table);
std::shared_ptr<arrow::Table> arrow_new_table;
auto status = arrow_table->RemoveColumn(i, &arrow_new_table);
- if (status.ok()) {
+ if (garrow_error_check(error, status, "[table][remove-column]")) {
return garrow_table_new_raw(&arrow_new_table);
} else {
- garrow_error_set(error, status, "[table][remove-column]");
return NULL;
}
}
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/writeable-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable-file.cpp b/c_glib/arrow-glib/writeable-file.cpp
index d0937ea..b717c32 100644
--- a/c_glib/arrow-glib/writeable-file.cpp
+++ b/c_glib/arrow-glib/writeable-file.cpp
@@ -66,12 +66,7 @@ garrow_writeable_file_write_at(GArrowWriteableFile *writeable_file,
garrow_writeable_file_get_raw(writeable_file);
auto status = arrow_writeable_file->WriteAt(position, data, n_bytes);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][writeable-file][write-at]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][writeable-file][write-at]");
}
G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/3ad9d09f/c_glib/arrow-glib/writeable.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable.cpp b/c_glib/arrow-glib/writeable.cpp
index 6f4c630..eb6adfe 100644
--- a/c_glib/arrow-glib/writeable.cpp
+++ b/c_glib/arrow-glib/writeable.cpp
@@ -64,12 +64,7 @@ garrow_writeable_write(GArrowWriteable *writeable,
const auto arrow_writeable = garrow_writeable_get_raw(writeable);
auto status = arrow_writeable->Write(data, n_bytes);
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][writeable][write]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][writeable][write]");
}
/**
@@ -88,12 +83,7 @@ garrow_writeable_flush(GArrowWriteable *writeable,
const auto arrow_writeable = garrow_writeable_get_raw(writeable);
auto status = arrow_writeable->Flush();
- if (status.ok()) {
- return TRUE;
- } else {
- garrow_error_set(error, status, "[io][writeable][flush]");
- return FALSE;
- }
+ return garrow_error_check(error, status, "[io][writeable][flush]");
}
G_END_DECLS