C Interfaces

See also

The C data interface and C stream interface specifications.

ABI Structures

struct ArrowSchema
struct ArrowArray
struct ArrowArrayStream

C Data Interface

Status ExportType(const DataType &type, struct ArrowSchema *out)

Export C++ DataType using the C data interface format.

The root type is considered to have empty name and metadata. If you want the root type to have a name and/or metadata, pass a Field instead.

Parameters
  • [in] type: DataType object to export

  • [out] out: C struct where to export the datatype

Status ExportField(const Field &field, struct ArrowSchema *out)

Export C++ Field using the C data interface format.

Parameters
  • [in] field: Field object to export

  • [out] out: C struct where to export the field

Status ExportSchema(const Schema &schema, struct ArrowSchema *out)

Export C++ Schema using the C data interface format.

Parameters
  • [in] schema: Schema object to export

  • [out] out: C struct where to export the field

Status ExportArray(const Array &array, struct ArrowArray *out, struct ArrowSchema *out_schema = NULLPTR)

Export C++ Array using the C data interface format.

The resulting ArrowArray struct keeps the array data and buffers alive until its release callback is called by the consumer.

Parameters
  • [in] array: Array object to export

  • [out] out: C struct where to export the array

  • [out] out_schema: optional C struct where to export the array type

Status ExportRecordBatch(const RecordBatch &batch, struct ArrowArray *out, struct ArrowSchema *out_schema = NULLPTR)

Export C++ RecordBatch using the C data interface format.

The record batch is exported as if it were a struct array. The resulting ArrowArray struct keeps the record batch data and buffers alive until its release callback is called by the consumer.

Parameters
  • [in] batch: Record batch to export

  • [out] out: C struct where to export the record batch

  • [out] out_schema: optional C struct where to export the record batch schema

Result<std::shared_ptr<DataType>> ImportType(struct ArrowSchema *schema)

Import C++ DataType from the C data interface.

The given ArrowSchema struct is released (as per the C data interface specification), even if this function fails.

Return

Imported type object

Parameters
  • [inout] schema: C data interface struct representing the data type

Result<std::shared_ptr<Field>> ImportField(struct ArrowSchema *schema)

Import C++ Field from the C data interface.

The given ArrowSchema struct is released (as per the C data interface specification), even if this function fails.

Return

Imported field object

Parameters
  • [inout] schema: C data interface struct representing the field

Result<std::shared_ptr<Schema>> ImportSchema(struct ArrowSchema *schema)

Import C++ Schema from the C data interface.

The given ArrowSchema struct is released (as per the C data interface specification), even if this function fails.

Return

Imported field object

Parameters
  • [inout] schema: C data interface struct representing the field

Result<std::shared_ptr<Array>> ImportArray(struct ArrowArray *array, std::shared_ptr<DataType> type)

Import C++ array from the C data interface.

The ArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting array.

Return

Imported array object

Parameters
  • [inout] array: C data interface struct holding the array data

  • [in] type: type of the imported array

Result<std::shared_ptr<Array>> ImportArray(struct ArrowArray *array, struct ArrowSchema *type)

Import C++ array and its type from the C data interface.

The ArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting array. The ArrowSchema struct is released, even if this function fails.

Return

Imported array object

Parameters
  • [inout] array: C data interface struct holding the array data

  • [inout] type: C data interface struct holding the array type

Result<std::shared_ptr<RecordBatch>> ImportRecordBatch(struct ArrowArray *array, std::shared_ptr<Schema> schema)

Import C++ record batch from the C data interface.

The ArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting record batch.

Return

Imported record batch object

Parameters
  • [inout] array: C data interface struct holding the record batch data

  • [in] schema: schema of the imported record batch

Result<std::shared_ptr<RecordBatch>> ImportRecordBatch(struct ArrowArray *array, struct ArrowSchema *schema)

Import C++ record batch and its schema from the C data interface.

The type represented by the ArrowSchema struct must be a struct type array. The ArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting record batch. The ArrowSchema struct is released, even if this function fails.

Return

Imported record batch object

Parameters
  • [inout] array: C data interface struct holding the record batch data

  • [inout] schema: C data interface struct holding the record batch schema

C Stream Interface

Status ExportRecordBatchReader(std::shared_ptr<RecordBatchReader> reader, struct ArrowArrayStream *out)

EXPERIMENTAL: Export C++ RecordBatchReader using the C stream interface.

The resulting ArrowArrayStream struct keeps the record batch reader alive until its release callback is called by the consumer.

Parameters
  • [in] reader: RecordBatchReader object to export

  • [out] out: C struct where to export the stream

Result<std::shared_ptr<RecordBatchReader>> ImportRecordBatchReader(struct ArrowArrayStream *stream)

EXPERIMENTAL: Import C++ RecordBatchReader from the C stream interface.

The ArrowArrayStream struct has its contents moved to a private object held alive by the resulting record batch reader.

Return

Imported RecordBatchReader object

Parameters
  • [inout] stream: C stream interface struct