Skip to content

Commit

Permalink
feat: make apache-arrow ORC extension optional (#558)
Browse files Browse the repository at this point in the history
* add macro guard for arrow-orc.

* tests revision.

* trigger CI again.

* make ci error info consistent.

* fix a bug on ubuntu.
  • Loading branch information
yecol authored Jul 29, 2024
1 parent d5442cd commit 6a13df3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
echo "|"
echo "| Run: "
echo "|"
echo "| make clformat"
echo "| make graphar-clformat"
echo "|"
echo "| to fix this error."
echo "|"
Expand All @@ -124,7 +124,7 @@ jobs:
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| cpplint failures found! Run: "
echo "|"
echo "| make vineyard_cpplint"
echo "| make graphar-cpplint"
echo "|"
echo "| to fix this error."
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Expand Down
4 changes: 3 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ if (${Arrow_VERSION} VERSION_GREATER_EQUAL "12.0.0")
endif()
# Check if ORC is enabled.
if (NOT ${ARROW_ORC})
message(FATAL_ERROR "apache-arrow ORC extension is required.")
message(WARNING "apache-arrow is built without ORC extension, ORC related functionalities will be disabled.")
else()
add_definitions(-DARROW_ORC) # Add macro, otherwise inconsistent in build phase on ubuntu.
endif()

find_package(Parquet QUIET)
Expand Down
10 changes: 8 additions & 2 deletions cpp/src/graphar/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

#ifdef ARROW_ORC
#include "arrow/adapters/orc/adapter.h"
#endif
#include "arrow/api.h"
#include "arrow/csv/api.h"
#include "arrow/dataset/api.h"
Expand Down Expand Up @@ -89,10 +91,12 @@ std::shared_ptr<ds::FileFormat> FileSystem::GetFileFormat(
return std::make_shared<ds::CsvFileFormat>();
case PARQUET:
return std::make_shared<ds::ParquetFileFormat>();
case ORC:
return std::make_shared<ds::OrcFileFormat>();
case JSON:
return std::make_shared<ds::JsonFileFormat>();
#ifdef ARROW_ORC
case ORC:
return std::make_shared<ds::OrcFileFormat>();
#endif
default:
return nullptr;
}
Expand Down Expand Up @@ -233,6 +237,7 @@ Status FileSystem::WriteTableToFile(const std::shared_ptr<arrow::Table>& table,
builder.build(), parquet::default_arrow_writer_properties()));
break;
}
#ifdef ARROW_ORC
case FileType::ORC: {
auto writer_options = arrow::adapters::orc::WriteOptions();
writer_options.compression = arrow::Compression::type::ZSTD;
Expand All @@ -243,6 +248,7 @@ Status FileSystem::WriteTableToFile(const std::shared_ptr<arrow::Table>& table,
RETURN_NOT_ARROW_OK(writer->Close());
break;
}
#endif
default:
return Status::Invalid(
"Unsupported file type: ", FileTypeToString(file_type), " for wrting.");
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/graphar/reader_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

#ifdef ARROW_ORC
#include "arrow/adapters/orc/adapter.h"
#endif
#include "arrow/api.h"
#include "arrow/csv/api.h"
#include "arrow/filesystem/api.h"
Expand Down
4 changes: 4 additions & 0 deletions cpp/test/test_arrow_chunk_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include <sstream>
#include <string>

#ifdef ARROW_ORC
#include "arrow/adapters/orc/adapter.h"
#endif
#include "arrow/api.h"
#include "arrow/csv/api.h"
#include "arrow/filesystem/api.h"
Expand Down Expand Up @@ -112,6 +114,7 @@ TEST_CASE_METHOD(GlobalFixture, "TestVertexPropertyWriter") {
auto pg3 = vertex_info->GetPropertyGroup("id");
REQUIRE(writer->WriteTable(tmp_table, pg3, 0).IsTypeError());

#ifdef ARROW_ORC
SECTION("TestOrcParquetReader") {
arrow::Status st;
arrow::MemoryPool* pool = arrow::default_memory_pool();
Expand Down Expand Up @@ -150,6 +153,7 @@ TEST_CASE_METHOD(GlobalFixture, "TestVertexPropertyWriter") {
REQUIRE(table1->GetColumnByName("gender")->ToString() ==
table2->GetColumnByName("gender")->ToString());
}
#endif

SECTION("TestEdgeChunkWriter") {
arrow::Status st;
Expand Down
1 change: 0 additions & 1 deletion cpp/test/test_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sstream>
#include <string>

#include "arrow/adapters/orc/adapter.h"
#include "arrow/api.h"
#include "arrow/csv/api.h"
#include "arrow/filesystem/api.h"
Expand Down

0 comments on commit 6a13df3

Please sign in to comment.