C Interfaces#
See also
TheC data interface andC stream interface specifications.
ABI Structures#
- structArrowSchema#
- structArrowArray#
- structArrowArrayStream#
C Data Interface#
- StatusExportType(constDataType&type,structArrowSchema*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 aField instead.
- Parameters:
type –[in]DataType object to export
out –[out] C struct where to export the datatype
- StatusExportField(constField&field,structArrowSchema*out)#
Export C++Field using the C data interface format.
- Parameters:
field –[in]Field object to export
out –[out] C struct where to export the field
- StatusExportSchema(constSchema&schema,structArrowSchema*out)#
Export C++Schema using the C data interface format.
- Parameters:
schema –[in]Schema object to export
out –[out] C struct where to export the field
- StatusExportArray(constArray&array,structArrowArray*out,structArrowSchema*out_schema=NULLPTR)#
Export C++Array using the C data interface format.
The resultingArrowArray struct keeps the array data and buffers alive until its release callback is called by the consumer.
- Parameters:
array –[in]Array object to export
out –[out] C struct where to export the array
out_schema –[out] optional C struct where to export the array type
- StatusExportRecordBatch(constRecordBatch&batch,structArrowArray*out,structArrowSchema*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 resultingArrowArray struct keeps the record batch data and buffers alive until its release callback is called by the consumer.
- Parameters:
batch –[in] Record batch to export
out –[out] C struct where to export the record batch
out_schema –[out] optional C struct where to export the record batch schema
- Result<std::shared_ptr<DataType>>ImportType(structArrowSchema*schema)#
Import C++DataType from the C data interface.
The givenArrowSchema struct is released (as per the C data interface specification), even if this function fails.
- Parameters:
schema –[inout] C data interface struct representing the data type
- Returns:
Imported type object
- Result<std::shared_ptr<Field>>ImportField(structArrowSchema*schema)#
Import C++Field from the C data interface.
The givenArrowSchema struct is released (as per the C data interface specification), even if this function fails.
- Parameters:
schema –[inout] C data interface struct representing the field
- Returns:
Imported field object
- Result<std::shared_ptr<Schema>>ImportSchema(structArrowSchema*schema)#
Import C++Schema from the C data interface.
The givenArrowSchema struct is released (as per the C data interface specification), even if this function fails.
- Parameters:
schema –[inout] C data interface struct representing the field
- Returns:
Imported field object
- Result<std::shared_ptr<Array>>ImportArray(structArrowArray*array,std::shared_ptr<DataType>type)#
Import C++ array from the C data interface.
TheArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting array.
- Parameters:
array –[inout] C data interface struct holding the array data
type –[in] type of the imported array
- Returns:
Imported array object
- Result<std::shared_ptr<Array>>ImportArray(structArrowArray*array,structArrowSchema*type)#
Import C++ array and its type from the C data interface.
TheArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting array. TheArrowSchema struct is released, even if this function fails.
- Parameters:
array –[inout] C data interface struct holding the array data
type –[inout] C data interface struct holding the array type
- Returns:
Imported array object
- Result<std::shared_ptr<RecordBatch>>ImportRecordBatch(structArrowArray*array,std::shared_ptr<Schema>schema)#
Import C++ record batch from the C data interface.
TheArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting record batch.
- Parameters:
array –[inout] C data interface struct holding the record batch data
schema –[in] schema of the imported record batch
- Returns:
Imported record batch object
- Result<std::shared_ptr<RecordBatch>>ImportRecordBatch(structArrowArray*array,structArrowSchema*schema)#
Import C++ record batch and its schema from the C data interface.
The type represented by theArrowSchema struct must be a struct type array. TheArrowArray struct has its contents moved (as per the C data interface specification) to a private object held alive by the resulting record batch. TheArrowSchema struct is released, even if this function fails.
- Parameters:
array –[inout] C data interface struct holding the record batch data
schema –[inout] C data interface struct holding the record batch schema
- Returns:
Imported record batch object
C Stream Interface#
- StatusExportRecordBatchReader(std::shared_ptr<RecordBatchReader>reader,structArrowArrayStream*out)#
Export C++RecordBatchReader using the C stream interface.
The resultingArrowArrayStream struct keeps the record batch reader alive until its release callback is called by the consumer.
- Parameters:
reader –[in]RecordBatchReader object to export
out –[out] C struct where to export the stream
- StatusExportChunkedArray(std::shared_ptr<ChunkedArray>chunked_array,structArrowArrayStream*out)#
Export C++ChunkedArray using the C data interface format.
The resultingArrowArrayStream struct keeps the chunked array data and buffers alive until its release callback is called by the consumer.
- Parameters:
chunked_array –[in]ChunkedArray object to export
out –[out] C struct where to export the stream
- StatusExportDeviceRecordBatchReader(std::shared_ptr<RecordBatchReader>reader,structArrowDeviceArrayStream*out)#
Export C++RecordBatchReader using the C device stream interface.
The resulting ArrowDeviceArrayStream struct keeps the record batch reader alive until its release callback is called by the consumer. The device type is determined by calling device_type() on theRecordBatchReader.
- Parameters:
reader –[in]RecordBatchReader object to export
out –[out] C struct to export the stream to
- StatusExportDeviceChunkedArray(std::shared_ptr<ChunkedArray>chunked_array,DeviceAllocationTypedevice_type,structArrowDeviceArrayStream*out)#
Export C++ChunkedArray using the C device data interface format.
The resulting ArrowDeviceArrayStream keeps the chunked array data and buffers alive until its release callback is called by the consumer.
- Parameters:
chunked_array –[in]ChunkedArray object to export
device_type –[in] the device type the data is located on
out –[out] C struct to export the stream to
- Result<std::shared_ptr<RecordBatchReader>>ImportRecordBatchReader(structArrowArrayStream*stream)#
Import C++RecordBatchReader from the C stream interface.
TheArrowArrayStream struct has its contents moved to a private object held alive by the resulting record batch reader.
- Parameters:
stream –[inout] C stream interface struct
- Returns:
ImportedRecordBatchReader object
- Result<std::shared_ptr<ChunkedArray>>ImportChunkedArray(structArrowArrayStream*stream)#
Import C++ChunkedArray from the C stream interface.
TheArrowArrayStream struct has its contents moved to a private object, is consumed in its entirity, and released before returning all chunks as aChunkedArray.
- Parameters:
stream –[inout] C stream interface struct
- Returns:
ImportedChunkedArray object
- Result<std::shared_ptr<RecordBatchReader>>ImportDeviceRecordBatchReader(structArrowDeviceArrayStream*stream,constDeviceMemoryMapper&mapper=DefaultDeviceMemoryMapper)#
Import C++RecordBatchReader from the C device stream interface.
The ArrowDeviceArrayStream struct has its contents moved to a private object held alive by the resulting record batch reader.
Note
If there was a required sync event, sync events are accessible by individual buffers of columns. We are not yet bubbling the sync events from the buffers up to the
GetSyncEventmethod of an importedRecordBatch. This will be added in a future update.- Parameters:
stream –[inout] C device stream interface struct
mapper –[in] mapping from device type and ID to memory manager
- Returns:
ImportedRecordBatchReader object
- Result<std::shared_ptr<ChunkedArray>>ImportDeviceChunkedArray(structArrowDeviceArrayStream*stream,constDeviceMemoryMapper&mapper=DefaultDeviceMemoryMapper)#
Import C++ChunkedArray from the C device stream interface.
The ArrowDeviceArrayStream struct has its contents moved to a private object, is consumed in its entirety, and released before returning all chunks as aChunkedArray.
Note
Any chunks that require synchronization for their device memory will have the SyncEvent objects available by checking the individual buffers of each chunk. These SyncEvents should be checked before accessing the data in those buffers.
- Parameters:
stream –[inout] C device stream interface struct
mapper –[in] mapping from device type and ID to memory manager
- Returns:
ImportedChunkedArray object

