MCPcopy Create free account
hub / github.com/apache/arrow / test_compression_level

Function test_compression_level

python/pyarrow/tests/parquet/test_basic.py:571–613  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

569
570
571def test_compression_level():
572 arr = pa.array(list(map(int, range(1000))))
573 data = [arr, arr]
574 table = pa.Table.from_arrays(data, names=['a', 'b'])
575
576 # Check one compression level.
577 _check_roundtrip(table, expected=table, compression="gzip",
578 compression_level=1)
579
580 # Check another one to make sure that compression_level=1 does not
581 # coincide with the default one in Arrow.
582 _check_roundtrip(table, expected=table, compression="gzip",
583 compression_level=5)
584
585 # Check that the user can provide a compression per column
586 _check_roundtrip(table, expected=table,
587 compression={'a': "gzip", 'b': "snappy"})
588
589 # Check that the user can provide a compression level per column
590 _check_roundtrip(table, expected=table, compression="gzip",
591 compression_level={'a': 2, 'b': 3})
592
593 # Check if both LZ4 compressors are working
594 # (level < 3 -> fast, level >= 3 -> HC)
595 _check_roundtrip(table, expected=table, compression="lz4",
596 compression_level=1)
597
598 _check_roundtrip(table, expected=table, compression="lz4",
599 compression_level=9)
600
601 # Check that specifying a compression level for a codec which does allow
602 # specifying one, results into an error.
603 # Uncompressed, snappy and lzo do not support specifying a compression
604 # level.
605 # GZIP (zlib) allows for specifying a compression level but as of up
606 # to version 1.2.11 the valid range is [-1, 9].
607 invalid_combinations = [("snappy", 4), ("gzip", -1337),
608 ("None", 444), ("lzo", 14)]
609 buf = io.BytesIO()
610 for (codec, level) in invalid_combinations:
611 with pytest.raises((ValueError, OSError)):
612 _write_table(table, buf, compression=codec,
613 compression_level=level)
614
615
616def test_lz4_raw_compression_alias():

Callers

nothing calls this directly

Calls 5

_check_roundtripFunction · 0.90
_write_tableFunction · 0.90
listFunction · 0.85
mapFunction · 0.85
arrayMethod · 0.45

Tested by

no test coverage detected