C++ API Reference#

group nanoarrow_hpp

The utilities provided in this file are intended to support C++ users of the nanoarrow C library such that C++-style resource allocation and error handling can be used with nanoarrow data structures. These utilities are not intended to mirror the nanoarrow C API.

Error handling#

group nanoarrow_hpp-errors

Most functions in the C API return an ArrowErrorCode to communicate possible failure. Except where documented, it is usually not safe to continue after a non-zero value has been returned. While the nanoarrow C++ helpers do not throw any exceptions of their own, these helpers are provided to facilitate using the nanoarrow C++ helpers in frameworks where this is a useful error handling idiom.

Defines

_NANOARROW_THROW_NOT_OK_IMPL(NAME, EXPR, EXPR_STR)#
NANOARROW_THROW_NOT_OK(EXPR)#
class Exception : public std::exception#

Owning object wrappers#

group nanoarrow_hpp-unique

The Arrow C Data interface, the Arrow C Stream interface, and the nanoarrow C library use stack-allocatable objects, some of which require initialization or cleanup.

Typedefs

using UniqueSchema = internal::Unique<struct ArrowSchema>#

Class wrapping a unique struct ArrowSchema.

using UniqueArray = internal::Unique<struct ArrowArray>#

Class wrapping a unique struct ArrowArray.

using UniqueArrayStream = internal::Unique<struct ArrowArrayStream>#

Class wrapping a unique struct ArrowArrayStream.

using UniqueBuffer = internal::Unique<struct ArrowBuffer>#

Class wrapping a unique struct ArrowBuffer.

using UniqueBitmap = internal::Unique<struct ArrowBitmap>#

Class wrapping a unique struct ArrowBitmap.

using UniqueArrayView = internal::Unique<struct ArrowArrayView>#

Class wrapping a unique struct ArrowArrayView.

Array Stream utilities#

group nanoarrow_hpp-array-stream

These classes provide simple struct ArrowArrayStream implementations that can be extended to help simplify the process of creating a valid ArrowArrayStream implementation or used as-is for testing.

class EmptyArrayStream#
#include <nanoarrow.hpp>

An empty array stream.

This class can be constructed from an enum ArrowType or struct ArrowSchema and implements a default get_next() method that always marks the output ArrowArray as released. This class can be extended with an implementation of get_next() for a custom source.

Subclassed by nanoarrow::VectorArrayStream

Public Static Functions

static inline UniqueArrayStream MakeUnique(struct ArrowSchema *schema)#

Create an empty UniqueArrayStream from a struct ArrowSchema.

This object takes ownership of the schema and marks the source schema as released.

class VectorArrayStream : public nanoarrow::EmptyArrayStream#
#include <nanoarrow.hpp>

Implementation of an ArrowArrayStream backed by a vector of ArrowArray objects.

Public Static Functions

static inline UniqueArrayStream MakeUnique(struct ArrowSchema *schema, struct ArrowArray *array)#

Create a UniqueArrowArrayStream from an existing array.

Takes ownership of the schema and the array.

static inline UniqueArrayStream MakeUnique(struct ArrowSchema *schema, std::vector<UniqueArray> arrays)#

Create a UniqueArrowArrayStream from existing arrays.

This object takes ownership of the schema and arrays.

Base classes and utilities#

group nanoarrow_hpp-unique_base

Functions

static inline void init_pointer(struct ArrowSchema *data)#
static inline void move_pointer(struct ArrowSchema *src, struct ArrowSchema *dst)#
static inline void release_pointer(struct ArrowSchema *data)#
static inline void init_pointer(struct ArrowArray *data)#
static inline void move_pointer(struct ArrowArray *src, struct ArrowArray *dst)#
static inline void release_pointer(struct ArrowArray *data)#
static inline void init_pointer(struct ArrowArrayStream *data)#
static inline void move_pointer(struct ArrowArrayStream *src, struct ArrowArrayStream *dst)#
static inline void release_pointer(ArrowArrayStream *data)#
static inline void init_pointer(struct ArrowBuffer *data)#
static inline void move_pointer(struct ArrowBuffer *src, struct ArrowBuffer *dst)#
static inline void release_pointer(struct ArrowBuffer *data)#
static inline void init_pointer(struct ArrowBitmap *data)#
static inline void move_pointer(struct ArrowBitmap *src, struct ArrowBitmap *dst)#
static inline void release_pointer(struct ArrowBitmap *data)#
static inline void init_pointer(struct ArrowArrayView *data)#
static inline void move_pointer(struct ArrowArrayView *src, struct ArrowArrayView *dst)#
static inline void release_pointer(struct ArrowArrayView *data)#
template<typename T>
class Unique#
#include <nanoarrow.hpp>

A unique_ptr-like base class for stack-allocatable objects.

Template Parameters:

T – The object type

Public Functions

inline Unique()#

Construct an invalid instance of T holding no resources.

inline Unique(T *data)#

Move and take ownership of data.

inline Unique(Unique &&rhs)#

Move and take ownership of data wrapped by rhs.

inline T *get() noexcept#

Get a pointer to the data owned by this object.

inline T *operator->()#

Use the pointer operator to access fields of this object.

inline void reset()#

Call data’s release callback if valid.

inline void reset(T *data)#

Call data’s release callback if valid and move ownership of the data pointed to by data.

inline void move(T *out)#

Move ownership of this object to the data pointed to by out.