Skip to content

Implement Arrow C device API#305

Merged
CurtHagenlocher merged 2 commits into
apache:mainfrom
CurtHagenlocher:DeviceApi
Apr 2, 2026
Merged

Implement Arrow C device API#305
CurtHagenlocher merged 2 commits into
apache:mainfrom
CurtHagenlocher:DeviceApi

Conversation

@CurtHagenlocher
Copy link
Copy Markdown
Contributor

What's Changed

Implement Arrow C device API

Closes #299.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Arrow C Device Data Interface (device arrays + device array streams) in the C# Arrow implementation, along with new unit tests and Python interop tests (via Python.NET) to validate behavior.

Changes:

  • Introduces CArrowDeviceArray, CArrowDeviceArrayStream, and ArrowDeviceType plus import/export helpers for arrays, record batches, and streams.
  • Adds a CArrowDeviceArrayStream importer/exporter to round-trip IArrowArrayStream through the device stream ABI (CPU-only for now).
  • Adds new C# tests and Python interop tests, and refactors Python.NET initialization into a shared xUnit collection fixture.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/Apache.Arrow.Tests/PythonNetFixture.cs Adds shared Python.NET initialization + skip/throw logic for Python interop tests.
test/Apache.Arrow.Tests/PythonNetCollection.cs Defines xUnit collection to share PythonNetFixture across Python interop tests.
test/Apache.Arrow.Tests/CDeviceDataInterfaceTests.cs Adds managed tests for device array + device stream export/import and CPU-only enforcement.
test/Apache.Arrow.Tests/CDeviceDataInterfacePythonTests.cs Adds PyArrow interop tests for the device data interface.
test/Apache.Arrow.Tests/CDataInterfacePythonTests.cs Switches existing Python tests to the shared Python.NET fixture/collection.
src/Apache.Arrow/C/ArrowDeviceType.cs Adds Arrow device type enum values per the C Device Data Interface spec.
src/Apache.Arrow/C/CArrowDeviceArray.cs Adds struct + allocation helpers for ArrowDeviceArray (device-aware array export container).
src/Apache.Arrow/C/CArrowDeviceArrayExporter.cs Exports IArrowArray/RecordBatch to CArrowDeviceArray (CPU-only fields).
src/Apache.Arrow/C/CArrowDeviceArrayImporter.cs Imports CArrowDeviceArray into IArrowArray/RecordBatch (CPU-only).
src/Apache.Arrow/C/CArrowDeviceArrayStream.cs Adds struct + allocation helpers for ArrowDeviceArrayStream ABI struct.
src/Apache.Arrow/C/CArrowDeviceArrayStreamExporter.cs Exports IArrowArrayStream to CArrowDeviceArrayStream (CPU-only).
src/Apache.Arrow/C/CArrowDeviceArrayStreamImporter.cs Imports CArrowDeviceArrayStream into IArrowArrayStream (CPU-only).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/Apache.Arrow.Tests/CDeviceDataInterfacePythonTests.cs
Comment thread test/Apache.Arrow.Tests/CDeviceDataInterfacePythonTests.cs Outdated
Comment thread test/Apache.Arrow.Tests/CDeviceDataInterfacePythonTests.cs
Comment thread src/Apache.Arrow/C/CArrowDeviceArrayStreamImporter.cs
Comment thread src/Apache.Arrow/C/CArrowDeviceArrayStreamImporter.cs
Comment thread src/Apache.Arrow/C/CArrowDeviceArrayStreamExporter.cs
Comment thread test/Apache.Arrow.Tests/PythonNetFixture.cs Outdated
@CurtHagenlocher
Copy link
Copy Markdown
Contributor Author

(I'm sorry for abusing your patience with all these PRs, @adamreeve)

@adamreeve
Copy link
Copy Markdown
Contributor

(I'm sorry for abusing your patience with all these PRs, @adamreeve)

No worries, it's nice to see all these improvements landing!

Copy link
Copy Markdown
Contributor

@adamreeve adamreeve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me thanks Curt

@CurtHagenlocher CurtHagenlocher merged commit 1185f99 into apache:main Apr 2, 2026
22 of 24 checks passed
@CurtHagenlocher CurtHagenlocher deleted the DeviceApi branch April 2, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the Device Stream interface

3 participants