Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions r/src/parquet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "./arrow_types.h"

#include "./safe-call-into-r.h"

#if defined(ARROW_R_WITH_PARQUET)

#include <arrow/table.h>
Expand Down Expand Up @@ -129,7 +131,10 @@ std::shared_ptr<parquet::arrow::FileReader> parquet___arrow___FileReader__OpenFi
std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadTable1(
const std::shared_ptr<parquet::arrow::FileReader>& reader) {
std::shared_ptr<arrow::Table> table;
PARQUET_THROW_NOT_OK(reader->ReadTable(&table));
auto result =
RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadTable(&table); });

StopIfNotOk(result);
return table;
}

Expand All @@ -138,15 +143,21 @@ std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadTable2(
const std::shared_ptr<parquet::arrow::FileReader>& reader,
const std::vector<int>& column_indices) {
std::shared_ptr<arrow::Table> table;
PARQUET_THROW_NOT_OK(reader->ReadTable(column_indices, &table));
auto result = RunWithCapturedRIfPossibleVoid(
[&]() { return reader->ReadTable(column_indices, &table); });

StopIfNotOk(result);
return table;
}

// [[parquet::export]]
std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadRowGroup1(
const std::shared_ptr<parquet::arrow::FileReader>& reader, int i) {
std::shared_ptr<arrow::Table> table;
PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, &table));
auto result =
RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadRowGroup(i, &table); });

StopIfNotOk(result);
return table;
}

Expand All @@ -155,7 +166,10 @@ std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadRowGroup2(
const std::shared_ptr<parquet::arrow::FileReader>& reader, int i,
const std::vector<int>& column_indices) {
std::shared_ptr<arrow::Table> 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;
}

Expand All @@ -164,7 +178,10 @@ std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadRowGroups1(
const std::shared_ptr<parquet::arrow::FileReader>& reader,
const std::vector<int>& row_groups) {
std::shared_ptr<arrow::Table> table;
PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, &table));
auto result = RunWithCapturedRIfPossibleVoid(
[&]() { return reader->ReadRowGroups(row_groups, &table); });

StopIfNotOk(result);
return table;
}

Expand All @@ -173,7 +190,10 @@ std::shared_ptr<arrow::Table> parquet___arrow___FileReader__ReadRowGroups2(
const std::shared_ptr<parquet::arrow::FileReader>& reader,
const std::vector<int>& row_groups, const std::vector<int>& column_indices) {
std::shared_ptr<arrow::Table> 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;
}

Expand All @@ -199,7 +219,10 @@ int parquet___arrow___FileReader__num_row_groups(
std::shared_ptr<arrow::ChunkedArray> parquet___arrow___FileReader__ReadColumn(
const std::shared_ptr<parquet::arrow::FileReader>& reader, int i) {
std::shared_ptr<arrow::ChunkedArray> array;
PARQUET_THROW_NOT_OK(reader->ReadColumn(i - 1, &array));
auto result =
RunWithCapturedRIfPossibleVoid([&]() { return reader->ReadColumn(i - 1, &array); });

StopIfNotOk(result);
return array;
}

Expand Down