james-willis opened a new pull request, #1193:
URL: https://github.com/apache/sedona-db/pull/1193

   Closes DB-410.
   
   ## Header rebuild → `start_raster_from`
   
   Five call sites each hand-rolled the same thing:
   
   ```rust
   let t: [f64; 6] = raster.transform().try_into().map_err(|_| { ... })?;
   let spatial_dims = raster.spatial_dims();
   new_builder.start_raster_nd(&t, &spatial_dims, raster.spatial_shape(), 
raster.crs())?;
   ```
   
   `RasterBuilder::start_raster_from` already does exactly this, so all five 
now call it: `RS_Slice`, `RS_SliceRange`, `RS_DimToBand`, `RS_BandToDim`, 
`RS_EnsureLoaded`.
   
   In `RS_EnsureLoaded` this also retires a block of owned-metadata locals 
(`transform` / `spatial_dims_owned` / `spatial_shape` / `crs`) that existed 
only to keep borrows from spanning the per-band `await` points. The header is 
built synchronously before the band loop, so none of them are needed — verified 
nothing downstream reads them.
   
   ## Pass-through bands → `copy_into`
   
   The pass-through paths in `RS_Slice`, `RS_SliceRange` and `RS_DimToBand` — 
bands that don't carry the named dimension and are emitted unchanged — did:
   
   ```rust
   start_band(StartBandArgs { name, nodata, ..StartBandArgs::new(&dim_names, 
band.shape(), band.data_type()) })?;
   let data = band.nd_buffer()?.as_contiguous()?;
   band_data_writer().append_value(data);
   ```
   
   That materialises a fresh identity band and re-copies the bytes. `copy_into` 
shares the source buffer zero-copy and carries `view()` forward instead of 
dropping it.
   
   This half was gated on view persistence — non-identity views weren't 
representable, so a view-preserving pass-through had nothing to land on. #1113 
merged 2026-08-12, so the gate is lifted.
   
   Band names are passed explicitly (`raster.band_name(band_idx)`) because 
`BandRef` has no name accessor — the name lives on `RasterRef` by index. #1192 
adds `BandRef::name()` and makes `copy_into` inherit it; once that lands these 
become redundant and can drop to `BandOverrides::default()`. They're correct 
either way, so the two PRs don't conflict.
   
   ## Deliberately out of scope
   
   `RS_EnsureLoaded`'s **band loop** is untouched. It's async with owned-data 
scoping around the `await`s, its InDb pass-through is already zero-copy via 
`append_band_data_from`, and it carries an explicit internal-error guard for 
non-identity views. Converting it is a restructure that also has to keep the 
OutDb loader path emitting identity bands — worth its own change, not a rider 
on a DRY pass. The ticket only calls for "revisit," so it stays a follow-up.
   
   ## Verification
   
   ```
   sedona-raster-functions  254 passed; 0 failed
   ```
   
   fmt and clippy clean. Net −44 lines.


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