Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 160 additions & 89 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ members = [
"c/sedona-s2geography",
"c/sedona-tg",
"r/sedonadb/src/rust",
"rust/sedona-geo-traits-ext",
"rust/sedona-geo-generic-alg",
"rust/sedona-adbc",
"rust/sedona-expr",
"rust/sedona-functions",
Expand Down Expand Up @@ -65,6 +67,7 @@ arrow-json = { version = "55.1.0" }
arrow-schema = { version = "55.1.0" }
async-trait = { version = "0.1.87" }
bytes = "1.10"
byteorder = "1"
chrono = { version = "0.4.38", default-features = false }
comfy-table = { version = "7.0" }
criterion = { version = "0.5", features = ["html_reports"] }
Expand All @@ -82,23 +85,21 @@ env_logger = "0.11"
futures = { version = "0.3" }
object_store = { version = "0.12.0", default-features = false }
float_next_after = "1"
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
mimalloc = { version = "0.1", default-features = false }
libmimalloc-sys = { version = "0.1", default-features = false }
once_cell = "1.20"

geos = { version = "10.0.0", features = ["geo"] }
geos = { version = "10.0.0", features = ["geo", "v3_10_0"] }

# Use our own fork of georust/geo, which implements generic computational geometry algorithms for geo-traits
geo-generic-alg = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-generic-alg" }
geo-types = "0.7.16"
geo-traits = "0.2.0"
geo-traits-ext = "0.1.0"
geo = { version = "0.30.0" }
geo-types = "0.7.17"
geo-traits = "0.3.0"
geo = "0.31.0"

geo-index = { version = "0.3.1" }

wkb = { version = "0.8.0", features = ["geos"] }
wkt = "0.13.0"
wkb = "0.9.1"
wkt = "0.14.0"

parking_lot = "0.12"
parquet = { version = "55.1.0", default-features = false, features = [
Expand Down Expand Up @@ -129,9 +130,6 @@ datafusion-ffi = { git = "https://github.com/paleolimbot/datafusion.git", branch
datafusion-physical-expr = { git = "https://github.com/paleolimbot/datafusion.git", branch = "local-49-with-patch", package = "datafusion-physical-expr" }
datafusion-physical-plan = { git = "https://github.com/paleolimbot/datafusion.git", branch = "local-49-with-patch", package = "datafusion-physical-plan" }

geo-types = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-types" }
geo-traits = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-traits" }
geo-traits-ext = { git = "https://github.com/wherobots/geo.git", branch = "generic-alg", package = "geo-traits-ext" }
# TODO: remove them once changes we made to geo-index and wkb crates are merged to upstream and released
geo-index = { git = "https://github.com/wherobots/geo-index.git", branch = "main" }
wkb = { git = "https://github.com/wherobots/wkb.git", branch = "generic-alg" }
wkt = { git = "https://github.com/wherobots/wkt.git", branch = "generic-alg" }
wkb = { git = "https://github.com/georust/wkb.git", rev = "130eb0c2b343bc9299aeafba6d34c2a6e53f3b6a" }
9 changes: 8 additions & 1 deletion c/sedona-geos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ criterion = { workspace = true }
sedona = { path = "../../rust/sedona" }
sedona-testing = { path = "../../rust/sedona-testing", features = ["criterion"] }
rstest = { workspace = true }
geo-types = { workspace = true }

[dependencies]
arrow-schema = { workspace = true }
Expand All @@ -42,8 +43,14 @@ sedona-expr = { path = "../../rust/sedona-expr" }
sedona-functions = { path = "../../rust/sedona-functions" }
sedona-geometry = { path = "../../rust/sedona-geometry" }
sedona-schema = { path = "../../rust/sedona-schema" }
wkb = { workspace = true, features = ["geos"] }
geo-traits = { workspace = true }
wkb = { workspace = true }
byteorder = { workspace = true }

[[bench]]
harness = false
name = "geos-functions"

[[bench]]
harness = false
name = "wkb_to_geos"
77 changes: 77 additions & 0 deletions c/sedona-geos/benches/wkb_to_geos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use criterion::{criterion_group, criterion_main};
use geo_types::{LineString, Point};
use sedona_geos::wkb_to_geos::GEOSWkbFactory;
use wkb::Endianness;

fn generate_wkb_linestring(num_points: usize, endianness: Endianness) -> Vec<u8> {
let mut points = Vec::new();
for i in 0..num_points {
points.push(Point::new(i as f64, i as f64));
}
let linestring = LineString::from(points);
let mut buffer = Vec::new();
wkb::writer::write_geometry(
&mut buffer,
&linestring,
&wkb::writer::WriteOptions { endianness },
)
.unwrap();
buffer
}

fn bench_parse(c: &mut criterion::Criterion) {
for num_points in [4, 10, 100, 500, 1000] {
for endianness in [Endianness::BigEndian, Endianness::LittleEndian] {
let wkb_buf = generate_wkb_linestring(num_points, endianness);
let wkb = wkb::reader::read_wkb(&wkb_buf).unwrap();
let endianness_name: &str = match endianness {
Endianness::BigEndian => "big endian",
Endianness::LittleEndian => "little endian",
};

c.bench_function(
&format!(
"convert linestring containing {num_points} points using to_geos ({endianness_name})"
),
|b| {
let factory = GEOSWkbFactory::new();
b.iter(|| {
let g = factory.create(&wkb).unwrap();
criterion::black_box(g);
});
},
);

c.bench_function(
&format!(
"convert linestring containing {num_points} points using geos wkb parser ({endianness_name})"
),
|b| {
b.iter(|| {
let g = geos::Geometry::new_from_wkb(wkb.buf()).unwrap();
criterion::black_box(g);
});
},
);
}
}
}

criterion_group!(benches, bench_parse);
criterion_main!(benches);
4 changes: 3 additions & 1 deletion c/sedona-geos/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
use datafusion_common::{DataFusionError, Result};
use sedona_functions::executor::{GenericExecutor, GeometryFactory};

use crate::wkb_to_geos::GEOSWkbFactory;

/// A [GenericExecutor] that iterates over [geos::Geometry]
pub type GeosExecutor<'a, 'b> = GenericExecutor<'a, 'b, GeosGeometryFactory, GeosGeometryFactory>;

/// [GeometryFactory] implementation for iterating over [geos::Geometry]
#[derive(Default)]
pub struct GeosGeometryFactory {
inner: wkb::reader::to_geos::GEOSWkbFactory,
inner: GEOSWkbFactory,
}

impl GeometryFactory for GeosGeometryFactory {
Expand Down
1 change: 1 addition & 0 deletions c/sedona-geos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ mod st_convexhull;
mod st_dwithin;
mod st_length;
mod st_perimeter;
pub mod wkb_to_geos;
Loading