pwrliang commented on code in PR #465: URL: https://github.com/apache/sedona-db/pull/465#discussion_r2710805430
########## rust/sedona-spatial-join/src/index/gpu_spatial_index_builder.rs: ########## @@ -0,0 +1,248 @@ +// 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 crate::index::gpu_spatial_index::GPUSpatialIndex; +use crate::index::spatial_index::{SpatialIndexRef, SpatialJoinBuildMetrics}; +use crate::operand_evaluator::EvaluatedGeometryArray; +use crate::utils::join_utils::need_produce_result_in_final; +use crate::{ + evaluated_batch::EvaluatedBatch, index::BuildPartition, + operand_evaluator::create_operand_evaluator, spatial_predicate::SpatialPredicate, +}; +use arrow::array::BooleanBufferBuilder; +use arrow::compute::concat; +use arrow_array::RecordBatch; +use arrow_schema::SchemaRef; +use datafusion_common::Result; +use datafusion_common::{DataFusionError, JoinType}; +use datafusion_execution::memory_pool::{MemoryConsumer, MemoryPool, MemoryReservation}; +use futures::StreamExt; +use geo_types::{coord, Rect}; +use parking_lot::Mutex; +use sedona_common::SpatialJoinOptions; +use sedona_libgpuspatial::GpuSpatial; +use std::sync::atomic::AtomicUsize; +use std::sync::Arc; + +pub struct GPUSpatialIndexBuilder { + schema: SchemaRef, + spatial_predicate: SpatialPredicate, + options: SpatialJoinOptions, + join_type: JoinType, + probe_threads_count: usize, + metrics: SpatialJoinBuildMetrics, + /// Batches to be indexed + indexed_batches: Vec<EvaluatedBatch>, + /// Memory reservation for tracking the memory usage of the spatial index + reservation: MemoryReservation, +} + +impl GPUSpatialIndexBuilder { + pub fn new( + schema: SchemaRef, + spatial_predicate: SpatialPredicate, + options: SpatialJoinOptions, + join_type: JoinType, + probe_threads_count: usize, + memory_pool: Arc<dyn MemoryPool>, + metrics: SpatialJoinBuildMetrics, + ) -> Self { + let consumer = MemoryConsumer::new("SpatialJoinIndex"); + let reservation = consumer.register(&memory_pool); + + Self { + schema, + spatial_predicate, + options, + join_type, + probe_threads_count, + metrics, + indexed_batches: vec![], + reservation, + } + } + /// Build visited bitmaps for tracking left-side indices in outer joins. Review Comment: Fixed -- 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]
