Skip to content

Commit b06b173

Browse files
authored
Merge branch 'apache:main' into main
2 parents b16c186 + 5cff82a commit b06b173

36 files changed

Lines changed: 1566 additions & 276 deletions

.github/workflows/r.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,23 @@ jobs:
9191
if: matrix.config.os == 'macos-latest'
9292
run: brew install geos
9393

94+
# Dynamically set a short target directory on Windows to bypass 260-char MinGW limits,
95+
# while keeping paths standard on Mac/Linux.
96+
- name: Configure Target Directory
97+
shell: bash
98+
run: |
99+
if [ "$RUNNER_OS" == "Windows" ]; then
100+
echo "SEDONADB_TARGET_DIR=D:/a/t" >> $GITHUB_ENV
101+
echo "CACHE_WORKSPACE=. -> D:/a/t" >> $GITHUB_ENV
102+
else
103+
echo "SEDONADB_TARGET_DIR=$(pwd)/r/sedonadb/src/rust/target" >> $GITHUB_ENV
104+
echo "CACHE_WORKSPACE=. -> r/sedonadb/src/rust/target" >> $GITHUB_ENV
105+
fi
106+
94107
- uses: Swatinem/rust-cache@v2
95108
with:
96-
# Update this key to force a new cache
97109
prefix-key: "r-v4"
98-
# The R package uses its own target directory
99-
workspaces: ". -> r/sedonadb/src/rust/target"
100-
101-
# Explicitly specify for Windows, which otherwise chooses a shorter version
102-
# to work around a path length limitation when building from longer starting paths.
103-
# This allows us to use a common cache configuration for Windows, MacOS, and Linux
104-
- name: Set R/Rust target directory
105-
if: matrix.config.os == 'windows-latest'
106-
run: |
107-
echo "SEDONADB_TARGET_DIR=$(pwd -W)/r/sedonadb/src/rust/target" >> $GITHUB_ENV
108-
shell: bash
110+
workspaces: ${{ env.CACHE_WORKSPACE }}
109111

110112
- uses: r-lib/actions/setup-r-dependencies@v2
111113
with:

Cargo.lock

