Fix resuming arrow format
Opened by lhoestq (closed)

following https://github.com/huggingface/datasets/pull/6658

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_6964). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005735 / 0.011353 (-0.005618) | 0.003746 / 0.011008 (-0.007263) | 0.063115 / 0.038508 (0.024606) | 0.033557 / 0.023109 (0.010447) | 0.247599 / 0.275898 (-0.028299) | 0.275310 / 0.323480 (-0.048170) | 0.004203 / 0.007986 (-0.003783) | 0.002770 / 0.004328 (-0.001558) | 0.050951 / 0.004250 (0.046700) | 0.046609 / 0.037052 (0.009557) | 0.256237 / 0.258489 (-0.002252) | 0.292050 / 0.293841 (-0.001791) | 0.027991 / 0.128546 (-0.100556) | 0.010367 / 0.075646 (-0.065279) | 0.202295 / 0.419271 (-0.216977) | 0.037287 / 0.043533 (-0.006246) | 0.250330 / 0.255139 (-0.004809) | 0.281250 / 0.283200 (-0.001950) | 0.018832 / 0.141683 (-0.122851) | 1.117303 / 1.452155 (-0.334852) | 1.141593 / 1.492716 (-0.351123) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.097318 / 0.018006 (0.079312) | 0.304853 / 0.000490 (0.304364) | 0.000220 / 0.000200 (0.000020) | 0.000044 / 0.000054 (-0.000011) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.020353 / 0.037411 (-0.017058) | 0.065497 / 0.014526 (0.050971) | 0.076205 / 0.176557 (-0.100351) | 0.122471 / 0.737135 (-0.614665) | 0.079522 / 0.296338 (-0.216816) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.282604 / 0.215209 (0.067395) | 2.743198 / 2.077655 (0.665543) | 1.480436 / 1.504120 (-0.023684) | 1.373935 / 1.541195 (-0.167260) | 1.388901 / 1.468490 (-0.079589) | 0.571961 / 4.584777 (-4.012816) | 2.431790 / 3.745712 (-1.313922) | 2.942126 / 5.269862 (-2.327736) | 1.857361 / 4.565676 (-2.708316) | 0.063535 / 0.424275 (-0.360740) | 0.005039 / 0.007607 (-0.002568) | 0.331726 / 0.226044 (0.105682) | 3.282504 / 2.268929 (1.013576) | 1.852303 / 55.444624 (-53.592321) | 1.506665 / 6.876477 (-5.369812) | 1.577524 / 2.142072 (-0.564548) | 0.646267 / 4.805227 (-4.158960) | 0.118706 / 6.500664 (-6.381958) | 0.043437 / 0.075469 (-0.032033) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.978073 / 1.841788 (-0.863714) | 12.028575 / 8.074308 (3.954267) | 10.066303 / 10.191392 (-0.125090) | 0.131763 / 0.680424 (-0.548661) | 0.016479 / 0.534201 (-0.517722) | 0.286012 / 0.579283 (-0.293271) | 0.266824 / 0.434364 (-0.167540) | 0.328452 / 0.540337 (-0.211885) | 0.414562 / 1.386936 (-0.972374) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.005943 / 0.011353 (-0.005409) | 0.003992 / 0.011008 (-0.007016) | 0.051159 / 0.038508 (0.012651) | 0.033805 / 0.023109 (0.010695) | 0.268425 / 0.275898 (-0.007474) | 0.295662 / 0.323480 (-0.027818) | 0.004473 / 0.007986 (-0.003512) | 0.002910 / 0.004328 (-0.001418) | 0.048595 / 0.004250 (0.044345) | 0.043724 / 0.037052 (0.006671) | 0.280552 / 0.258489 (0.022063) | 0.319052 / 0.293841 (0.025211) | 0.031269 / 0.128546 (-0.097278) | 0.010976 / 0.075646 (-0.064671) | 0.060128 / 0.419271 (-0.359144) | 0.034198 / 0.043533 (-0.009335) | 0.269664 / 0.255139 (0.014525) | 0.292249 / 0.283200 (0.009049) | 0.019950 / 0.141683 (-0.121733) | 1.143073 / 1.452155 (-0.309082) | 1.188553 / 1.492716 (-0.304164) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.095188 / 0.018006 (0.077182) | 0.300207 / 0.000490 (0.299717) | 0.000205 / 0.000200 (0.000005) | 0.000051 / 0.000054 (-0.000003) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.023610 / 0.037411 (-0.013802) | 0.082868 / 0.014526 (0.068342) | 0.089059 / 0.176557 (-0.087498) | 0.131735 / 0.737135 (-0.605401) | 0.091467 / 0.296338 (-0.204872) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.302497 / 0.215209 (0.087287) | 2.985794 / 2.077655 (0.908140) | 1.590783 / 1.504120 (0.086663) | 1.468819 / 1.541195 (-0.072375) | 1.503115 / 1.468490 (0.034625) | 0.575109 / 4.584777 (-4.009668) | 0.972370 / 3.745712 (-2.773342) | 2.727976 / 5.269862 (-2.541886) | 1.793438 / 4.565676 (-2.772238) | 0.068840 / 0.424275 (-0.355435) | 0.005440 / 0.007607 (-0.002167) | 0.351843 / 0.226044 (0.125799) | 3.523108 / 2.268929 (1.254180) | 1.928576 / 55.444624 (-53.516049) | 1.627939 / 6.876477 (-5.248538) | 1.837618 / 2.142072 (-0.304454) | 0.669351 / 4.805227 (-4.135876) | 0.121822 / 6.500664 (-6.378842) | 0.042056 / 0.075469 (-0.033413) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.020081 / 1.841788 (-0.821707) | 13.417448 / 8.074308 (5.343140) | 10.974516 / 10.191392 (0.783124) | 0.135240 / 0.680424 (-0.545184) | 0.017581 / 0.534201 (-0.516620) | 0.289080 / 0.579283 (-0.290203) | 0.127679 / 0.434364 (-0.306685) | 0.331818 / 0.540337 (-0.208520) | 0.453143 / 1.386936 (-0.933793) |

</details>
</details>

![](https://cml.dev/watermark.png#ef2fb358433678b322d275c0bdee3239fa6485b2 "CML watermark")