Kontinuation commented on code in PR #555:
URL: https://github.com/apache/sedona-db/pull/555#discussion_r2736112375


##########
rust/sedona-spatial-join/src/prepare.rs:
##########
@@ -0,0 +1,416 @@
+// 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 std::{mem, sync::Arc};
+
+use arrow_schema::SchemaRef;
+use datafusion_common::Result;
+use datafusion_common_runtime::JoinSet;
+use datafusion_execution::{
+    disk_manager::RefCountedTempFile, memory_pool::MemoryConsumer, 
SendableRecordBatchStream,
+    TaskContext,
+};
+use datafusion_expr::JoinType;
+use datafusion_physical_plan::metrics::ExecutionPlanMetricsSet;
+use fastrand::Rng;
+use sedona_common::{sedona_internal_err, NumSpatialPartitionsConfig, 
SedonaOptions};
+use sedona_expr::statistics::GeoStatistics;
+use sedona_geometry::bounding_box::BoundingBox;
+
+use crate::{
+    index::{
+        memory_plan::{compute_memory_plan, PartitionMemorySummary},
+        partitioned_index_provider::PartitionedIndexProvider,
+        BuildSideBatchesCollector, CollectBuildSideMetrics, 
SpatialJoinBuildMetrics,
+    },
+    partitioning::{
+        kdb::KDBPartitioner,
+        stream_repartitioner::{SpilledPartition, SpilledPartitions, 
StreamRepartitioner},
+        PartitionedSide, SpatialPartition, SpatialPartitioner,
+    },
+    spatial_predicate::SpatialPredicate,
+    utils::bbox_sampler::BoundingBoxSamples,
+};
+
+pub(crate) struct SpatialJoinComponents {
+    pub partitioned_index_provider: Arc<PartitionedIndexProvider>,
+}
+
+#[allow(clippy::too_many_arguments)]
+pub(crate) async fn prepare_spatial_join_components(
+    context: Arc<TaskContext>,
+    build_schema: SchemaRef,
+    build_streams: Vec<SendableRecordBatchStream>,
+    spatial_predicate: SpatialPredicate,
+    join_type: JoinType,
+    probe_threads_count: usize,
+    metrics: ExecutionPlanMetricsSet,
+    seed: u64,
+) -> Result<SpatialJoinComponents> {

Review Comment:
   I have refactored this method by splitting it into smaller functions. There 
are some other related changes made to `BuildPartition` to make the flow of 
data simpler.



-- 
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]

Reply via email to