Add page index and content-defined chunking to reshard script
Browse files- reshard_parquet.py +2 -2
reshard_parquet.py
CHANGED
|
@@ -54,7 +54,7 @@ def reshard(shards: list[Path], split: str, rows_per_shard: int, out_dir: Path)
|
|
| 54 |
remainder = merged.slice(rows_per_shard)
|
| 55 |
|
| 56 |
name = f"{split}-{out_idx:05d}-of-{num_out:05d}.parquet"
|
| 57 |
-
pq.write_table(to_write, out_dir / name, compression="zstd")
|
| 58 |
out_idx += 1
|
| 59 |
print(f" wrote {name} ({to_write.num_rows:,} rows)")
|
| 60 |
|
|
@@ -70,7 +70,7 @@ def reshard(shards: list[Path], split: str, rows_per_shard: int, out_dir: Path)
|
|
| 70 |
import pyarrow as pa
|
| 71 |
merged = pa.concat_tables(buf_rows)
|
| 72 |
name = f"{split}-{out_idx:05d}-of-{num_out:05d}.parquet"
|
| 73 |
-
pq.write_table(merged, out_dir / name, compression="zstd")
|
| 74 |
out_idx += 1
|
| 75 |
print(f" wrote {name} ({merged.num_rows:,} rows)")
|
| 76 |
|
|
|
|
| 54 |
remainder = merged.slice(rows_per_shard)
|
| 55 |
|
| 56 |
name = f"{split}-{out_idx:05d}-of-{num_out:05d}.parquet"
|
| 57 |
+
pq.write_table(to_write, out_dir / name, compression="zstd", row_group_size=200_000, write_page_index=True, use_content_defined_chunking=True)
|
| 58 |
out_idx += 1
|
| 59 |
print(f" wrote {name} ({to_write.num_rows:,} rows)")
|
| 60 |
|
|
|
|
| 70 |
import pyarrow as pa
|
| 71 |
merged = pa.concat_tables(buf_rows)
|
| 72 |
name = f"{split}-{out_idx:05d}-of-{num_out:05d}.parquet"
|
| 73 |
+
pq.write_table(merged, out_dir / name, compression="zstd", row_group_size=200_000, write_page_index=True, use_content_defined_chunking=True)
|
| 74 |
out_idx += 1
|
| 75 |
print(f" wrote {name} ({merged.num_rows:,} rows)")
|
| 76 |
|