Conventions#

The Arrow C++ API follows a few simple guidelines. As with many rules,there may be exceptions.

Language version#

Starting with version 10.0, Arrow C++ is C++17-compatible.

Namespacing#

All the Arrow API (except macros) is namespaced inside aarrow namespace,and nested namespaces thereof.

Safe pointers#

Arrow objects are usually passed and stored using safe pointers – most ofthe timestd::shared_ptr but sometimes alsostd::unique_ptr.

Immutability#

Many Arrow objects are immutable: once constructed, their logical propertiescannot change anymore. This makes it possible to use them in multi-threadedscenarios without requiring tedious and error-prone synchronization.

There are obvious exceptions to this, such as IO objects or mutable data buffers.

Error reporting#

Most APIs indicate a successful or erroneous outcome by returning aarrow::Status instance. Arrow doesn’t throw exceptions of itsown, but third-party exceptions might propagate through, especiallystd::bad_alloc (but Arrow doesn’t use the standard allocators forlarge data).

When an API can return either an error code or a successful value, it usuallydoes so by returning the template classarrow::Result. However,some APIs (usually deprecated) returnarrow::Status and pass theresult value as an out-pointer parameter.

Here is an example of checking the outcome of an operation:

constint64_tbuffer_size=4096;automaybe_buffer=arrow::AllocateBuffer(buffer_size,&buffer);if(!maybe_buffer.ok()){// ... handle error}else{std::shared_ptr<arrow::Buffer>buffer=*maybe_buffer;// ... use allocated buffer}

If the caller function itself returns aarrow::Result orarrow::Status and wants to propagate any non-successful outcome, twoconvenience macros are available:

For example:

arrow::StatusDoSomething(){constint64_tbuffer_size=4096;std::shared_ptr<arrow::Buffer>buffer;ARROW_ASSIGN_OR_RAISE(buffer,arrow::AllocateBuffer(buffer_size));// ... allocation successful, do something with buffer below// return success at the endreturnStatus::OK();}