You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by pr...@apache.org on 2026/06/02 23:54:44 UTC

(sedona-spatialbench) 01/02: style: apply rustfmt to raster generation changes

This is an automated email from the ASF dual-hosted git repository.

prantogg pushed a commit to branch pranav/feature/raster-benchmark
in repository https://gitbox.apache.org/repos/asf/sedona-spatialbench.git

commit 50e30c24db0cf8f4058c94d73eccfde9716aa24b
Author: Pranav Toggi <pr...@gmail.com>
AuthorDate: Tue Jun 2 16:44:23 2026 -0700

    style: apply rustfmt to raster generation changes
---
 spatialbench-cli/src/raster_runner.rs | 14 +++-----------
 spatialbench-raster/src/cog/mod.rs    | 35 +++++++++++++++++++++++++----------
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/spatialbench-cli/src/raster_runner.rs b/spatialbench-cli/src/raster_runner.rs
index b9ee335..371201b 100644
--- a/spatialbench-cli/src/raster_runner.rs
+++ b/spatialbench-cli/src/raster_runner.rs
@@ -271,9 +271,7 @@ impl RasterConcurrency {
 
 /// Raw bytes of one COG's pixel buffer — the dominant in-flight memory unit.
 fn est_cog_bytes(cog: &CogConfig) -> u64 {
-    cog.raster.cog_width as u64
-        * cog.raster.cog_height as u64
-        * cog.dtype.bytes_per_pixel() as u64
+    cog.raster.cog_width as u64 * cog.raster.cog_height as u64 * cog.dtype.bytes_per_pixel() as u64
 }
 
 /// Build the full work list and the full deterministic manifest.
@@ -739,10 +737,7 @@ mod tests {
             fail_at: None,
             delay_ms: 5,
         });
-        let conc = RasterConcurrency {
-            gen: 4,
-            upload: 3,
-        };
+        let conc = RasterConcurrency { gen: 4, upload: 3 };
         let items = pipeline_items(60);
         run_pipeline(sink, items, conc, 60).await.unwrap();
 
@@ -764,10 +759,7 @@ mod tests {
             fail_at: Some(3),
             delay_ms: 0,
         });
-        let conc = RasterConcurrency {
-            gen: 2,
-            upload: 2,
-        };
+        let conc = RasterConcurrency { gen: 2, upload: 2 };
         let err = run_pipeline(sink, pipeline_items(20), conc, 20)
             .await
             .unwrap_err();
diff --git a/spatialbench-raster/src/cog/mod.rs b/spatialbench-raster/src/cog/mod.rs
index 9a24f96..519d74f 100644
--- a/spatialbench-raster/src/cog/mod.rs
+++ b/spatialbench-raster/src/cog/mod.rs
@@ -551,10 +551,7 @@ pub struct CalibrationResult {
 /// # Errors
 ///
 /// Returns `io::Error` if ZSTD compression fails during a probe.
-pub fn calibrate_frequency(
-    config: &CogConfig,
-    target_ratio: f32,
-) -> io::Result<CalibrationResult> {
+pub fn calibrate_frequency(config: &CogConfig, target_ratio: f32) -> io::Result<CalibrationResult> {
     // Coarse geometric sweep along the descending arm, stopping as soon as we
     // bracket the target (or leave the smooth arm / hit the cap). Stopping early
     // keeps both startup and tests cheap.
@@ -567,14 +564,22 @@ pub fn calibrate_frequency(
             // the lowest frequency is the best we can do.
             None => {
                 if target_ratio >= r {
-                    return Ok(CalibrationResult { frequency: freq, achieved_ratio: r, clamped: true });
+                    return Ok(CalibrationResult {
+                        frequency: freq,
+                        achieved_ratio: r,
+                        clamped: true,
+                    });
                 }
             }
             Some((pf, pr)) => {
                 if r >= pr {
                     // Ratio turned back up → end of the smooth arm at `prev`, and
                     // the target is below the arm's minimum → clamp to the arm end.
-                    return Ok(CalibrationResult { frequency: pf, achieved_ratio: pr, clamped: true });
+                    return Ok(CalibrationResult {
+                        frequency: pf,
+                        achieved_ratio: pr,
+                        clamped: true,
+                    });
                 }
                 if r <= target_ratio {
                     // Bracketed: ratio(pf) > target >= ratio(freq). Bisect within
@@ -590,13 +595,21 @@ pub fn calibrate_frequency(
                             hi = mid; // ratio too low → back off frequency
                         }
                     }
-                    return Ok(CalibrationResult { frequency: mid, achieved_ratio: mid_ratio, clamped: false });
+                    return Ok(CalibrationResult {
+                        frequency: mid,
+                        achieved_ratio: mid_ratio,
+                        clamped: false,
+                    });
                 }
             }
         }
         if freq >= CALIB_FREQ_MAX {
             // Hit the cap with ratio still above target → clamp to the cap.
-            return Ok(CalibrationResult { frequency: freq, achieved_ratio: r, clamped: true });
+            return Ok(CalibrationResult {
+                frequency: freq,
+                achieved_ratio: r,
+                clamped: true,
+            });
         }
         prev = Some((freq, r));
         freq = (freq * CALIB_SWEEP_STEP).min(CALIB_FREQ_MAX);
@@ -952,7 +965,10 @@ mod tests {
         // (highest frequency reached). Achieved ratio stays above the target.
         let cal = calibrate_frequency(&calib_config(RasterDtype::UInt16), 1.02).unwrap();
         assert!(cal.clamped);
-        assert!(cal.frequency > CALIB_FREQ_MIN, "should clamp to the high end");
+        assert!(
+            cal.frequency > CALIB_FREQ_MIN,
+            "should clamp to the high end"
+        );
         assert!(cal.achieved_ratio > 1.02);
     }
 
@@ -1137,4 +1153,3 @@ mod tests {
         assert!(pixels.iter().all(|&v| (0.0..=1.0).contains(&v)));
     }
 }
-