|
| 1 | +<!--- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# Arrow c integration |
| 21 | + |
| 22 | +This is a Rust crate that tests compatibility between Rust's Arrow implementation and PyArrow. |
| 23 | + |
| 24 | +Note that this crate uses two languages and an external ABI: |
| 25 | +* `Rust` |
| 26 | +* `Python` |
| 27 | +* C ABI privately exposed by `Pyarrow`. |
| 28 | + |
| 29 | +## Basic idea |
| 30 | + |
| 31 | +Pyarrow exposes a C ABI to convert arrow arrays from and to its C implementation, see [here](https://arrow.apache.org/docs/format/CDataInterface.html). |
| 32 | + |
| 33 | +This package uses the equivalent struct in Rust (`arrow::array::ArrowArray`), and verifies that |
| 34 | +we can use pyarrow's interface to move pointers from and to Rust. |
| 35 | + |
| 36 | +## Relevant literature |
| 37 | + |
| 38 | +* [Arrow's CDataInterface](https://arrow.apache.org/docs/format/CDataInterface.html) |
| 39 | +* [Rust's FFI](https://doc.rust-lang.org/nomicon/ffi.html) |
| 40 | +* [Pyarrow private binds](https://github.com/apache/arrow/blob/ae1d24efcc3f1ac2a876d8d9f544a34eb04ae874/python/pyarrow/array.pxi#L1226) |
| 41 | +* [PyO3](https://docs.rs/pyo3/0.12.1/pyo3/index.html) |
| 42 | + |
| 43 | +## How to develop |
| 44 | + |
| 45 | +```bash |
| 46 | +# prepare development environment (used to build wheel / install in development) |
| 47 | +python -m venv venv |
| 48 | +venv/bin/pip install maturin==0.8.2 toml==0.10.1 pyarrow==1.0.0 |
| 49 | +``` |
| 50 | + |
| 51 | +Whenever rust code changes (your changes or via git pull): |
| 52 | + |
| 53 | +```bash |
| 54 | +source venv/bin/activate |
| 55 | +maturin develop |
| 56 | +python -m unittest discover tests |
| 57 | +``` |
0 commit comments