Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Google Tests for Arrow and Parquet writers #181

Merged
merged 10 commits into from
Dec 7, 2023
2 changes: 1 addition & 1 deletion ci-utils/envs/conda_cpp.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
z5py
libtiff
libtiff <=4.5.0
boost >=1.63
nlohmann_json
blosc
Expand Down
1 change: 1 addition & 0 deletions src/nyx/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace Nyxus

std::vector<std::tuple<std::vector<std::string>, int, std::vector<double>>> get_feature_values();
std::vector<std::string> get_header(const std::vector<std::tuple<std::string, AvailableFeatures>>& F );
std::string get_arrow_filename(const std::string& output_path, const std::string& default_filename, const SaveOption& arrow_file_type);

void init_feature_buffers();
void clear_feature_buffers();
Expand Down
38 changes: 23 additions & 15 deletions src/nyx/output_writers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ arrow::Status ParquetWriter::setup(const std::vector<std::string> &header) {

fields.push_back(arrow::field(header[0], arrow::utf8()));
fields.push_back(arrow::field(header[1], arrow::utf8()));
fields.push_back(arrow::field(header[2], arrow::int64()));
fields.push_back(arrow::field(header[2], arrow::int32()));
sameeul marked this conversation as resolved.
Show resolved Hide resolved

for (int i = 3; i < header.size(); ++i)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ arrow::Status ParquetWriter::write (const std::vector<std::tuple<std::vector<std

arrays.push_back(segmentation_array);

arrow::Int64Builder int_builder;
arrow::Int32Builder int_builder;
std::shared_ptr<arrow::Array> labels_array;
// construct label column
for (int i = 0; i < num_rows; ++i) {
Expand Down Expand Up @@ -168,26 +168,26 @@ arrow::Status ParquetWriter::write (const std::vector<std::tuple<std::vector<std
ARROW_ASSIGN_OR_RAISE(auto table,
arrow::Table::FromRecordBatches(schema_, {batch}));


std::cout << table->ToString() << std::endl;

ARROW_RETURN_NOT_OK(writer_->WriteTable(*table.get(), batch->num_rows()));



return arrow::Status::OK();
}

arrow::Status ParquetWriter::close () {
arrow::Status status = writer_->Close();
auto status = writer_->Close();

if (!status.ok()) {
// Handle read error
return status;
}
return arrow::Status::OK();

if (!status.ok()) {
// Handle read error
return status;
}

status = output_stream_->Close();

if (!status.ok()) {
// Handle read error
return status;
}

return arrow::Status::OK();
}

Expand All @@ -198,7 +198,7 @@ arrow::Status ArrowIPCWriter::setup(const std::vector<std::string> &header) {

fields.push_back(arrow::field("intensity_image", arrow::utf8()));
fields.push_back(arrow::field("segmentation_image", arrow::utf8()));
fields.push_back(arrow::field("ROI_label", arrow::int64()));
fields.push_back(arrow::field("ROI_label", arrow::int32()));

for (int i = 3; i < header.size(); ++i)
{
Expand Down Expand Up @@ -342,6 +342,14 @@ arrow::Status ArrowIPCWriter::close () {
// Handle read error
return status;
}

status = output_stream_->Close();

if (!status.ok()) {
// Handle read error
return status;
}

return arrow::Status::OK();

}
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ endif()

target_include_directories (runAllTests PUBLIC ${GTEST_INCLUDE_DIRS})
target_link_directories (runAllTests PUBLIC ${GTEST_LIBRARY_PATH})
target_link_libraries (runAllTests PUBLIC gtest ${Nyxus_LIBRARIES})
target_link_libraries (runAllTests PUBLIC gtest ${Nyxus_LIBRARIES})
14 changes: 14 additions & 0 deletions tests/test_all.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
#include "test_glszm.h"
#include "test_ngtdm.h"
#include "test_roi_blacklist.h"
#include "test_arrow.h"
#include "test_arrow_file_name.h"

TEST(TEST_NYXUS, TEST_ARROW_FILE_NAME) {
test_file_naming();
}

TEST(TEST_NYXUS, TEST_ARROW) {
test_arrow();
}

TEST(TEST_NYXUS, TEST_PARQUET) {
test_parquet();
}

TEST(TEST_NYXUS, TEST_GABOR){
test_gabor();
Expand Down
Loading