diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index f9f7b0447c17b..c32d0640592b8 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,10 @@ 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); }); + + StopIfNotOk(result); return table; } @@ -146,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; } @@ -155,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; } @@ -164,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; } @@ -173,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; } @@ -199,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; }