You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2020/04/20 19:22:09 UTC
[arrow] 27/28: ARROW-8488: [R] Remove VALUE_OR_STOP and
STOP_IF_NOT_OK macros
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit a6290a88ec34a3378037c05b45a4f64ab91747d8
Author: François Saint-Jacques <fs...@gmail.com>
AuthorDate: Mon Apr 20 09:24:12 2020 -0400
ARROW-8488: [R] Remove VALUE_OR_STOP and STOP_IF_NOT_OK macros
Prefer templated functions over macro to align with the C++ style.
Closes #6969 from fsaintjacques/ARROW-8488
Authored-by: François Saint-Jacques <fs...@gmail.com>
Signed-off-by: François Saint-Jacques <fs...@gmail.com>
---
r/src/array.cpp | 6 +++---
r/src/array_from_vector.cpp | 32 ++++++++++++++++----------------
r/src/array_to_vector.cpp | 12 ++++++------
r/src/arrow_types.h | 20 ++++++--------------
r/src/chunkedarray.cpp | 4 ++--
r/src/compression.cpp | 6 +++---
r/src/compute.cpp | 30 +++++++++++++++---------------
r/src/csv.cpp | 8 ++++----
r/src/dataset.cpp | 42 ++++++++++++++++++++----------------------
r/src/datatype.cpp | 4 ++--
r/src/feather.cpp | 8 ++++----
r/src/filesystem.cpp | 32 ++++++++++++++++----------------
r/src/io.cpp | 44 ++++++++++++++++++++++----------------------
r/src/json.cpp | 4 ++--
r/src/message.cpp | 12 ++++++------
r/src/parquet.cpp | 2 +-
r/src/py-to-r.cpp | 17 ++++++++---------
r/src/recordbatch.cpp | 18 +++++++++---------
r/src/recordbatchreader.cpp | 20 ++++++++++----------
r/src/recordbatchwriter.cpp | 10 +++++-----
r/src/schema.cpp | 4 ++--
r/src/table.cpp | 12 ++++++------
r/src/threadpool.cpp | 2 +-
23 files changed, 169 insertions(+), 180 deletions(-)
diff --git a/r/src/array.cpp b/r/src/array.cpp
index 6244674..f1c32ca 100644
--- a/r/src/array.cpp
+++ b/r/src/array.cpp
@@ -143,7 +143,7 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
// [[arrow::export]]
std::shared_ptr<arrow::Array> Array__View(const std::shared_ptr<arrow::Array>& array,
const std::shared_ptr<arrow::DataType>& type) {
- return VALUE_OR_STOP(array->View(type));
+ return ValueOrStop(array->View(type));
}
// [[arrow::export]]
@@ -164,7 +164,7 @@ LogicalVector Array__Mask(const std::shared_ptr<arrow::Array>& array) {
// [[arrow::export]]
void Array__Validate(const std::shared_ptr<arrow::Array>& array) {
- STOP_IF_NOT_OK(array->Validate());
+ StopIfNotOk(array->Validate());
}
// [[arrow::export]]
@@ -194,7 +194,7 @@ std::shared_ptr<arrow::Array> StructArray__GetFieldByName(
// [[arrow::export]]
arrow::ArrayVector StructArray__Flatten(
const std::shared_ptr<arrow::StructArray>& array) {
- return VALUE_OR_STOP(array->Flatten());
+ return ValueOrStop(array->Flatten());
}
// [[arrow::export]]
diff --git a/r/src/array_from_vector.cpp b/r/src/array_from_vector.cpp
index 35bfbae..49ebfed 100644
--- a/r/src/array_from_vector.cpp
+++ b/r/src/array_from_vector.cpp
@@ -203,13 +203,13 @@ struct VectorToArrayConverter {
static std::shared_ptr<Array> Visit(SEXP x, const std::shared_ptr<DataType>& type) {
std::unique_ptr<ArrayBuilder> builder;
- STOP_IF_NOT_OK(MakeBuilder(arrow::default_memory_pool(), type, &builder));
+ StopIfNotOk(MakeBuilder(arrow::default_memory_pool(), type, &builder));
VectorToArrayConverter converter{x, builder.get()};
- STOP_IF_NOT_OK(arrow::VisitTypeInline(*type, &converter));
+ StopIfNotOk(arrow::VisitTypeInline(*type, &converter));
std::shared_ptr<Array> result;
- STOP_IF_NOT_OK(builder->Finish(&result));
+ StopIfNotOk(builder->Finish(&result));
return result;
}
@@ -228,7 +228,7 @@ std::shared_ptr<Array> MakeFactorArrayImpl(Rcpp::IntegerVector_ factor,
auto n = factor.size();
std::shared_ptr<Buffer> indices_buffer =
- VALUE_OR_STOP(AllocateBuffer(n * sizeof(value_type)));
+ ValueOrStop(AllocateBuffer(n * sizeof(value_type)));
std::vector<std::shared_ptr<Buffer>> buffers{nullptr, indices_buffer};
@@ -243,7 +243,7 @@ std::shared_ptr<Array> MakeFactorArrayImpl(Rcpp::IntegerVector_ factor,
if (i < n) {
// there are NA's so we need a null buffer
- auto null_buffer = VALUE_OR_STOP(AllocateBuffer(BitUtil::BytesForBits(n)));
+ auto null_buffer = ValueOrStop(AllocateBuffer(BitUtil::BytesForBits(n)));
internal::FirstTimeBitmapWriter null_bitmap_writer(null_buffer->mutable_data(), 0, n);
// catch up
@@ -273,7 +273,7 @@ std::shared_ptr<Array> MakeFactorArrayImpl(Rcpp::IntegerVector_ factor,
SEXP levels = Rf_getAttrib(factor, R_LevelsSymbol);
auto dict = MakeStringArray(levels, utf8());
- return VALUE_OR_STOP(DictionaryArray::FromArrays(type, array_indices, dict));
+ return ValueOrStop(DictionaryArray::FromArrays(type, array_indices, dict));
}
std::shared_ptr<Array> MakeFactorArray(Rcpp::IntegerVector_ factor,
@@ -1070,7 +1070,7 @@ std::shared_ptr<Array> MakeSimpleArray(SEXP x) {
auto first_na = std::find_if(p_vec_start, p_vec_end, is_na<value_type>);
if (first_na < p_vec_end) {
- auto null_bitmap = VALUE_OR_STOP(AllocateBuffer(BitUtil::BytesForBits(n)));
+ auto null_bitmap = ValueOrStop(AllocateBuffer(BitUtil::BytesForBits(n)));
internal::FirstTimeBitmapWriter bitmap_writer(null_bitmap->mutable_data(), 0, n);
// first loop to clear all the bits before the first NA
@@ -1192,7 +1192,7 @@ std::shared_ptr<arrow::Array> Array__from_vector(
// struct types
if (type->id() == Type::STRUCT) {
if (!type_inferred) {
- STOP_IF_NOT_OK(arrow::r::CheckCompatibleStruct(x, type));
+ StopIfNotOk(arrow::r::CheckCompatibleStruct(x, type));
}
return arrow::r::MakeStructArray(x, type);
@@ -1200,17 +1200,17 @@ std::shared_ptr<arrow::Array> Array__from_vector(
// general conversion with converter and builder
std::unique_ptr<arrow::r::VectorConverter> converter;
- STOP_IF_NOT_OK(arrow::r::GetConverter(type, &converter));
+ StopIfNotOk(arrow::r::GetConverter(type, &converter));
// Create ArrayBuilder for type
std::unique_ptr<arrow::ArrayBuilder> type_builder;
- STOP_IF_NOT_OK(arrow::MakeBuilder(arrow::default_memory_pool(), type, &type_builder));
- STOP_IF_NOT_OK(converter->Init(type_builder.get()));
+ StopIfNotOk(arrow::MakeBuilder(arrow::default_memory_pool(), type, &type_builder));
+ StopIfNotOk(converter->Init(type_builder.get()));
// ingest R data and grab the result array
- STOP_IF_NOT_OK(converter->Ingest(x));
+ StopIfNotOk(converter->Ingest(x));
std::shared_ptr<arrow::Array> result;
- STOP_IF_NOT_OK(converter->GetResult(&result));
+ StopIfNotOk(converter->GetResult(&result));
return result;
}
@@ -1261,8 +1261,8 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(Rcpp::List chunks,
if (n == 0) {
std::shared_ptr<arrow::Array> array;
std::unique_ptr<arrow::ArrayBuilder> type_builder;
- STOP_IF_NOT_OK(arrow::MakeBuilder(arrow::default_memory_pool(), type, &type_builder));
- STOP_IF_NOT_OK(type_builder->Finish(&array));
+ StopIfNotOk(arrow::MakeBuilder(arrow::default_memory_pool(), type, &type_builder));
+ StopIfNotOk(type_builder->Finish(&array));
vec.push_back(array);
} else {
// the first - might differ from the rest of the loop
@@ -1285,7 +1285,7 @@ std::shared_ptr<arrow::Array> DictionaryArray__FromArrays(
const std::shared_ptr<arrow::DataType>& type,
const std::shared_ptr<arrow::Array>& indices,
const std::shared_ptr<arrow::Array>& dict) {
- return VALUE_OR_STOP(arrow::DictionaryArray::FromArrays(type, indices, dict));
+ return ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict));
}
#endif
diff --git a/r/src/array_to_vector.cpp b/r/src/array_to_vector.cpp
index 5aefaee..4f55610 100644
--- a/r/src/array_to_vector.cpp
+++ b/r/src/array_to_vector.cpp
@@ -129,7 +129,7 @@ Status SomeNull_Ingest(SEXP data, R_xlen_t start, R_xlen_t n,
SEXP ArrayVector__as_vector(R_xlen_t n, const ArrayVector& arrays) {
auto converter = Converter::Make(arrays);
Shield<SEXP> data(converter->Allocate(n));
- STOP_IF_NOT_OK(converter->IngestSerial(data));
+ StopIfNotOk(converter->IngestSerial(data));
return data;
}
@@ -387,7 +387,7 @@ class Converter_Struct : public Converter {
Status Ingest_all_nulls(SEXP data, R_xlen_t start, R_xlen_t n) const {
int nf = converters.size();
for (int i = 0; i < nf; i++) {
- STOP_IF_NOT_OK(converters[i]->Ingest_all_nulls(VECTOR_ELT(data, i), start, n));
+ StopIfNotOk(converters[i]->Ingest_all_nulls(VECTOR_ELT(data, i), start, n));
}
return Status::OK();
}
@@ -397,9 +397,9 @@ class Converter_Struct : public Converter {
auto struct_array = internal::checked_cast<arrow::StructArray*>(array.get());
int nf = converters.size();
// Flatten() deals with merging of nulls
- auto arrays = VALUE_OR_STOP(struct_array->Flatten(default_memory_pool()));
+ auto arrays = ValueOrStop(struct_array->Flatten(default_memory_pool()));
for (int i = 0; i < nf; i++) {
- STOP_IF_NOT_OK(
+ StopIfNotOk(
converters[i]->Ingest_some_nulls(VECTOR_ELT(data, i), arrays[i], start, n));
}
@@ -760,7 +760,7 @@ Rcpp::List to_dataframe_serial(
for (int i = 0; i < nc; i++) {
SEXP column = tbl[i] = converters[i]->Allocate(nr);
- STOP_IF_NOT_OK(converters[i]->IngestSerial(column));
+ StopIfNotOk(converters[i]->IngestSerial(column));
}
tbl.attr("names") = names;
tbl.attr("class") = Rcpp::CharacterVector::create("tbl_df", "tbl", "data.frame");
@@ -801,7 +801,7 @@ Rcpp::List to_dataframe_parallel(
// wait for the ingestion to be finished
status &= tg->Finish();
- STOP_IF_NOT_OK(status);
+ StopIfNotOk(status);
tbl.attr("names") = names;
tbl.attr("class") = Rcpp::CharacterVector::create("tbl_df", "tbl", "data.frame");
diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h
index bcc1869..5c2b05a 100644
--- a/r/src/arrow_types.h
+++ b/r/src/arrow_types.h
@@ -43,14 +43,6 @@ struct data {
} // namespace r
} // namespace arrow
-#define STOP_IF_NOT(TEST, MSG) \
- do { \
- if (!(TEST)) Rcpp::stop(MSG); \
- } while (0)
-
-#define STOP_IF_NOT_OK(status) StopIfNotOk(status)
-#define VALUE_OR_STOP(result) ValueOrStop(result)
-
template <typename T>
struct NoDelete {
inline void operator()(T* ptr) {}
@@ -244,18 +236,18 @@ namespace fs = ::arrow::fs;
namespace arrow {
-template <typename R>
-auto ValueOrStop(R&& result) -> decltype(std::forward<R>(result).ValueOrDie()) {
- STOP_IF_NOT_OK(result.status());
- return std::forward<R>(result).ValueOrDie();
-}
-
static inline void StopIfNotOk(const Status& status) {
if (!(status.ok())) {
Rcpp::stop(status.ToString());
}
}
+template <typename R>
+auto ValueOrStop(R&& result) -> decltype(std::forward<R>(result).ValueOrDie()) {
+ StopIfNotOk(result.status());
+ return std::forward<R>(result).ValueOrDie();
+}
+
namespace r {
Status count_fields(SEXP lst, int* out);
diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp
index 749dc2d..5aeea8a 100644
--- a/r/src/chunkedarray.cpp
+++ b/r/src/chunkedarray.cpp
@@ -74,12 +74,12 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__Slice2(
std::shared_ptr<arrow::ChunkedArray> ChunkedArray__View(
const std::shared_ptr<arrow::ChunkedArray>& array,
const std::shared_ptr<arrow::DataType>& type) {
- return VALUE_OR_STOP(array->View(type));
+ return ValueOrStop(array->View(type));
}
// [[arrow::export]]
void ChunkedArray__Validate(const std::shared_ptr<arrow::ChunkedArray>& chunked_array) {
- STOP_IF_NOT_OK(chunked_array->Validate());
+ StopIfNotOk(chunked_array->Validate());
}
// [[arrow::export]]
diff --git a/r/src/compression.cpp b/r/src/compression.cpp
index 63beed8..cef03f1 100644
--- a/r/src/compression.cpp
+++ b/r/src/compression.cpp
@@ -22,7 +22,7 @@
// [[arrow::export]]
std::unique_ptr<arrow::util::Codec> util___Codec__Create(arrow::Compression::type codec,
int compression_level) {
- return VALUE_OR_STOP(arrow::util::Codec::Create(codec, compression_level));
+ return ValueOrStop(arrow::util::Codec::Create(codec, compression_level));
}
// [[arrow::export]]
@@ -39,14 +39,14 @@ bool util___Codec__IsAvailable(arrow::Compression::type codec) {
std::shared_ptr<arrow::io::CompressedOutputStream> io___CompressedOutputStream__Make(
const std::unique_ptr<arrow::util::Codec>& codec,
const std::shared_ptr<arrow::io::OutputStream>& raw) {
- return VALUE_OR_STOP(arrow::io::CompressedOutputStream::Make(codec.get(), raw));
+ return ValueOrStop(arrow::io::CompressedOutputStream::Make(codec.get(), raw));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::CompressedInputStream> io___CompressedInputStream__Make(
const std::unique_ptr<arrow::util::Codec>& codec,
const std::shared_ptr<arrow::io::InputStream>& raw) {
- return VALUE_OR_STOP(arrow::io::CompressedInputStream::Make(codec.get(), raw));
+ return ValueOrStop(arrow::io::CompressedInputStream::Make(codec.get(), raw));
}
#endif
diff --git a/r/src/compute.cpp b/r/src/compute.cpp
index 212b27c..bf9935a 100644
--- a/r/src/compute.cpp
+++ b/r/src/compute.cpp
@@ -36,7 +36,7 @@ std::shared_ptr<arrow::Array> Array__cast(
const std::shared_ptr<arrow::compute::CastOptions>& options) {
std::shared_ptr<arrow::Array> out;
arrow::compute::FunctionContext context;
- STOP_IF_NOT_OK(arrow::compute::Cast(&context, *array, target_type, *options, &out));
+ StopIfNotOk(arrow::compute::Cast(&context, *array, target_type, *options, &out));
return out;
}
@@ -48,7 +48,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__cast(
arrow::compute::Datum value(chunked_array);
arrow::compute::Datum out;
arrow::compute::FunctionContext context;
- STOP_IF_NOT_OK(arrow::compute::Cast(&context, value, target_type, *options, &out));
+ StopIfNotOk(arrow::compute::Cast(&context, value, target_type, *options, &out));
return out.chunked_array();
}
@@ -88,7 +88,7 @@ std::shared_ptr<arrow::Array> Array__Take(const std::shared_ptr<arrow::Array>& v
std::shared_ptr<arrow::Array> out;
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *values, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *values, *indices, options, &out));
return out;
}
@@ -100,7 +100,7 @@ std::shared_ptr<arrow::ChunkedArray> Array__TakeChunked(
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *values, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *values, *indices, options, &out));
return out;
}
@@ -111,7 +111,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatch__Take(
std::shared_ptr<arrow::RecordBatch> out;
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *batch, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *batch, *indices, options, &out));
return out;
}
@@ -123,7 +123,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__Take(
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *values, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *values, *indices, options, &out));
return out;
}
@@ -135,7 +135,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__TakeChunked(
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *values, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *values, *indices, options, &out));
return out;
}
@@ -146,7 +146,7 @@ std::shared_ptr<arrow::Table> Table__Take(const std::shared_ptr<arrow::Table>& t
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *table, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *table, *indices, options, &out));
return out;
}
@@ -158,7 +158,7 @@ std::shared_ptr<arrow::Table> Table__TakeChunked(
arrow::compute::FunctionContext context;
arrow::compute::TakeOptions options;
- STOP_IF_NOT_OK(arrow::compute::Take(&context, *table, *indices, options, &out));
+ StopIfNotOk(arrow::compute::Take(&context, *table, *indices, options, &out));
return out;
}
@@ -173,7 +173,7 @@ std::shared_ptr<arrow::Array> Array__Filter(const std::shared_ptr<arrow::Array>&
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, values, filter, {}, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, values, filter, {}, &out));
return out.make_array();
}
@@ -188,7 +188,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatch__Filter(
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, batch, filter, options, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, batch, filter, options, &out));
return out.record_batch();
}
@@ -203,7 +203,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__Filter(
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, values, filter, options, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, values, filter, options, &out));
return out.chunked_array();
}
@@ -218,7 +218,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__FilterChunked(
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, values, filter, options, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, values, filter, options, &out));
return out.chunked_array();
}
@@ -233,7 +233,7 @@ std::shared_ptr<arrow::Table> Table__Filter(const std::shared_ptr<arrow::Table>&
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, table, filter, options, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, table, filter, options, &out));
std::shared_ptr<arrow::Table> tab = out.table();
if (tab->num_rows() == 0) {
// Slight hack: if there are no rows in the result, instead do a 0-length
@@ -255,7 +255,7 @@ std::shared_ptr<arrow::Table> Table__FilterChunked(
if (keep_na) {
options.null_selection_behavior = arrow::compute::FilterOptions::EMIT_NULL;
}
- STOP_IF_NOT_OK(arrow::compute::Filter(&context, table, filter, options, &out));
+ StopIfNotOk(arrow::compute::Filter(&context, table, filter, options, &out));
std::shared_ptr<arrow::Table> tab = out.table();
if (tab->num_rows() == 0) {
// Slight hack: if there are no rows in the result, instead do a 0-length
diff --git a/r/src/csv.cpp b/r/src/csv.cpp
index 9c71ea6..a4432eb 100644
--- a/r/src/csv.cpp
+++ b/r/src/csv.cpp
@@ -78,15 +78,15 @@ std::shared_ptr<arrow::csv::TableReader> csv___TableReader__Make(
const std::shared_ptr<arrow::csv::ReadOptions>& read_options,
const std::shared_ptr<arrow::csv::ParseOptions>& parse_options,
const std::shared_ptr<arrow::csv::ConvertOptions>& convert_options) {
- return VALUE_OR_STOP(arrow::csv::TableReader::Make(arrow::default_memory_pool(), input,
- *read_options, *parse_options,
- *convert_options));
+ return ValueOrStop(arrow::csv::TableReader::Make(arrow::default_memory_pool(), input,
+ *read_options, *parse_options,
+ *convert_options));
}
// [[arrow::export]]
std::shared_ptr<arrow::Table> csv___TableReader__Read(
const std::shared_ptr<arrow::csv::TableReader>& table_reader) {
- return VALUE_OR_STOP(table_reader->Read());
+ return ValueOrStop(table_reader->Read());
}
#endif
diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp
index e92ac03..d5c9d83 100644
--- a/r/src/dataset.cpp
+++ b/r/src/dataset.cpp
@@ -27,7 +27,7 @@ using Rcpp::String;
// [[arrow::export]]
std::shared_ptr<ds::ScannerBuilder> dataset___Dataset__NewScan(
const std::shared_ptr<ds::Dataset>& ds) {
- return VALUE_OR_STOP(ds->NewScan());
+ return ValueOrStop(ds->NewScan());
}
// [[arrow::export]]
@@ -45,13 +45,13 @@ std::string dataset___Dataset__type_name(const std::shared_ptr<ds::Dataset>& dat
std::shared_ptr<ds::Dataset> dataset___Dataset__ReplaceSchema(
const std::shared_ptr<ds::Dataset>& dataset,
const std::shared_ptr<arrow::Schema>& schm) {
- return VALUE_OR_STOP(dataset->ReplaceSchema(schm));
+ return ValueOrStop(dataset->ReplaceSchema(schm));
}
// [[arrow::export]]
std::shared_ptr<ds::UnionDataset> dataset___UnionDataset__create(
const ds::DatasetVector& datasets, const std::shared_ptr<arrow::Schema>& schm) {
- return VALUE_OR_STOP(ds::UnionDataset::Make(schm, datasets));
+ return ValueOrStop(ds::UnionDataset::Make(schm, datasets));
}
// [[arrow::export]]
@@ -81,14 +81,14 @@ std::shared_ptr<ds::Dataset> dataset___DatasetFactory__Finish1(
if (unify_schemas) {
opts.inspect_options.fragments = ds::InspectOptions::kInspectAllFragments;
}
- return VALUE_OR_STOP(factory->Finish(opts));
+ return ValueOrStop(factory->Finish(opts));
}
// [[arrow::export]]
std::shared_ptr<ds::Dataset> dataset___DatasetFactory__Finish2(
const std::shared_ptr<ds::DatasetFactory>& factory,
const std::shared_ptr<arrow::Schema>& schema) {
- return VALUE_OR_STOP(factory->Finish(schema));
+ return ValueOrStop(factory->Finish(schema));
}
// [[arrow::export]]
@@ -98,13 +98,13 @@ std::shared_ptr<arrow::Schema> dataset___DatasetFactory__Inspect(
if (unify_schemas) {
opts.fragments = ds::InspectOptions::kInspectAllFragments;
}
- return VALUE_OR_STOP(factory->Inspect(opts));
+ return ValueOrStop(factory->Inspect(opts));
}
// [[arrow::export]]
std::shared_ptr<ds::DatasetFactory> dataset___UnionDatasetFactory__Make(
const std::vector<std::shared_ptr<ds::DatasetFactory>>& children) {
- return VALUE_OR_STOP(ds::UnionDatasetFactory::Make(children));
+ return ValueOrStop(ds::UnionDatasetFactory::Make(children));
}
// [[arrow::export]]
@@ -119,8 +119,7 @@ std::shared_ptr<ds::DatasetFactory> dataset___FileSystemDatasetFactory__Make2(
options.partitioning = partitioning;
}
- return VALUE_OR_STOP(
- ds::FileSystemDatasetFactory::Make(fs, *selector, format, options));
+ return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options));
}
// [[arrow::export]]
@@ -143,8 +142,7 @@ std::shared_ptr<ds::DatasetFactory> dataset___FileSystemDatasetFactory__Make3(
options.partitioning = factory;
}
- return VALUE_OR_STOP(
- ds::FileSystemDatasetFactory::Make(fs, *selector, format, options));
+ return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options));
}
// FileFormat, ParquetFileFormat, IpcFileFormat
@@ -206,7 +204,7 @@ std::shared_ptr<ds::PartitioningFactory> dataset___HivePartitioning__MakeFactory
// [[arrow::export]]
void dataset___ScannerBuilder__Project(const std::shared_ptr<ds::ScannerBuilder>& sb,
const std::vector<std::string>& cols) {
- STOP_IF_NOT_OK(sb->Project(cols));
+ StopIfNotOk(sb->Project(cols));
}
// [[arrow::export]]
@@ -214,20 +212,20 @@ void dataset___ScannerBuilder__Filter(const std::shared_ptr<ds::ScannerBuilder>&
const std::shared_ptr<ds::Expression>& expr) {
// Expressions converted from R's expressions are typed with R's native type,
// i.e. double, int64_t and bool.
- auto cast_filter = VALUE_OR_STOP(InsertImplicitCasts(*expr, *sb->schema()));
- STOP_IF_NOT_OK(sb->Filter(cast_filter));
+ auto cast_filter = ValueOrStop(InsertImplicitCasts(*expr, *sb->schema()));
+ StopIfNotOk(sb->Filter(cast_filter));
}
// [[arrow::export]]
void dataset___ScannerBuilder__UseThreads(const std::shared_ptr<ds::ScannerBuilder>& sb,
bool threads) {
- STOP_IF_NOT_OK(sb->UseThreads(threads));
+ StopIfNotOk(sb->UseThreads(threads));
}
// [[arrow::export]]
void dataset___ScannerBuilder__BatchSize(const std::shared_ptr<ds::ScannerBuilder>& sb,
int64_t batch_size) {
- STOP_IF_NOT_OK(sb->BatchSize(batch_size));
+ StopIfNotOk(sb->BatchSize(batch_size));
}
// [[arrow::export]]
@@ -239,24 +237,24 @@ std::shared_ptr<arrow::Schema> dataset___ScannerBuilder__schema(
// [[arrow::export]]
std::shared_ptr<ds::Scanner> dataset___ScannerBuilder__Finish(
const std::shared_ptr<ds::ScannerBuilder>& sb) {
- return VALUE_OR_STOP(sb->Finish());
+ return ValueOrStop(sb->Finish());
}
// [[arrow::export]]
std::shared_ptr<arrow::Table> dataset___Scanner__ToTable(
const std::shared_ptr<ds::Scanner>& scanner) {
- return VALUE_OR_STOP(scanner->ToTable());
+ return ValueOrStop(scanner->ToTable());
}
// [[arrow::export]]
std::vector<std::shared_ptr<ds::ScanTask>> dataset___Scanner__Scan(
const std::shared_ptr<ds::Scanner>& scanner) {
- auto it = VALUE_OR_STOP(scanner->Scan());
+ auto it = ValueOrStop(scanner->Scan());
std::vector<std::shared_ptr<ds::ScanTask>> out;
std::shared_ptr<ds::ScanTask> scan_task;
// TODO(npr): can this iteration be parallelized?
for (auto st : it) {
- scan_task = VALUE_OR_STOP(st);
+ scan_task = ValueOrStop(st);
out.push_back(scan_task);
}
return out;
@@ -266,11 +264,11 @@ std::vector<std::shared_ptr<ds::ScanTask>> dataset___Scanner__Scan(
std::vector<std::shared_ptr<arrow::RecordBatch>> dataset___ScanTask__get_batches(
const std::shared_ptr<ds::ScanTask>& scan_task) {
arrow::RecordBatchIterator rbi;
- rbi = VALUE_OR_STOP(scan_task->Execute());
+ rbi = ValueOrStop(scan_task->Execute());
std::vector<std::shared_ptr<arrow::RecordBatch>> out;
std::shared_ptr<arrow::RecordBatch> batch;
for (auto b : rbi) {
- batch = VALUE_OR_STOP(b);
+ batch = ValueOrStop(b);
out.push_back(batch);
}
return out;
diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp
index bad97ea..87b3c96 100644
--- a/r/src/datatype.cpp
+++ b/r/src/datatype.cpp
@@ -89,7 +89,7 @@ std::shared_ptr<arrow::DataType> Null__initialize() { return arrow::null(); }
std::shared_ptr<arrow::DataType> Decimal128Type__initialize(int32_t precision,
int32_t scale) {
// Use the builder that validates inputs
- return VALUE_OR_STOP(arrow::Decimal128Type::Make(precision, scale));
+ return ValueOrStop(arrow::Decimal128Type::Make(precision, scale));
}
// [[arrow::export]]
@@ -216,7 +216,7 @@ arrow::TimeUnit::type TimestampType__unit(
std::shared_ptr<arrow::DataType> DictionaryType__initialize(
const std::shared_ptr<arrow::DataType>& index_type,
const std::shared_ptr<arrow::DataType>& value_type, bool ordered) {
- return VALUE_OR_STOP(arrow::DictionaryType::Make(index_type, value_type, ordered));
+ return ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered));
}
// [[arrow::export]]
diff --git a/r/src/feather.cpp b/r/src/feather.cpp
index 7ab7360..f60f8b5 100644
--- a/r/src/feather.cpp
+++ b/r/src/feather.cpp
@@ -33,7 +33,7 @@ void ipc___WriteFeather__Table(const std::shared_ptr<arrow::io::OutputStream>& s
if (compression_level != -1) {
properties.compression_level = compression_level;
}
- STOP_IF_NOT_OK(arrow::ipc::feather::WriteTable(*table, stream.get(), properties));
+ StopIfNotOk(arrow::ipc::feather::WriteTable(*table, stream.get(), properties));
}
// ----------- Reader
@@ -56,11 +56,11 @@ std::shared_ptr<arrow::Table> ipc___feather___Reader__Read(
for (R_xlen_t i = 0; i < n; i++) {
names[i] = CHAR(STRING_ELT(columns, i));
}
- STOP_IF_NOT_OK(reader->Read(names, &table));
+ StopIfNotOk(reader->Read(names, &table));
break;
}
case NILSXP:
- STOP_IF_NOT_OK(reader->Read(&table));
+ StopIfNotOk(reader->Read(&table));
break;
default:
Rcpp::stop("incompatible column specification");
@@ -73,7 +73,7 @@ std::shared_ptr<arrow::Table> ipc___feather___Reader__Read(
// [[arrow::export]]
std::shared_ptr<arrow::ipc::feather::Reader> ipc___feather___Reader__Open(
const std::shared_ptr<arrow::io::RandomAccessFile>& stream) {
- return VALUE_OR_STOP(arrow::ipc::feather::Reader::Open(stream));
+ return ValueOrStop(arrow::ipc::feather::Reader::Open(stream));
}
// [[arrow::export]]
diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp
index 54f2491..ce69332 100644
--- a/r/src/filesystem.cpp
+++ b/r/src/filesystem.cpp
@@ -120,7 +120,7 @@ std::vector<std::shared_ptr<T>> shared_ptr_vector(const std::vector<T>& vec) {
std::vector<std::shared_ptr<fs::FileInfo>> fs___FileSystem__GetTargetInfos_Paths(
const std::shared_ptr<fs::FileSystem>& file_system,
const std::vector<std::string>& paths) {
- auto results = VALUE_OR_STOP(file_system->GetFileInfo(paths));
+ auto results = ValueOrStop(file_system->GetFileInfo(paths));
return shared_ptr_vector(results);
}
@@ -128,74 +128,74 @@ std::vector<std::shared_ptr<fs::FileInfo>> fs___FileSystem__GetTargetInfos_Paths
std::vector<std::shared_ptr<fs::FileInfo>> fs___FileSystem__GetTargetInfos_FileSelector(
const std::shared_ptr<fs::FileSystem>& file_system,
const std::shared_ptr<fs::FileSelector>& selector) {
- auto results = VALUE_OR_STOP(file_system->GetFileInfo(*selector));
+ auto results = ValueOrStop(file_system->GetFileInfo(*selector));
return shared_ptr_vector(results);
}
// [[arrow::export]]
void fs___FileSystem__CreateDir(const std::shared_ptr<fs::FileSystem>& file_system,
const std::string& path, bool recursive) {
- STOP_IF_NOT_OK(file_system->CreateDir(path, recursive));
+ StopIfNotOk(file_system->CreateDir(path, recursive));
}
// [[arrow::export]]
void fs___FileSystem__DeleteDir(const std::shared_ptr<fs::FileSystem>& file_system,
const std::string& path) {
- STOP_IF_NOT_OK(file_system->DeleteDir(path));
+ StopIfNotOk(file_system->DeleteDir(path));
}
// [[arrow::export]]
void fs___FileSystem__DeleteDirContents(
const std::shared_ptr<fs::FileSystem>& file_system, const std::string& path) {
- STOP_IF_NOT_OK(file_system->DeleteDirContents(path));
+ StopIfNotOk(file_system->DeleteDirContents(path));
}
// [[arrow::export]]
void fs___FileSystem__DeleteFile(const std::shared_ptr<fs::FileSystem>& file_system,
const std::string& path) {
- STOP_IF_NOT_OK(file_system->DeleteFile(path));
+ StopIfNotOk(file_system->DeleteFile(path));
}
// [[arrow::export]]
void fs___FileSystem__DeleteFiles(const std::shared_ptr<fs::FileSystem>& file_system,
const std::vector<std::string>& paths) {
- STOP_IF_NOT_OK(file_system->DeleteFiles(paths));
+ StopIfNotOk(file_system->DeleteFiles(paths));
}
// [[arrow::export]]
void fs___FileSystem__Move(const std::shared_ptr<fs::FileSystem>& file_system,
const std::string& src, const std::string& dest) {
- STOP_IF_NOT_OK(file_system->Move(src, dest));
+ StopIfNotOk(file_system->Move(src, dest));
}
// [[arrow::export]]
void fs___FileSystem__CopyFile(const std::shared_ptr<fs::FileSystem>& file_system,
const std::string& src, const std::string& dest) {
- STOP_IF_NOT_OK(file_system->CopyFile(src, dest));
+ StopIfNotOk(file_system->CopyFile(src, dest));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::InputStream> fs___FileSystem__OpenInputStream(
const std::shared_ptr<fs::FileSystem>& file_system, const std::string& path) {
- return VALUE_OR_STOP(file_system->OpenInputStream(path));
+ return ValueOrStop(file_system->OpenInputStream(path));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::RandomAccessFile> fs___FileSystem__OpenInputFile(
const std::shared_ptr<fs::FileSystem>& file_system, const std::string& path) {
- return VALUE_OR_STOP(file_system->OpenInputFile(path));
+ return ValueOrStop(file_system->OpenInputFile(path));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::OutputStream> fs___FileSystem__OpenOutputStream(
const std::shared_ptr<fs::FileSystem>& file_system, const std::string& path) {
- return VALUE_OR_STOP(file_system->OpenOutputStream(path));
+ return ValueOrStop(file_system->OpenOutputStream(path));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::OutputStream> fs___FileSystem__OpenAppendStream(
const std::shared_ptr<fs::FileSystem>& file_system, const std::string& path) {
- return VALUE_OR_STOP(file_system->OpenAppendStream(path));
+ return ValueOrStop(file_system->OpenAppendStream(path));
}
// [[arrow::export]]
@@ -218,7 +218,7 @@ std::shared_ptr<fs::SubTreeFileSystem> fs___SubTreeFileSystem__create(
// [[arrow::export]]
Rcpp::List fs___FileSystemFromUri(const std::string& path) {
std::string out_path;
- auto file_system = VALUE_OR_STOP(fs::FileSystemFromUri(path, &out_path));
+ auto file_system = ValueOrStop(fs::FileSystemFromUri(path, &out_path));
return Rcpp::List::create(Rcpp::Named("fs") = file_system,
Rcpp::Named("path") = out_path);
}
@@ -228,12 +228,12 @@ Rcpp::List fs___FileSystemFromUri(const std::string& path) {
#if defined(ARROW_R_WITH_S3)
// [[s3::export]]
-void fs___EnsureS3Initialized() { STOP_IF_NOT_OK(fs::EnsureS3Initialized()); }
+void fs___EnsureS3Initialized() { StopIfNotOk(fs::EnsureS3Initialized()); }
// [[s3::export]]
std::shared_ptr<fs::S3FileSystem> fs___S3FileSystem__create() {
auto opts = fs::S3Options::Defaults();
- return VALUE_OR_STOP(fs::S3FileSystem::Make(opts));
+ return ValueOrStop(fs::S3FileSystem::Make(opts));
}
#endif
diff --git a/r/src/io.cpp b/r/src/io.cpp
index dc7bcae..41d902a 100644
--- a/r/src/io.cpp
+++ b/r/src/io.cpp
@@ -26,21 +26,21 @@ using Rcpp::RawVector_;
// [[arrow::export]]
std::shared_ptr<arrow::Buffer> io___Readable__Read(
const std::shared_ptr<arrow::io::Readable>& x, int64_t nbytes) {
- return VALUE_OR_STOP(x->Read(nbytes));
+ return ValueOrStop(x->Read(nbytes));
}
// ------ arrow::io::InputStream
// [[arrow::export]]
void io___InputStream__Close(const std::shared_ptr<arrow::io::InputStream>& x) {
- STOP_IF_NOT_OK(x->Close());
+ StopIfNotOk(x->Close());
}
// ------ arrow::io::OutputStream
// [[arrow::export]]
void io___OutputStream__Close(const std::shared_ptr<arrow::io::OutputStream>& x) {
- STOP_IF_NOT_OK(x->Close());
+ StopIfNotOk(x->Close());
}
// ------ arrow::io::RandomAccessFile
@@ -48,7 +48,7 @@ void io___OutputStream__Close(const std::shared_ptr<arrow::io::OutputStream>& x)
// [[arrow::export]]
int64_t io___RandomAccessFile__GetSize(
const std::shared_ptr<arrow::io::RandomAccessFile>& x) {
- return VALUE_OR_STOP(x->GetSize());
+ return ValueOrStop(x->GetSize());
}
// [[arrow::export]]
@@ -60,30 +60,30 @@ bool io___RandomAccessFile__supports_zero_copy(
// [[arrow::export]]
void io___RandomAccessFile__Seek(const std::shared_ptr<arrow::io::RandomAccessFile>& x,
int64_t position) {
- STOP_IF_NOT_OK(x->Seek(position));
+ StopIfNotOk(x->Seek(position));
}
// [[arrow::export]]
int64_t io___RandomAccessFile__Tell(
const std::shared_ptr<arrow::io::RandomAccessFile>& x) {
- return VALUE_OR_STOP(x->Tell());
+ return ValueOrStop(x->Tell());
}
// [[arrow::export]]
std::shared_ptr<arrow::Buffer> io___RandomAccessFile__Read0(
const std::shared_ptr<arrow::io::RandomAccessFile>& x) {
- int64_t current = VALUE_OR_STOP(x->Tell());
+ int64_t current = ValueOrStop(x->Tell());
- int64_t n = VALUE_OR_STOP(x->GetSize());
+ int64_t n = ValueOrStop(x->GetSize());
- return VALUE_OR_STOP(x->Read(n - current));
+ return ValueOrStop(x->Read(n - current));
}
// [[arrow::export]]
std::shared_ptr<arrow::Buffer> io___RandomAccessFile__ReadAt(
const std::shared_ptr<arrow::io::RandomAccessFile>& x, int64_t position,
int64_t nbytes) {
- return VALUE_OR_STOP(x->ReadAt(position, nbytes));
+ return ValueOrStop(x->ReadAt(position, nbytes));
}
// ------ arrow::io::MemoryMappedFile
@@ -91,19 +91,19 @@ std::shared_ptr<arrow::Buffer> io___RandomAccessFile__ReadAt(
// [[arrow::export]]
std::shared_ptr<arrow::io::MemoryMappedFile> io___MemoryMappedFile__Create(
const std::string& path, int64_t size) {
- return VALUE_OR_STOP(arrow::io::MemoryMappedFile::Create(path, size));
+ return ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size));
}
// [[arrow::export]]
std::shared_ptr<arrow::io::MemoryMappedFile> io___MemoryMappedFile__Open(
const std::string& path, arrow::io::FileMode::type mode) {
- return VALUE_OR_STOP(arrow::io::MemoryMappedFile::Open(path, mode));
+ return ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode));
}
// [[arrow::export]]
void io___MemoryMappedFile__Resize(const std::shared_ptr<arrow::io::MemoryMappedFile>& x,
int64_t size) {
- STOP_IF_NOT_OK(x->Resize(size));
+ StopIfNotOk(x->Resize(size));
}
// ------ arrow::io::ReadableFile
@@ -111,7 +111,7 @@ void io___MemoryMappedFile__Resize(const std::shared_ptr<arrow::io::MemoryMapped
// [[arrow::export]]
std::shared_ptr<arrow::io::ReadableFile> io___ReadableFile__Open(
const std::string& path) {
- return VALUE_OR_STOP(arrow::io::ReadableFile::Open(path));
+ return ValueOrStop(arrow::io::ReadableFile::Open(path));
}
// ------ arrow::io::BufferReader
@@ -127,14 +127,14 @@ std::shared_ptr<arrow::io::BufferReader> io___BufferReader__initialize(
// [[arrow::export]]
void io___Writable__write(const std::shared_ptr<arrow::io::Writable>& stream,
const std::shared_ptr<arrow::Buffer>& buf) {
- STOP_IF_NOT_OK(stream->Write(buf->data(), buf->size()));
+ StopIfNotOk(stream->Write(buf->data(), buf->size()));
}
// ------- arrow::io::OutputStream
// [[arrow::export]]
int64_t io___OutputStream__Tell(const std::shared_ptr<arrow::io::OutputStream>& stream) {
- return VALUE_OR_STOP(stream->Tell());
+ return ValueOrStop(stream->Tell());
}
// ------ arrow::io::FileOutputStream
@@ -142,7 +142,7 @@ int64_t io___OutputStream__Tell(const std::shared_ptr<arrow::io::OutputStream>&
// [[arrow::export]]
std::shared_ptr<arrow::io::FileOutputStream> io___FileOutputStream__Open(
const std::string& path) {
- return VALUE_OR_STOP(arrow::io::FileOutputStream::Open(path));
+ return ValueOrStop(arrow::io::FileOutputStream::Open(path));
}
// ------ arrow::BufferOutputStream
@@ -150,8 +150,8 @@ std::shared_ptr<arrow::io::FileOutputStream> io___FileOutputStream__Open(
// [[arrow::export]]
std::shared_ptr<arrow::io::BufferOutputStream> io___BufferOutputStream__Create(
int64_t initial_capacity) {
- return VALUE_OR_STOP(arrow::io::BufferOutputStream::Create(
- initial_capacity, arrow::default_memory_pool()));
+ return ValueOrStop(arrow::io::BufferOutputStream::Create(initial_capacity,
+ arrow::default_memory_pool()));
}
// [[arrow::export]]
@@ -163,19 +163,19 @@ int64_t io___BufferOutputStream__capacity(
// [[arrow::export]]
std::shared_ptr<arrow::Buffer> io___BufferOutputStream__Finish(
const std::shared_ptr<arrow::io::BufferOutputStream>& stream) {
- return VALUE_OR_STOP(stream->Finish());
+ return ValueOrStop(stream->Finish());
}
// [[arrow::export]]
int64_t io___BufferOutputStream__Tell(
const std::shared_ptr<arrow::io::BufferOutputStream>& stream) {
- return VALUE_OR_STOP(stream->Tell());
+ return ValueOrStop(stream->Tell());
}
// [[arrow::export]]
void io___BufferOutputStream__Write(
const std::shared_ptr<arrow::io::BufferOutputStream>& stream, RawVector_ bytes) {
- STOP_IF_NOT_OK(stream->Write(bytes.begin(), bytes.size()));
+ StopIfNotOk(stream->Write(bytes.begin(), bytes.size()));
}
#endif
diff --git a/r/src/json.cpp b/r/src/json.cpp
index 0479121..8bbd042 100644
--- a/r/src/json.cpp
+++ b/r/src/json.cpp
@@ -47,7 +47,7 @@ std::shared_ptr<arrow::json::TableReader> json___TableReader__Make(
const std::shared_ptr<arrow::json::ReadOptions>& read_options,
const std::shared_ptr<arrow::json::ParseOptions>& parse_options) {
std::shared_ptr<arrow::json::TableReader> table_reader;
- STOP_IF_NOT_OK(arrow::json::TableReader::Make(
+ StopIfNotOk(arrow::json::TableReader::Make(
arrow::default_memory_pool(), input, *read_options, *parse_options, &table_reader));
return table_reader;
}
@@ -56,7 +56,7 @@ std::shared_ptr<arrow::json::TableReader> json___TableReader__Make(
std::shared_ptr<arrow::Table> json___TableReader__Read(
const std::shared_ptr<arrow::json::TableReader>& table_reader) {
std::shared_ptr<arrow::Table> table;
- STOP_IF_NOT_OK(table_reader->Read(&table));
+ StopIfNotOk(table_reader->Read(&table));
return table;
}
diff --git a/r/src/message.cpp b/r/src/message.cpp
index 4d7115f..92c4613 100644
--- a/r/src/message.cpp
+++ b/r/src/message.cpp
@@ -59,8 +59,8 @@ std::shared_ptr<arrow::RecordBatch> ipc___ReadRecordBatch__Message__Schema(
const std::shared_ptr<arrow::Schema>& schema) {
// TODO: perhaps this should come from the R side
arrow::ipc::DictionaryMemo memo;
- return VALUE_OR_STOP(arrow::ipc::ReadRecordBatch(
- *message, schema, &memo, arrow::ipc::IpcReadOptions::Defaults()));
+ return ValueOrStop(arrow::ipc::ReadRecordBatch(*message, schema, &memo,
+ arrow::ipc::IpcReadOptions::Defaults()));
}
// [[arrow::export]]
@@ -68,14 +68,14 @@ std::shared_ptr<arrow::Schema> ipc___ReadSchema_InputStream(
const std::shared_ptr<arrow::io::InputStream>& stream) {
// TODO: promote to function argument
arrow::ipc::DictionaryMemo memo;
- return VALUE_OR_STOP(arrow::ipc::ReadSchema(stream.get(), &memo));
+ return ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo));
}
// [[arrow::export]]
std::shared_ptr<arrow::Schema> ipc___ReadSchema_Message(
const std::unique_ptr<arrow::ipc::Message>& message) {
arrow::ipc::DictionaryMemo empty_memo;
- return VALUE_OR_STOP(arrow::ipc::ReadSchema(*message, &empty_memo));
+ return ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo));
}
//--------- MessageReader
@@ -89,13 +89,13 @@ std::unique_ptr<arrow::ipc::MessageReader> ipc___MessageReader__Open(
// [[arrow::export]]
std::unique_ptr<arrow::ipc::Message> ipc___MessageReader__ReadNextMessage(
const std::unique_ptr<arrow::ipc::MessageReader>& reader) {
- return VALUE_OR_STOP(reader->ReadNextMessage());
+ return ValueOrStop(reader->ReadNextMessage());
}
// [[arrow::export]]
std::unique_ptr<arrow::ipc::Message> ipc___ReadMessage(
const std::shared_ptr<arrow::io::InputStream>& stream) {
- return VALUE_OR_STOP(arrow::ipc::ReadMessage(stream.get()));
+ return ValueOrStop(arrow::ipc::ReadMessage(stream.get()));
}
#endif
diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp
index 562bc5d..a2b3893 100644
--- a/r/src/parquet.cpp
+++ b/r/src/parquet.cpp
@@ -296,7 +296,7 @@ void parquet___arrow___WriteTable(
std::shared_ptr<arrow::Schema> parquet___arrow___FileReader__GetSchema(
const std::unique_ptr<parquet::arrow::FileReader>& reader) {
std::shared_ptr<arrow::Schema> schema;
- STOP_IF_NOT_OK(reader->GetSchema(&schema));
+ StopIfNotOk(reader->GetSchema(&schema));
return schema;
}
diff --git a/r/src/py-to-r.cpp b/r/src/py-to-r.cpp
index 491ee57..021b8f4 100644
--- a/r/src/py-to-r.cpp
+++ b/r/src/py-to-r.cpp
@@ -21,13 +21,13 @@
// [[arrow::export]]
std::shared_ptr<arrow::Array> ImportArray(uintptr_t array, uintptr_t schema) {
- return VALUE_OR_STOP(arrow::ImportArray(reinterpret_cast<struct ArrowArray*>(array),
- reinterpret_cast<struct ArrowSchema*>(schema)));
+ return ValueOrStop(arrow::ImportArray(reinterpret_cast<struct ArrowArray*>(array),
+ reinterpret_cast<struct ArrowSchema*>(schema)));
}
// [[arrow::export]]
std::shared_ptr<arrow::RecordBatch> ImportRecordBatch(uintptr_t array, uintptr_t schema) {
- return VALUE_OR_STOP(
+ return ValueOrStop(
arrow::ImportRecordBatch(reinterpret_cast<struct ArrowArray*>(array),
reinterpret_cast<struct ArrowSchema*>(schema)));
}
@@ -50,26 +50,25 @@ void delete_arrow_array(uintptr_t ptr) {
// [[arrow::export]]
void ExportType(const std::shared_ptr<arrow::DataType>& type, uintptr_t ptr) {
- STOP_IF_NOT_OK(arrow::ExportType(*type, reinterpret_cast<struct ArrowSchema*>(ptr)));
+ StopIfNotOk(arrow::ExportType(*type, reinterpret_cast<struct ArrowSchema*>(ptr)));
}
// [[arrow::export]]
void ExportSchema(const std::shared_ptr<arrow::Schema>& schema, uintptr_t ptr) {
- STOP_IF_NOT_OK(
- arrow::ExportSchema(*schema, reinterpret_cast<struct ArrowSchema*>(ptr)));
+ StopIfNotOk(arrow::ExportSchema(*schema, reinterpret_cast<struct ArrowSchema*>(ptr)));
}
// [[arrow::export]]
void ExportArray(const std::shared_ptr<arrow::Array>& array, uintptr_t ptr,
uintptr_t schema_ptr) {
- STOP_IF_NOT_OK(arrow::ExportArray(*array, reinterpret_cast<struct ArrowArray*>(ptr),
- reinterpret_cast<struct ArrowSchema*>(schema_ptr)));
+ StopIfNotOk(arrow::ExportArray(*array, reinterpret_cast<struct ArrowArray*>(ptr),
+ reinterpret_cast<struct ArrowSchema*>(schema_ptr)));
}
// [[arrow::export]]
void ExportRecordBatch(const std::shared_ptr<arrow::RecordBatch>& batch, uintptr_t ptr,
uintptr_t schema_ptr) {
- STOP_IF_NOT_OK(
+ StopIfNotOk(
arrow::ExportRecordBatch(*batch, reinterpret_cast<struct ArrowArray*>(ptr),
reinterpret_cast<struct ArrowSchema*>(schema_ptr)));
}
diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp
index eb375c5..2cbc656 100644
--- a/r/src/recordbatch.cpp
+++ b/r/src/recordbatch.cpp
@@ -112,7 +112,7 @@ bool RecordBatch__Equals(const std::shared_ptr<arrow::RecordBatch>& self,
std::shared_ptr<arrow::RecordBatch> RecordBatch__RemoveColumn(
const std::shared_ptr<arrow::RecordBatch>& batch, int i) {
arrow::r::validate_index(i, batch->num_columns());
- return VALUE_OR_STOP(batch->RemoveColumn(i));
+ return ValueOrStop(batch->RemoveColumn(i));
}
// [[arrow::export]]
@@ -153,7 +153,7 @@ Rcpp::RawVector ipc___SerializeRecordBatch__Raw(
const std::shared_ptr<arrow::RecordBatch>& batch) {
// how many bytes do we need ?
int64_t size;
- STOP_IF_NOT_OK(arrow::ipc::GetRecordBatchSize(*batch, &size));
+ StopIfNotOk(arrow::ipc::GetRecordBatchSize(*batch, &size));
// allocate the result raw vector
Rcpp::RawVector out(Rcpp::no_init(size));
@@ -161,9 +161,9 @@ Rcpp::RawVector ipc___SerializeRecordBatch__Raw(
// serialize into the bytes of the raw vector
auto buffer = std::make_shared<arrow::r::RBuffer<RAWSXP, Rcpp::RawVector>>(out);
arrow::io::FixedSizeBufferWriter stream(buffer);
- STOP_IF_NOT_OK(arrow::ipc::SerializeRecordBatch(
+ StopIfNotOk(arrow::ipc::SerializeRecordBatch(
*batch, arrow::ipc::IpcWriteOptions::Defaults(), &stream));
- STOP_IF_NOT_OK(stream.Close());
+ StopIfNotOk(stream.Close());
return out;
}
@@ -174,7 +174,7 @@ std::shared_ptr<arrow::RecordBatch> ipc___ReadRecordBatch__InputStream__Schema(
const std::shared_ptr<arrow::Schema>& schema) {
// TODO: promote to function arg
arrow::ipc::DictionaryMemo memo;
- return VALUE_OR_STOP(arrow::ipc::ReadRecordBatch(
+ return ValueOrStop(arrow::ipc::ReadRecordBatch(
schema, &memo, arrow::ipc::IpcReadOptions::Defaults(), stream.get()));
}
@@ -223,7 +223,7 @@ Status count_fields(SEXP lst, int* out) {
std::shared_ptr<arrow::RecordBatch> RecordBatch__from_arrays__known_schema(
const std::shared_ptr<arrow::Schema>& schema, SEXP lst) {
int num_fields;
- STOP_IF_NOT_OK(arrow::r::count_fields(lst, &num_fields));
+ StopIfNotOk(arrow::r::count_fields(lst, &num_fields));
if (schema->num_fields() != num_fields) {
Rcpp::stop("incompatible. schema has %d fields, and %d arrays are supplied",
@@ -258,7 +258,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatch__from_arrays__known_schema(
}
int64_t num_rows = 0;
- STOP_IF_NOT_OK(arrow::r::check_consistent_array_size(arrays, &num_rows));
+ StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows));
return arrow::RecordBatch::Make(schema, num_rows, arrays);
}
@@ -270,7 +270,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatch__from_arrays(SEXP schema_sxp, SE
}
int num_fields;
- STOP_IF_NOT_OK(arrow::r::count_fields(lst, &num_fields));
+ StopIfNotOk(arrow::r::count_fields(lst, &num_fields));
// convert lst to a vector of arrow::Array
std::vector<std::shared_ptr<arrow::Array>> arrays(num_fields);
@@ -307,7 +307,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatch__from_arrays(SEXP schema_sxp, SE
// check all sizes are the same
int64_t num_rows = 0;
- STOP_IF_NOT_OK(arrow::r::check_consistent_array_size(arrays, &num_rows));
+ StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows));
return arrow::RecordBatch::Make(schema, num_rows, arrays);
}
diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp
index 3fce4d0..2405bf8 100644
--- a/r/src/recordbatchreader.cpp
+++ b/r/src/recordbatchreader.cpp
@@ -29,7 +29,7 @@ std::shared_ptr<arrow::Schema> RecordBatchReader__schema(
std::shared_ptr<arrow::RecordBatch> RecordBatchReader__ReadNext(
const std::shared_ptr<arrow::RecordBatchReader>& reader) {
std::shared_ptr<arrow::RecordBatch> batch;
- STOP_IF_NOT_OK(reader->ReadNext(&batch));
+ StopIfNotOk(reader->ReadNext(&batch));
return batch;
}
@@ -39,7 +39,7 @@ std::shared_ptr<arrow::RecordBatch> RecordBatchReader__ReadNext(
std::shared_ptr<arrow::RecordBatchReader> ipc___RecordBatchStreamReader__Open(
const std::shared_ptr<arrow::io::InputStream>& stream) {
std::shared_ptr<arrow::RecordBatchReader> reader;
- return VALUE_OR_STOP(arrow::ipc::RecordBatchStreamReader::Open(stream));
+ return ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream));
}
// [[arrow::export]]
@@ -49,7 +49,7 @@ std::vector<std::shared_ptr<arrow::RecordBatch>> ipc___RecordBatchStreamReader__
while (true) {
std::shared_ptr<arrow::RecordBatch> batch;
- STOP_IF_NOT_OK(reader->ReadNext(&batch));
+ StopIfNotOk(reader->ReadNext(&batch));
if (!batch) break;
res.push_back(batch);
@@ -78,14 +78,14 @@ std::shared_ptr<arrow::RecordBatch> ipc___RecordBatchFileReader__ReadRecordBatch
if (i < 0 && i >= reader->num_record_batches()) {
Rcpp::stop("Record batch index out of bounds");
}
- return VALUE_OR_STOP(reader->ReadRecordBatch(i));
+ return ValueOrStop(reader->ReadRecordBatch(i));
}
// [[arrow::export]]
std::shared_ptr<arrow::ipc::RecordBatchFileReader> ipc___RecordBatchFileReader__Open(
const std::shared_ptr<arrow::io::RandomAccessFile>& file) {
std::shared_ptr<arrow::ipc::RecordBatchFileReader> reader;
- return VALUE_OR_STOP(arrow::ipc::RecordBatchFileReader::Open(file));
+ return ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file));
}
// [[arrow::export]]
@@ -94,10 +94,10 @@ std::shared_ptr<arrow::Table> Table__from_RecordBatchFileReader(
int num_batches = reader->num_record_batches();
std::vector<std::shared_ptr<arrow::RecordBatch>> batches(num_batches);
for (int i = 0; i < num_batches; i++) {
- batches[i] = VALUE_OR_STOP(reader->ReadRecordBatch(i));
+ batches[i] = ValueOrStop(reader->ReadRecordBatch(i));
}
- return VALUE_OR_STOP(arrow::Table::FromRecordBatches(std::move(batches)));
+ return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches)));
}
// [[arrow::export]]
@@ -106,12 +106,12 @@ std::shared_ptr<arrow::Table> Table__from_RecordBatchStreamReader(
std::shared_ptr<arrow::RecordBatch> batch;
std::vector<std::shared_ptr<arrow::RecordBatch>> batches;
while (true) {
- STOP_IF_NOT_OK(reader->ReadNext(&batch));
+ StopIfNotOk(reader->ReadNext(&batch));
if (!batch) break;
batches.push_back(batch);
}
- return VALUE_OR_STOP(arrow::Table::FromRecordBatches(std::move(batches)));
+ return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches)));
}
// [[arrow::export]]
@@ -121,7 +121,7 @@ std::vector<std::shared_ptr<arrow::RecordBatch>> ipc___RecordBatchFileReader__ba
std::vector<std::shared_ptr<arrow::RecordBatch>> res(n);
for (int i = 0; i < n; i++) {
- res[i] = VALUE_OR_STOP(reader->ReadRecordBatch(i));
+ res[i] = ValueOrStop(reader->ReadRecordBatch(i));
}
return res;
diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp
index c6ff171..847b335 100644
--- a/r/src/recordbatchwriter.cpp
+++ b/r/src/recordbatchwriter.cpp
@@ -23,20 +23,20 @@
void ipc___RecordBatchWriter__WriteRecordBatch(
const std::shared_ptr<arrow::ipc::RecordBatchWriter>& batch_writer,
const std::shared_ptr<arrow::RecordBatch>& batch) {
- STOP_IF_NOT_OK(batch_writer->WriteRecordBatch(*batch));
+ StopIfNotOk(batch_writer->WriteRecordBatch(*batch));
}
// [[arrow::export]]
void ipc___RecordBatchWriter__WriteTable(
const std::shared_ptr<arrow::ipc::RecordBatchWriter>& batch_writer,
const std::shared_ptr<arrow::Table>& table) {
- STOP_IF_NOT_OK(batch_writer->WriteTable(*table));
+ StopIfNotOk(batch_writer->WriteTable(*table));
}
// [[arrow::export]]
void ipc___RecordBatchWriter__Close(
const std::shared_ptr<arrow::ipc::RecordBatchWriter>& batch_writer) {
- STOP_IF_NOT_OK(batch_writer->Close());
+ StopIfNotOk(batch_writer->Close());
}
// [[arrow::export]]
@@ -45,7 +45,7 @@ std::shared_ptr<arrow::ipc::RecordBatchWriter> ipc___RecordBatchFileWriter__Open
const std::shared_ptr<arrow::Schema>& schema, bool use_legacy_format) {
auto options = arrow::ipc::IpcWriteOptions::Defaults();
options.write_legacy_ipc_format = use_legacy_format;
- return VALUE_OR_STOP(arrow::ipc::NewFileWriter(stream.get(), schema, options));
+ return ValueOrStop(arrow::ipc::NewFileWriter(stream.get(), schema, options));
}
// [[arrow::export]]
@@ -54,7 +54,7 @@ std::shared_ptr<arrow::ipc::RecordBatchWriter> ipc___RecordBatchStreamWriter__Op
const std::shared_ptr<arrow::Schema>& schema, bool use_legacy_format) {
auto options = arrow::ipc::IpcWriteOptions::Defaults();
options.write_legacy_ipc_format = use_legacy_format;
- return VALUE_OR_STOP(NewStreamWriter(stream.get(), schema, options));
+ return ValueOrStop(NewStreamWriter(stream.get(), schema, options));
}
#endif
diff --git a/r/src/schema.cpp b/r/src/schema.cpp
index af74731..35de151 100644
--- a/r/src/schema.cpp
+++ b/r/src/schema.cpp
@@ -85,7 +85,7 @@ std::shared_ptr<arrow::Schema> Schema__WithMetadata(
Rcpp::RawVector Schema__serialize(const std::shared_ptr<arrow::Schema>& schema) {
arrow::ipc::DictionaryMemo empty_memo;
std::shared_ptr<arrow::Buffer> out =
- VALUE_OR_STOP(arrow::ipc::SerializeSchema(*schema, &empty_memo));
+ ValueOrStop(arrow::ipc::SerializeSchema(*schema, &empty_memo));
auto n = out->size();
Rcpp::RawVector vec(out->size());
@@ -103,7 +103,7 @@ bool Schema__Equals(const std::shared_ptr<arrow::Schema>& schema,
// [[arrow::export]]
std::shared_ptr<arrow::Schema> arrow__UnifySchemas(
const std::vector<std::shared_ptr<arrow::Schema>>& schemas) {
- return VALUE_OR_STOP(arrow::UnifySchemas(schemas));
+ return ValueOrStop(arrow::UnifySchemas(schemas));
}
#endif
diff --git a/r/src/table.cpp b/r/src/table.cpp
index 2b9fc4f..2681548 100644
--- a/r/src/table.cpp
+++ b/r/src/table.cpp
@@ -28,7 +28,7 @@ using Rcpp::DataFrame;
std::shared_ptr<arrow::Table> Table__from_dataframe(DataFrame tbl) {
auto rb = RecordBatch__from_dataframe(tbl);
- return VALUE_OR_STOP(arrow::Table::FromRecordBatches({std::move(rb)}));
+ return ValueOrStop(arrow::Table::FromRecordBatches({std::move(rb)}));
}
// [[arrow::export]]
@@ -97,13 +97,13 @@ bool Table__Equals(const std::shared_ptr<arrow::Table>& lhs,
// [[arrow::export]]
bool Table__Validate(const std::shared_ptr<arrow::Table>& table) {
- STOP_IF_NOT_OK(table->Validate());
+ StopIfNotOk(table->Validate());
return true;
}
// [[arrow::export]]
bool Table__ValidateFull(const std::shared_ptr<arrow::Table>& table) {
- STOP_IF_NOT_OK(table->ValidateFull());
+ StopIfNotOk(table->ValidateFull());
return true;
}
@@ -150,15 +150,15 @@ std::shared_ptr<arrow::Table> Table__from_dots(SEXP lst, SEXP schema_sxp) {
if (Rf_inherits(schema_sxp, "Schema")) {
auto schema = arrow::r::extract<arrow::Schema>(schema_sxp);
- tab = VALUE_OR_STOP(arrow::Table::FromRecordBatches(schema, std::move(batches)));
+ tab = ValueOrStop(arrow::Table::FromRecordBatches(schema, std::move(batches)));
} else {
- tab = VALUE_OR_STOP(arrow::Table::FromRecordBatches(std::move(batches)));
+ tab = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches)));
}
return tab;
}
int num_fields;
- STOP_IF_NOT_OK(arrow::r::count_fields(lst, &num_fields));
+ StopIfNotOk(arrow::r::count_fields(lst, &num_fields));
std::vector<std::shared_ptr<arrow::ChunkedArray>> columns(num_fields);
std::shared_ptr<arrow::Schema> schema;
diff --git a/r/src/threadpool.cpp b/r/src/threadpool.cpp
index b7a8c82..0a2013d 100644
--- a/r/src/threadpool.cpp
+++ b/r/src/threadpool.cpp
@@ -45,7 +45,7 @@ int GetCpuThreadPoolCapacity() { return arrow::GetCpuThreadPoolCapacity(); }
//' @export
// [[arrow::export]]
void SetCpuThreadPoolCapacity(int threads) {
- STOP_IF_NOT_OK(arrow::SetCpuThreadPoolCapacity(threads));
+ StopIfNotOk(arrow::SetCpuThreadPoolCapacity(threads));
}
#endif