Kontinuation commented on code in PR #586:
URL: https://github.com/apache/sedona-db/pull/586#discussion_r2796791609
##########
c/sedona-libgpuspatial/src/lib.rs:
##########
@@ -15,6 +15,537 @@
// specific language governing permissions and limitations
// under the License.
-// Module declarations
+use arrow_schema::DataType;
+use geo::Rect;
+
+mod error;
#[cfg(gpu_available)]
+mod libgpuspatial;
mod libgpuspatial_glue_bindgen;
+mod options;
+mod predicate;
+// Re-export to the users
+pub use error::GpuSpatialError;
+pub use options::GpuSpatialOptions;
+pub use predicate::GpuSpatialRelationPredicate;
+
+#[cfg(gpu_available)]
+mod sys {
+ use super::libgpuspatial;
+ use super::libgpuspatial_glue_bindgen;
+ use super::*;
+
+ pub type Result<T> = std::result::Result<T, GpuSpatialError>;
+
+ use std::sync::{Arc, Mutex};
+
+ use libgpuspatial::{
+ FloatIndex2DBuilder, GpuSpatialRefinerWrapper,
GpuSpatialRuntimeWrapper, SharedFloatIndex2D,
+ };
+ // To be used in the global state. We need to ensure these are Send + Sync
since they will be shared across threads.
+ unsafe impl Send for libgpuspatial_glue_bindgen::GpuSpatialRuntime {}
+ unsafe impl Sync for libgpuspatial_glue_bindgen::GpuSpatialRuntime {}
+
+ // -- Global State --
+ static GLOBAL_GPUSPATIAL_RUNTIME:
Mutex<Option<Arc<Mutex<GpuSpatialRuntimeWrapper>>>> =
+ Mutex::new(None);
+
+ // -- The Actual Implementation Struct --
+ pub struct SpatialImpl {
+ runtime: Option<Arc<Mutex<GpuSpatialRuntimeWrapper>>>,
+ // Index state is either building (Builder) or built (Shared)
+ index_builder: Option<FloatIndex2DBuilder>,
+ index: Option<SharedFloatIndex2D>,
+ refiner: Option<GpuSpatialRefinerWrapper>,
+ }
Review Comment:
Just discovered that Dewey has already gave a more comprehensive suggestion.
https://github.com/apache/sedona-db/pull/586#pullrequestreview-3781255055
--
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]