Commit 9267b04
committed
refactor(raster): use i64 throughout the view-machinery surface
Per Dewey's review: every `source_axis`/`source_shape`/`visible_shape`
in the view helpers should be `i64` to match `ViewEntry`'s signed
fields and the stride arithmetic, instead of round-tripping through
`u64` and sprinkling `as` casts through helper bodies. Reworked to
make i64 the canonical view-machinery type — no more u64↔i64
conversions in `data()`, `nd_buffer()`, `contiguous_data()`, or the
band-construction storage step.
Public surface changes:
- `BandRef::shape() -> &[i64]` (was `&[u64]`). Production callers
outside the raster crate's own tests don't exist; tests use array
literals which infer the new element type. `width()` and `height()`
stay `u64` (conventional non-negative scalar counts) and pick up a
single `as u64` cast in the default `dim_size()` impl.
- `BandRef::raw_source_shape() -> &[u64]` unchanged — this is a
direct slice into the Arrow `UInt64Array` column, changing the
return type would force an alloc per call.
- `NdBuffer.shape: Vec<i64>`, `NdBuffer.offset: i64` — internal
struct, no out-of-crate consumers.
Internals now `i64`:
- `validate_view(view, source_shape: &[i64])`, with an added
`source_shape[sa] >= 0` check at the boundary.
- `is_identity_view(view, source_shape: &[i64])`.
- `visible_shape_from_view(view) -> Vec<i64>`.
- `BandRefImpl::visible_shape: Vec<i64>` (matches the trait return).
- `materialize_strided` and `check_view_buffer_bounds` take
`visible_shape: &[i64]`.
Conversions concentrated at the two unavoidable boundaries — both
are Arrow column reads:
- `RasterRefImpl::band()` converts `raw_source_shape() -> &[u64]`
into `Vec<i64>` once with a `try_from` overflow check.
- `RasterBuilder::start_band_with_view` does the same conversion at
its `source_shape: &[u64]` entry point before calling
`validate_view`.
Eliminates the source-stride `i64::try_from` cast that used to live
inside `band()` (line ~527 pre-refactor). Tests pass: sedona-raster
131, sedona-raster-functions 143, sedona-raster-gdal 53. Arrow column
storage and the public `width()`/`height()` API unchanged.1 parent e890f90 commit 9267b04
3 files changed
Lines changed: 103 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | | - | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
171 | | - | |
172 | | - | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 190 | + | |
193 | 191 | | |
194 | 192 | | |
195 | 193 | | |
| |||
220 | 218 | | |
221 | 219 | | |
222 | 220 | | |
223 | | - | |
| 221 | + | |
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
| |||
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
237 | 235 | | |
238 | 236 | | |
239 | 237 | | |
| |||
285 | 283 | | |
286 | 284 | | |
287 | 285 | | |
288 | | - | |
| 286 | + | |
289 | 287 | | |
290 | 288 | | |
291 | 289 | | |
| |||
302 | 300 | | |
303 | 301 | | |
304 | 302 | | |
305 | | - | |
| 303 | + | |
306 | 304 | | |
307 | 305 | | |
308 | 306 | | |
| |||
322 | 320 | | |
323 | 321 | | |
324 | 322 | | |
325 | | - | |
| 323 | + | |
326 | 324 | | |
327 | 325 | | |
328 | 326 | | |
329 | 327 | | |
330 | 328 | | |
331 | | - | |
| 329 | + | |
332 | 330 | | |
333 | 331 | | |
334 | 332 | | |
| |||
435 | 433 | | |
436 | 434 | | |
437 | 435 | | |
438 | | - | |
| 436 | + | |
439 | 437 | | |
440 | 438 | | |
441 | 439 | | |
442 | | - | |
| 440 | + | |
443 | 441 | | |
444 | 442 | | |
445 | 443 | | |
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
449 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
450 | 467 | | |
451 | 468 | | |
452 | 469 | | |
| |||
474 | 491 | | |
475 | 492 | | |
476 | 493 | | |
477 | | - | |
| 494 | + | |
478 | 495 | | |
479 | 496 | | |
480 | 497 | | |
| |||
492 | 509 | | |
493 | 510 | | |
494 | 511 | | |
495 | | - | |
| 512 | + | |
496 | 513 | | |
497 | 514 | | |
498 | 515 | | |
| |||
517 | 534 | | |
518 | 535 | | |
519 | 536 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
524 | 540 | | |
525 | 541 | | |
526 | 542 | | |
527 | | - | |
528 | | - | |
529 | 543 | | |
530 | | - | |
| 544 | + | |
531 | 545 | | |
532 | 546 | | |
533 | 547 | | |
| |||
552 | 566 | | |
553 | 567 | | |
554 | 568 | | |
555 | | - | |
| 569 | + | |
556 | 570 | | |
557 | 571 | | |
558 | 572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
423 | 437 | | |
424 | 438 | | |
425 | 439 | | |
| |||
470 | 484 | | |
471 | 485 | | |
472 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
473 | 494 | | |
474 | 495 | | |
475 | | - | |
| 496 | + | |
476 | 497 | | |
477 | 498 | | |
478 | 499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | | - | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
476 | 481 | | |
477 | 482 | | |
478 | 483 | | |
479 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
480 | 489 | | |
481 | 490 | | |
482 | 491 | | |
| |||
489 | 498 | | |
490 | 499 | | |
491 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
492 | 505 | | |
493 | 506 | | |
494 | 507 | | |
495 | 508 | | |
496 | 509 | | |
497 | 510 | | |
498 | 511 | | |
499 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
500 | 515 | | |
501 | 516 | | |
502 | | - | |
| 517 | + | |
503 | 518 | | |
504 | 519 | | |
505 | 520 | | |
| |||
678 | 693 | | |
679 | 694 | | |
680 | 695 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
688 | 700 | | |
689 | 701 | | |
690 | 702 | | |
| |||
698 | 710 | | |
699 | 711 | | |
700 | 712 | | |
701 | | - | |
| 713 | + | |
702 | 714 | | |
703 | 715 | | |
704 | 716 | | |
705 | 717 | | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
| 718 | + | |
711 | 719 | | |
712 | 720 | | |
713 | 721 | | |
| |||
789 | 797 | | |
790 | 798 | | |
791 | 799 | | |
792 | | - | |
| 800 | + | |
793 | 801 | | |
794 | 802 | | |
795 | 803 | | |
| |||
820 | 828 | | |
821 | 829 | | |
822 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
823 | 837 | | |
824 | | - | |
| 838 | + | |
825 | 839 | | |
826 | 840 | | |
827 | 841 | | |
| |||
1319 | 1333 | | |
1320 | 1334 | | |
1321 | 1335 | | |
1322 | | - | |
| 1336 | + | |
1323 | 1337 | | |
1324 | 1338 | | |
1325 | 1339 | | |
| |||
1330 | 1344 | | |
1331 | 1345 | | |
1332 | 1346 | | |
1333 | | - | |
| 1347 | + | |
1334 | 1348 | | |
1335 | 1349 | | |
1336 | 1350 | | |
| |||
0 commit comments