paleolimbot opened a new issue, #659:
URL: https://github.com/apache/sedona-db/issues/659
Found when coming up with an example for the latest R PR:
```python
import sedona.db
sd = sedona.db.connect()
sd.read_parquet(
"https://github.com/geoarrow/geoarrow-data/releases/download/v0.2.0/ns-water_elevation.parquet"
).to_view("elevation")
sd.read_parquet(
"https://github.com/geoarrow/geoarrow-data/releases/download/v0.2.0/ns-water_water-point.parquet"
).to_view("water_point")
sd.sql("""
SELECT water_point."OBJECTID", water_point.geometry, elevation."ZVALUE"
FROM water_point
INNER JOIN elevation ON ST_KNN(
ST_Transform(water_point.geometry, 26920),
ST_Transform(elevation.geometry, 26920),
1,
false
)
""").to_parquet("foofy.parquet")
```
The debugger points me to `geo_index::rtree::sort::hilbert::sort()`. Given
the number of stack frames with that label I am guessing that the recursion
isn't quite right.
```rust
/// Custom quicksort that partially sorts bbox data alongside the hilbert
values.
// Partially taken from static_aabb2d_index under the MIT/Apache license
fn sort<N: IndexableNum>(
values: &mut [u32],
boxes: &mut [N],
indices: &mut MutableIndices,
left: usize,
right: usize,
node_size: usize,
) {
debug_assert!(left <= right);
if left / node_size >= right / node_size {
return;
}
// apply median of three method
let start = values[left];
let mid = values[(left + right) >> 1];
let end = values[right];
let x = start.max(mid);
let pivot = if end > x {
x
} else if x == start {
mid.max(end)
} else if x == mid {
start.max(end)
} else {
end
};
let mut i = left.wrapping_sub(1);
let mut j = right.wrapping_add(1);
loop {
loop {
i = i.wrapping_add(1);
if values[i] >= pivot {
break;
}
}
loop {
j = j.wrapping_sub(1);
if values[j] <= pivot {
break;
}
}
if i >= j {
break;
}
swap(values, boxes, indices, i, j);
}
sort(values, boxes, indices, left, j, node_size);
sort(values, boxes, indices, j.wrapping_add(1), right, node_size);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]