feat(sedona-gdal): add foundational wrapper utilities#696
feat(sedona-gdal): add foundational wrapper utilities#696Kontinuation merged 6 commits intoapache:mainfrom
Conversation
f90ac02 to
83b18e2
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds foundational safe-wrapper utilities on top of the GDAL FFI crate (sedona-gdal). It introduces a pure-Rust CslStringList for GDAL's char** option lists, raster type abstractions (GdalDataType, GdalType, Buffer, DatasetOptions, ResampleAlg), a thread-local config setter, and expands the shared error type. It also re-exports the call_gdal_api! macro for use by follow-up wrapper PRs.
Changes:
- New
cpl.rs: ImplementsCslStringListwith comprehensive tests for building/querying null-terminated GDAL option string lists. - New
raster/types.rs+raster.rs: Adds raster type enums and structs (GdalDataType,Buffer,DatasetOptions,ResampleAlg) that map cleanly between Rust types and GDAL C types. config.rs+errors.rs+gdal_api.rsadditions: Thread-local GDAL config wrapper, two new error variants (BadArgument,FfiNulError), aResult<T>alias, and apub(crate)macro re-export.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
c/sedona-gdal/src/cpl.rs |
New: Pure-Rust CslStringList implementation with iterator, formatting, and conversion impls, plus unit tests |
c/sedona-gdal/src/raster/types.rs |
New: Raster type enums/structs and GdalType trait for Rust↔GDAL type mapping |
c/sedona-gdal/src/raster.rs |
New: Module declaration and re-exports for raster types |
c/sedona-gdal/src/config.rs |
New: set_thread_local_config_option wrapper function |
c/sedona-gdal/src/errors.rs |
Adds BadArgument, FfiNulError variants and a Result<T> type alias to GdalError |
c/sedona-gdal/src/gdal_api.rs |
Exports call_gdal_api! macro as pub(crate) |
c/sedona-gdal/src/lib.rs |
Registers new high-level wrapper modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1f6b2df to
1803c4c
Compare
paleolimbot
left a comment
There was a problem hiding this comment.
A few optional suggestions to consider...thank you!
| /// Set a GDAL library configuration option with **thread-local** scope. | ||
| pub fn set_thread_local_config_option(api: &'static GdalApi, key: &str, value: &str) -> Result<()> { |
There was a problem hiding this comment.
Perhaps not here, but it might be worth exposing this as with_thread_local_config_option(FnMut...) that takes care of resetting the previous value. At the very least returning the previous value so it can be reset may be a good feature of this particular function:
c/sedona-gdal/src/raster.rs
Outdated
| pub mod types; | ||
|
|
||
| pub use types::{ | ||
| Buffer, DatasetOptions, GdalDataType, GdalType, RasterCreationOptions, ResampleAlg, | ||
| }; |
There was a problem hiding this comment.
It seems odd to have these aliases...should the aliases be removed or types be private?
There was a problem hiding this comment.
I decided to remove these aliases.
| /// Shape as (cols, rows) — matches georust/gdal convention. | ||
| pub shape: (usize, usize), | ||
| pub data: Vec<T>, |
There was a problem hiding this comment.
Is there any future in which we need either (1) a shape larger than 2 dimensions or (2) non-owned data?
There was a problem hiding this comment.
I don't think we need to handle rasters with more than 2 dimensions using GDAL in the near future. This struct was taken from georust/gdal for representing blocks read from the raster. We'll simply pass in slices when working with buffer slices, and there's currently no methods for returning borrowed raster data. We can add a BorrowedBuffer if we need to work with non-owned buffer in a different way in the future.
ebb9d74 to
5a608c6
Compare
Summary
Testing
cargo test -p sedona-gdalcargo clippy -p sedona-gdal -- -D warnings