()
| 446 | |
| 447 | @pytest.mark.zstd |
| 448 | def test_compression_roundtrip(): |
| 449 | sink = io.BytesIO() |
| 450 | values = [random.randint(0, 3) for _ in range(10000)] |
| 451 | table = pa.Table.from_arrays([values], names=["values"]) |
| 452 | |
| 453 | options = pa.ipc.IpcWriteOptions(compression='zstd') |
| 454 | with pa.ipc.RecordBatchFileWriter( |
| 455 | sink, table.schema, options=options) as writer: |
| 456 | writer.write_table(table) |
| 457 | len1 = len(sink.getvalue()) |
| 458 | |
| 459 | sink2 = io.BytesIO() |
| 460 | codec = pa.Codec('zstd', compression_level=5) |
| 461 | options = pa.ipc.IpcWriteOptions(compression=codec) |
| 462 | with pa.ipc.RecordBatchFileWriter( |
| 463 | sink2, table.schema, options=options) as writer: |
| 464 | writer.write_table(table) |
| 465 | len2 = len(sink2.getvalue()) |
| 466 | |
| 467 | # In theory len2 should be less than len1 but for this test we just want |
| 468 | # to ensure compression_level is being correctly passed down to the C++ |
| 469 | # layer so we don't really care if it makes it worse or better |
| 470 | assert len2 != len1 |
| 471 | |
| 472 | t1 = pa.ipc.open_file(sink).read_all() |
| 473 | t2 = pa.ipc.open_file(sink2).read_all() |
| 474 | |
| 475 | assert t1 == t2 |
| 476 | |
| 477 | |
| 478 | def test_write_options(): |
nothing calls this directly
no test coverage detected