This directory contains the code and build system for the GraphAr C++ library.
GraphAr C++ uses CMake as a build configuration system. We recommend building out-of-source. If you are not familiar with this terminology:
cmake
is invoked directly from the cpp
directory. This can be inflexible when you wish to maintain multiple build environments (e.g. one for debug builds and another for release builds)cmake
is invoked from another directory, creating an isolated build environment that does not interact with any other build environment. For example, you could create cpp/build-debug
and invoke cmake $CMAKE_ARGS ..
from this directoryBuilding requires:
make
build utilitiesarrow-dev
, arrow-dataset
, arrow-acero
and parquet
modules) for Arrow filesystem support. You can refer to Apache Arrow Installation to install the required modules.Dependencies for optional features:
clang-format-8
for code formattingOn Ubuntu/Debian, you can install the required packages with:
sudo apt-get install \ build-essential \ cmake \ libboost-graph-dev \ doxygen # Arrow C++ dependencies wget -c \ https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \ -P /tmp/ sudo apt-get install -y /tmp/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb sudo apt-get update sudo apt-get install -y libarrow-dev libarrow-dataset-dev libarrow-acero-dev libparquet-dev
On macOS, you can use Homebrew to install the required packages:
brew update && brew bundle --file=cpp/Brewfile
[!NOTE] Currently, the Arrow C++ library has disabled ARROW_ORC in the brew formula, so you need to build and install the Arrow C++ library manually (with
-DARROW_ORC=True
).
All the instructions below assume that you have cloned the GraphAr git repository and navigated to the cpp
subdirectory with:
git clone https://github.com/apache/incubator-graphar.git cd incubator-graphar/cpp
Release build:
mkdir build-release cd build-release cmake .. make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores
Debug build with unit tests:
mkdir build-debug cd build-debug cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON .. make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores
After building, you can run the unit tests with:
git clone https://github.com/apache/incubator-graphar-testing.git testing # download the testing data GAR_TEST_DATA=${PWD}/testing ctest
Build with examples, you should build the project with BUILD_EXAMPLES
option, then run:
make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores GAR_TEST_DATA=${PWD}/testing ./bgl_example # run the BGL example
Build with benchmarks, you should build the project with BUILD_BENCHMARKS
option, then run:
make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores GAR_TEST_DATA=${PWD}/testing ./graph_info_benchmark # run the graph info benchmark
Extra Build Options:
-DGRAPHAR_BUILD_STATIC=ON
: Build GraphAr as static libraries.-DUSE_STATIC_ARROW=ON
: Link arrow static library to build GraphAr. If set this option, the option GRAPHAR_BUILD_STATIC=ON
will be set.In case you want to build GraphAr as single static library including all dependencies, we include a apache-arrow.cmake file that allows you to build Arrow and its dependencies from source and link it statically. To do this, you can follow the steps below:
mkdir build-static cd build-static cmake -DGRAPHAR_BUILD_STATIC=ON -DBUILD_ARROW_FROM_SOURCE=ON .. make -j8 # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores
After the building, you can install the GraphAr C++ library with:
sudo make install # run in directory you build, like build-release, build and so on
You should build the project with ENABLE_DOCS
option. Then run:
make docs
The API document is generated in the directory docs_doxygen
.
To format and lint the code, run:
cmake .. make graphar-clformat # format the code make graphar-cpplint # lint the code
Please refer to our GraphAr C++ API Reference.