From 8c131f9caeb155a1c1504ff556d4a54506c8048f Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 21 Aug 2023 10:24:50 -0300 Subject: [PATCH 1/3] use runwithcapturedr for parquet reading, too --- r/src/parquet.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index f9f7b0447c17..a8c122ae2669 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -17,6 +17,8 @@ #include "./arrow_types.h" +#include "./safe-call-into-r.h" + #if defined(ARROW_R_WITH_PARQUET) #include @@ -129,7 +131,10 @@ std::shared_ptr parquet___arrow___FileReader__OpenFi std::shared_ptr parquet___arrow___FileReader__ReadTable1( const std::shared_ptr& reader) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadTable(&table)); + auto result = + RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadTable(&table); }); + + StopIfNotOk(result); return table; } @@ -138,7 +143,8 @@ std::shared_ptr parquet___arrow___FileReader__ReadTable2( const std::shared_ptr& reader, const std::vector& column_indices) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadTable(column_indices, &table)); + auto result = RunWithCapturedRIfPossibleVoid( + [&]() { return reader->ReadTable(column_indices, &table); }); return table; } From 67212a421d1e42c1ea46bcf3cb871125f4f9a095 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Wed, 23 Aug 2023 14:22:25 -0300 Subject: [PATCH 2/3] make sure to stop for bad result --- r/src/parquet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index a8c122ae2669..0f8ddf134a19 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -145,6 +145,7 @@ std::shared_ptr parquet___arrow___FileReader__ReadTable2( std::shared_ptr table; auto result = RunWithCapturedRIfPossibleVoid( [&]() { return reader->ReadTable(column_indices, &table); }); + StopIfNotOk(result); return table; } From 775db906f886c95a9778f2bb57ecfd1a78c9f398 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 28 Aug 2023 11:37:23 -0300 Subject: [PATCH 3/3] run all parquet reads through RunWithCapturedR --- r/src/parquet.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index 0f8ddf134a19..c32d0640592b 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -145,6 +145,7 @@ std::shared_ptr parquet___arrow___FileReader__ReadTable2( std::shared_ptr table; auto result = RunWithCapturedRIfPossibleVoid( [&]() { return reader->ReadTable(column_indices, &table); }); + StopIfNotOk(result); return table; } @@ -153,7 +154,10 @@ std::shared_ptr parquet___arrow___FileReader__ReadTable2( std::shared_ptr parquet___arrow___FileReader__ReadRowGroup1( const std::shared_ptr& reader, int i) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, &table)); + auto result = + RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadRowGroup(i, &table); }); + + StopIfNotOk(result); return table; } @@ -162,7 +166,10 @@ std::shared_ptr parquet___arrow___FileReader__ReadRowGroup2( const std::shared_ptr& reader, int i, const std::vector& column_indices) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, column_indices, &table)); + auto result = RunWithCapturedRIfPossibleVoid( + [&]() { return reader->ReadRowGroup(i, column_indices, &table); }); + + StopIfNotOk(result); return table; } @@ -171,7 +178,10 @@ std::shared_ptr parquet___arrow___FileReader__ReadRowGroups1( const std::shared_ptr& reader, const std::vector& row_groups) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, &table)); + auto result = RunWithCapturedRIfPossibleVoid( + [&]() { return reader->ReadRowGroups(row_groups, &table); }); + + StopIfNotOk(result); return table; } @@ -180,7 +190,10 @@ std::shared_ptr parquet___arrow___FileReader__ReadRowGroups2( const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices) { std::shared_ptr table; - PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, column_indices, &table)); + auto result = RunWithCapturedRIfPossibleVoid( + [&]() { return reader->ReadRowGroups(row_groups, column_indices, &table); }); + + StopIfNotOk(result); return table; } @@ -206,7 +219,10 @@ int parquet___arrow___FileReader__num_row_groups( std::shared_ptr parquet___arrow___FileReader__ReadColumn( const std::shared_ptr& reader, int i) { std::shared_ptr array; - PARQUET_THROW_NOT_OK(reader->ReadColumn(i - 1, &array)); + auto result = + RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadColumn(i - 1, &array); }); + + StopIfNotOk(result); return array; }