Skip to content

Commit

Permalink
Don't discard Arrow's Status results. (#6)
Browse files Browse the repository at this point in the history
Fixes #3.
  • Loading branch information
matz-e authored May 13, 2024
1 parent 40c9d32 commit eb029ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target_link_libraries(TouchParquet
arrow_shared
parquet_shared
range-v3)
target_compile_options(TouchParquet PRIVATE -Werror=unused-result)

add_library(CircuitParquet STATIC ${CIRCUIT_SRCS})
target_include_directories(CircuitParquet PUBLIC
Expand All @@ -29,6 +30,7 @@ target_link_libraries(CircuitParquet
nlohmann_json::nlohmann_json
HighFive
range-v3)
target_compile_options(CircuitParquet PRIVATE -Werror=unused-result)

add_executable(touch2parquet touch2parquet.cpp)
target_link_libraries(touch2parquet
Expand Down
10 changes: 8 additions & 2 deletions src/circuit/parquet_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ void CircuitReaderParquet::init_data_reader() {
reader_ = parquet::ParquetFileReader::OpenFile(filename_, false);
}
// NOTE that reader is unique. We must give it up to the other reader
parquet::arrow::FileReader::Make(arrow::default_memory_pool(), std::move(reader_), &data_reader_);
const auto status = parquet::arrow::FileReader::Make(arrow::default_memory_pool(), std::move(reader_), &data_reader_);
if (!status.ok()) {
throw std::runtime_error(status.ToString());
}
cur_row_group_ = 0;
}

Expand All @@ -66,7 +69,10 @@ uint32_t CircuitReaderParquet::fillBuffer(CircuitData* buf, uint32_t length) {
return 0;
}

data_reader_->ReadRowGroup(cur_row_group_++, &(buf->row_group));
const auto status = data_reader_->ReadRowGroup(cur_row_group_++, &(buf->row_group));
if (!status.ok()) {
throw std::runtime_error(status.ToString());
}
return (uint32_t) buf->row_group->num_rows();
}

Expand Down
5 changes: 4 additions & 1 deletion src/touches/parquet_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ TouchWriterParquet::~TouchWriterParquet() {
_writeBuffer(_buffer_offset);
}
file_writer->Close();
out_file->Close();
const auto status = out_file->Close();
if (!status.ok()) {
std::clog << status.ToString() << std::endl;
}
}


Expand Down

0 comments on commit eb029ed

Please sign in to comment.