(indices: &[u32])
| 29 | const RLE_BENEFIT_DENOMINATOR: usize = 2; |
| 30 | |
| 31 | fn should_use_rle(indices: &[u32]) -> bool { |
| 32 | if indices.len() < 4 { |
| 33 | return false; |
| 34 | } |
| 35 | let mut run_count = 1usize; |
| 36 | for i in 1..indices.len() { |
| 37 | if indices[i] != indices[i - 1] { |
| 38 | run_count += 1; |
| 39 | } |
| 40 | } |
| 41 | // RLE cells needed: run_count * 8 bytes (value + length pairs) |
| 42 | // Delta cells approx: indices.len() * 1.5 bytes average |
| 43 | // Use simpler heuristic: worth it if run_count < indices.len() / 2 |
| 44 | run_count * RLE_BENEFIT_DENOMINATOR < indices.len() * RLE_BENEFIT_NUMERATOR |
| 45 | } |
| 46 | |
| 47 | /// RLE mode sentinel: u32::MAX. This value can never appear as a dict count |
| 48 | /// because a DimDict with u32::MAX distinct values would require ~16 GB of |
no test coverage detected