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


##########
rust/sedona/src/context.rs:
##########
@@ -115,6 +116,17 @@ impl SedonaContext {
         opts.crs_provider =
             
CrsProviderOption::new(Arc::new(sedona_proj::provider::ProjCrsProvider::default()));
 
+        // Set the spilled batch in-memory size threshold to 5% of the 
per-partition memory limit,
+        // with a minimum of 10MB. Batches larger than this threshold will be 
broken into smaller batches
+        // before writing to spill files. This is to avoid overshooting memory 
limit when reading super
+        // large spilled batches.
+        if let MemoryLimit::Finite(memory_limit) = 
runtime_env.memory_pool.memory_limit() {
+            let per_partition_memory_limit = 
memory_limit.div_ceil(target_partitions);
+            opts.spatial_join.spilled_batch_in_memory_size_threshold = 
per_partition_memory_limit
+                .div_ceil(20)
+                .max(10 * 1024 * 1024);

Review Comment:
   Defined these constants as `const`.



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