Commit 64ca69c
committed
Separate the Arrow layer from the Python bindings
geoarrow.cpp had grown to 1876 lines holding two quite different jobs: the
Arrow work - reading GeoArrow arrays, splitting them, writing the pieces -
and the Python work of where batches come from, who holds the GIL, and the
stream handed back over the PyCapsule interface.
Splitting them along that line was not only about size. extension's Catch2
target builds without pybind11, so while the Arrow code sat beside the
bindings it could not be compiled into the test suite at all: none of it
has ever had a C++ test, and every check on it went through geopandas.
Now geoarrow_arrays.cpp has no pybind11 in it, run_tests compiles it
directly, and tests_geoarrow.cpp goes at the layer as it is - building WKB
byte by byte, so a test states its input rather than borrowing the code
under test to produce it.
The eight new cases cover what the Python suite reaches only indirectly:
the per-feature type refusal and the row it names, a mixed batch of a
point, a line and an empty collection, multi-part explosion, nesting two
collections deep, polygons with holes, the exported schema of all three
encodings, and a null being refused rather than dropped. Checked that they
bite: removing the null_feat callback, the empty-geometry branch, or the
type check each fails one, with no Python involved.
Two small shape changes fell out of drawing the line. The batch splitters
took an InputStream, which is Python's; they now take the WKB reader and a
count, and there is one entry point per encoding, so the readers stay
internal. And BatchData holds a unique_ptr to the WKB writer, so its
destructor is defined out of line and splitMixedBatch makes the writer
itself - which is what keeps WkbWriter out of the header.
Nothing else moved: pieces are bit-identical on both geometry types, all
128 Python tests pass, and ru_maxrss is flat across the fourteen stream
lifecycles.
geoarrow.cpp 1876 -> 573
geoarrow_arrays.cpp 1282
geoarrow_arrays.hpp 160
tests_geoarrow.cpp 320
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqdWshmD4AUHhrqeMh86GS1 parent c2ab64d commit 64ca69c
6 files changed
Lines changed: 1794 additions & 1320 deletions
File tree
- extension
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
| 30 | + | |
20 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
21 | 35 | | |
22 | 36 | | |
23 | 37 | | |
| |||
0 commit comments