Skip to content

Commit 3955ab4

Browse files
authored
chore: fix clang compiler issue on Mac OS (PolusAI#290)
1 parent bdb7d7f commit 3955ab4

File tree

2 files changed

+25
-50
lines changed

2 files changed

+25
-50
lines changed

.github/workflows/build_and_test_mac.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install Conda Dependencies
3535
run: |
3636
conda install mamba
37-
mamba install compilers --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt
37+
mamba install compilers=1.10.0 --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt
3838
3939
- name: Configure CMake
4040
run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_CLI=ON -DRUN_GTEST=ON -DALLEXTRAS=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
@@ -71,7 +71,7 @@ jobs:
7171
- name: Install Conda Dependencies
7272
run: |
7373
conda install mamba
74-
mamba install compilers pytest bfio --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt --file ${{github.workspace}}/ci-utils/envs/conda_py.txt
74+
mamba install compilers=1.10.0 pytest bfio --file ${{github.workspace}}/ci-utils/envs/conda_cpp.txt --file ${{github.workspace}}/ci-utils/envs/conda_py.txt
7575
7676
- name: Install Nyxus
7777
working-directory: ${{github.workspace}}

tests/test_arrow.h

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <arrow/api.h>
66
#include <arrow/io/api.h>
7+
#include <arrow/status.h>
78
#include <parquet/arrow/reader.h>
89
#include <parquet/arrow/writer.h>
910
#include <parquet/exception.h>
@@ -29,74 +30,40 @@
2930
error "Missing the <filesystem> header."
3031
#endif
3132

32-
std::shared_ptr<arrow::Table> get_arrow_table(const std::string& file_path) {
33-
33+
arrow::Result<std::shared_ptr<arrow::Table>> get_arrow_table(const std::string& file_path) {
3434
auto file_extension = fs::path(file_path).extension().u8string();
3535

3636
if (file_extension == ".parquet") {
3737
arrow::MemoryPool* pool = arrow::default_memory_pool();
3838

39-
std::shared_ptr<arrow::io::RandomAccessFile> input;
39+
ARROW_ASSIGN_OR_RAISE(auto input, arrow::io::ReadableFile::Open(file_path));
4040

41-
//auto status = this->open(input, file_path);
42-
input = arrow::io::ReadableFile::Open(file_path).ValueOrDie();
43-
4441
std::unique_ptr<parquet::arrow::FileReader> arrow_reader;
42+
ARROW_ASSIGN_OR_RAISE(arrow_reader, parquet::arrow::OpenFile(input, pool));
4543

46-
auto status = parquet::arrow::OpenFile(input, pool, &arrow_reader);
47-
48-
if (!status.ok()) {
49-
// Handle read error
50-
auto err = status.ToString();
51-
throw std::runtime_error("Error reading Arrow file: " + err);
52-
}
53-
54-
// Read entire file as a single Arrow table
5544
std::shared_ptr<arrow::Table> table;
56-
57-
status = arrow_reader->ReadTable(&table);
58-
59-
if (!status.ok()) {
60-
// Handle read error
61-
auto err = status.ToString();
62-
throw std::runtime_error("Error reading Arrow file: " + err);
63-
}
45+
ARROW_RETURN_NOT_OK(arrow_reader->ReadTable(&table));
6446

6547
return table;
6648

6749
} else if (file_extension == ".arrow") {
68-
69-
// Create a memory-mapped file for reading.
70-
71-
std::shared_ptr<arrow::io::ReadableFile> input;
72-
73-
input = arrow::io::ReadableFile::Open(file_path).ValueOrDie();
50+
ARROW_ASSIGN_OR_RAISE(auto input, arrow::io::ReadableFile::Open(file_path));
7451

75-
// Create an IPC reader.
76-
auto result = arrow::ipc::RecordBatchFileReader::Open(input.get());
77-
78-
if (!result.ok()) {
79-
std::cerr << "Error opening IPC file: " << result.status().ToString() << std::endl;
80-
}
52+
std::shared_ptr<arrow::ipc::RecordBatchFileReader> reader;
53+
ARROW_ASSIGN_OR_RAISE(reader, arrow::ipc::RecordBatchFileReader::Open(input.get()));
8154

8255
std::vector<std::shared_ptr<arrow::RecordBatch>> batches;
83-
84-
auto reader = result.ValueOrDie();
85-
86-
for(int i = 0; i < reader->num_record_batches(); ++i) {
87-
auto batch = reader->ReadRecordBatch(i).ValueOrDie();
88-
56+
for (int i = 0; i < reader->num_record_batches(); ++i) {
57+
ARROW_ASSIGN_OR_RAISE(auto batch, reader->ReadRecordBatch(i));
8958
batches.push_back(batch);
9059
}
9160

92-
auto table = arrow::Table::FromRecordBatches(batches).ValueOrDie();
93-
61+
ARROW_ASSIGN_OR_RAISE(auto table, arrow::Table::FromRecordBatches(batches));
9462
return table;
95-
63+
9664
} else {
97-
throw std::invalid_argument("Error: file must either be an Arrow or Parquet file.");
65+
return arrow::Status::Invalid("Error: file must either be an Arrow or Parquet file.");
9866
}
99-
10067
}
10168

10269
std::shared_ptr<arrow::Table> create_features_table(const std::vector<std::string> &header,
@@ -253,7 +220,11 @@ void test_arrow() {
253220
FAIL() << "Error closing Arrow file: " << msg2.value() << std::endl;
254221
}
255222

256-
auto results_table = get_arrow_table(outputPath);
223+
auto results_table_result = get_arrow_table(outputPath);
224+
if (!results_table_result.ok()) {
225+
FAIL() << "Error reading Arrow file: " << results_table_result.status().ToString() << std::endl;
226+
}
227+
auto results_table = results_table_result.ValueOrDie();
257228

258229
auto& row_data = std::get<1>(features);
259230
std::vector<std::string> string_columns;
@@ -319,7 +290,11 @@ void test_parquet() {
319290
FAIL() << "Error closing Arrow file: " << msg2.value() << std::endl;
320291
}
321292

322-
auto results_table = get_arrow_table(outputPath);
293+
auto results_table_result = get_arrow_table(outputPath);
294+
if (!results_table_result.ok()) {
295+
FAIL() << "Error reading Parquet file: " << results_table_result.status().ToString() << std::endl;
296+
}
297+
auto results_table = results_table_result.ValueOrDie();
323298

324299
auto& row_data = std::get<1>(features);
325300
std::vector<std::string> string_columns;

0 commit comments

Comments
 (0)