Lines changed: 44 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ members = [
4040
"rust/sedona-raster-functions",
4141
"rust/sedona-schema",
4242
"rust/sedona-spatial-join",
43+
"rust/sedona-spatial-join-geography",
4344
"rust/sedona-spatial-join-gpu",
4445
"rust/sedona-query-planner",
4546
"rust/sedona-testing",
@@ -91,6 +92,7 @@ datafusion-execution = { version = "51.0.0", default-features = false }
9192
datafusion-expr = { version = "51.0.0" }
9293
datafusion-ffi = { version = "51.0.0" }
9394
datafusion-functions-nested = { version = "51.0.0" }
95+
datafusion-optimizer = { version = "51.0.0" }
9496
datafusion-physical-expr = { version = "51.0.0" }
9597
datafusion-physical-plan = { version = "51.0.0" }
9698
datafusion-pruning = { version = "51.0.0" }
@@ -109,7 +111,7 @@ glam = "0.32.0"
109111
libmimalloc-sys = { version = "0.1", default-features = false }
110112
log = "^0.4"
111113
libloading = "0.9"
112-
lru = "0.16"
114+
lru = "0.17"
113115
mimalloc = { version = "0.1", default-features = false }
114116
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
115117
object_store = { version = "0.12.4", default-features = false }
@@ -126,7 +128,7 @@ serde_json = { version = "1" }
126128
serde_with = { version = "3" }
127129
tempfile = { version = "3"}
128130
thiserror = { version = "2" }
129-
tokio = { version = "1.51", features = ["macros", "rt", "sync"] }
131+
tokio = { version = "1.52", features = ["macros", "rt", "sync"] }
130132
url = "2.5.7"
131133
wkb = "0.9.2"
132134
wkt = "0.14.0"
@@ -149,6 +151,7 @@ sedona-raster-functions = { version = "0.4.0", path = "rust/sedona-raster-functi
149151
sedona-schema = { version = "0.4.0", path = "rust/sedona-schema" }
150152
sedona-spatial-join = { version = "0.4.0", path = "rust/sedona-spatial-join" }
151153
sedona-spatial-join-gpu = { version = "0.4.0", path = "rust/sedona-spatial-join-gpu" }
154+
sedona-spatial-join-geography = { version = "0.4.0", path = "rust/sedona-spatial-join-geography" }
152155
sedona-query-planner = { version = "0.4.0", path = "rust/sedona-query-planner" }
153156
sedona-testing = { version = "0.4.0", path = "rust/sedona-testing" }
154157

c/sedona-s2geography/build.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ fn main() {
2727
// MACOS_DEPLOYMENT_TARGET isn't passed through properly but this can probably
2828
// be solved by setting the environment variable in CI before building a portable
2929
// target like a Python package.
30-
let dst = cmake::Config::new(".").build();
30+
let mut cmake_config = cmake::Config::new(".");
31+
32+
// Use RelWithDebInfo if building release with debug symbols
33+
if std::env::var("PROFILE").unwrap_or_default() == "release"
34+
&& std::env::var("CARGO_PROFILE_RELEASE_DEBUG").is_ok()
35+
{
36+
cmake_config.define("CMAKE_BUILD_TYPE", "RelWithDebInfo");
37+
}
38+
39+
let dst = cmake_config.build();
3140

3241
// Link the libraries that are easy to enumerate by hand and whose location
3342
// we control in CMakeLists.txt. s2geography_c and s2geography are always built

c/sedona-s2geography/src/geography.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use crate::utils::S2GeogCError;
3838
/// required in a thread safe way (although it may result in faster evaluation
3939
/// to force a build early in a situation where it is known that a lot of
4040
/// evaluations are about to happen).
41+
#[derive(Debug)]
4142
pub struct Geography<'a> {
4243
ptr: *mut S2Geog,
4344
_marker: PhantomData<&'a [u8]>,
@@ -125,9 +126,11 @@ impl GeographyFactory {
125126
Ok(geog)
126127
}
127128

128-
/// Internal wrappers around the actual init. This is the function that should be used
129-
/// in the event of looping over WKBs from the same arrow array.
130-
fn init_from_wkb(&mut self, wkb: &[u8], geog: &mut Geography) -> Result<(), S2GeogCError> {
129+
/// Initialize an existing Geography with a new WKB buffer
130+
///
131+
/// This is the function that should be used in the event of looping over
132+
/// WKBs from the same arrow array.
133+
pub fn init_from_wkb(&mut self, wkb: &[u8], geog: &mut Geography) -> Result<(), S2GeogCError> {
131134
unsafe {
132135
s2geog_call!(S2GeogFactoryInitFromWkbNonOwning(
133136
self.ptr,

c/sedona-s2geography/src/rect_bounder.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ impl RectBounder {
5151
unsafe { s2geog_call!(S2GeogRectBounderBound(self.ptr, geog.as_ptr())) }
5252
}
5353

54+
/// Perform the minimum expansion required to satisfy a distance expansion
55+
pub fn expand_by_distance(&mut self, distance_meters: f64) {
56+
unsafe { S2GeogRectBounderExpandByDistance(self.ptr, distance_meters) }
57+
}
58+
5459
/// Check if the bounder is empty (no geometries or only empty geometries
5560
/// have been added)
5661
pub fn is_empty(&self) -> bool {
@@ -139,6 +144,13 @@ mod tests {
139144
assert!(hi_lng >= 10.0);
140145
assert!(hi_lat >= 20.0);
141146

147+
bounder.expand_by_distance(100_000.0); // 100km
148+
let expanded = bounder.finish().unwrap().unwrap();
149+
assert!(expanded.0 < lo_lng);
150+
assert!(expanded.1 < lo_lat);
151+
assert!(expanded.2 > hi_lng);
152+
assert!(expanded.3 > hi_lat);
153+
142154
bounder.clear();
143155
assert!(bounder.is_empty());
144156
}

c/sedona-s2geography/src/s2geography_c_bindgen.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ unsafe extern "C" {
9797
geog: *const S2Geog,
9898
err: *mut S2GeogError,
9999
) -> S2GeogErrorCode;
100+
pub fn S2GeogRectBounderExpandByDistance(
101+
rect_bounder: *mut S2GeogRectBounder,
102+
distance_meters: f64,
103+
);
100104
pub fn S2GeogRectBounderIsEmpty(rect_bounder: *mut S2GeogRectBounder) -> u8;
101105
pub fn S2GeogRectBounderFinish(
102106
rect_bounder: *mut S2GeogRectBounder,

0 commit comments

Comments
 (0)