Commit 6eed3c3
committed
Dictionary-encode coordinate columns
A dense grid repeats every coordinate value across the whole partition (a
chunk of shape (time, lat, lon) carries each latitude time×lon times). The
reader materialized coordinate columns as dense, fully-repeated Arrow arrays,
so every GROUP BY / JOIN on a coordinate re-hashed a hugely redundant column
and the pivot moved far more bytes than the data itself.
Encode coordinate columns as Arrow dictionaries: the distinct coordinate
values are the dictionary and the strided per-row indices we already compute
are the dictionary indices — no broadcast of repeated values. The index type
is sized to the dimension length (int8/int16/int32), so a 6-step time chunk
uses 1 byte/row and a 721/1440-point lat/lon uses 2. On an ERA5-shaped chunk
the coordinate columns shrink ~4.8x (and equality GROUP BY / JOIN keys become
small integers).
- df.py: _parse_schema declares dimension coordinates as dictionary(index,
value) with the value type/metadata preserved; iter_record_batches and
dataset_to_record_batch emit DictionaryArrays.
- src/lib.rs: keep partition pruning and exact statistics working on the new
encoding — DataFusion coerces a coordinate filter to either a Dictionary
literal (timestamp) or Cast(col AS value_type) (float), so compare_to_scalar
unwraps Dictionary scalars, the pruning matchers strip decode casts, and
bound_to_scalar / total_byte_size unwrap the dictionary value type.
- tests: pin the encoding contract and the group-by round-trip; update schema
and memory-characterization expectations to the (smaller) encoded columns.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019VuSeCio99NcME5eubcN3N1 parent f085271 commit 6eed3c3
5 files changed
Lines changed: 234 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
268 | | - | |
269 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
270 | 280 | | |
271 | 281 | | |
272 | 282 | | |
| |||
348 | 358 | | |
349 | 359 | | |
350 | 360 | | |
351 | | - | |
352 | | - | |
| 361 | + | |
| 362 | + | |
353 | 363 | | |
354 | 364 | | |
355 | 365 | | |
| |||
387 | 397 | | |
388 | 398 | | |
389 | 399 | | |
390 | | - | |
391 | | - | |
| 400 | + | |
| 401 | + | |
392 | 402 | | |
393 | 403 | | |
394 | 404 | | |
| |||
440 | 450 | | |
441 | 451 | | |
442 | 452 | | |
443 | | - | |
| 453 | + | |
444 | 454 | | |
445 | 455 | | |
446 | 456 | | |
447 | 457 | | |
448 | 458 | | |
449 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
450 | 480 | | |
451 | 481 | | |
452 | 482 | | |
| |||
702 | 732 | | |
703 | 733 | | |
704 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
705 | 741 | | |
706 | 742 | | |
707 | 743 | | |
| |||
736 | 772 | | |
737 | 773 | | |
738 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
739 | 788 | | |
740 | 789 | | |
741 | 790 | | |
| |||
745 | 794 | | |
746 | 795 | | |
747 | 796 | | |
748 | | - | |
| 797 | + | |
749 | 798 | | |
750 | 799 | | |
751 | 800 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
162 | | - | |
| 165 | + | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
169 | | - | |
| 173 | + | |
| 174 | + | |
170 | 175 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | 209 | | |
215 | | - | |
216 | | - | |
| 210 | + | |
217 | 211 | | |
218 | 212 | | |
219 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
| |||
403 | 406 | | |
404 | 407 | | |
405 | 408 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
411 | 415 | | |
412 | 416 | | |
413 | 417 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
419 | 424 | | |
420 | 425 | | |
421 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments