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

Function test_compression_level

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

Source from the content-addressed store, hash-verified

586
587
588def test_compression_level():
589 arr = pa.array(list(map(int, range(1000))))
590 data = [arr, arr]
591 table = pa.Table.from_arrays(data, names=['a', 'b'])
592
593 # Check one compression level.
594 _check_roundtrip(table, expected=table, compression="gzip",
595 compression_level=1)
596
597 # Check another one to make sure that compression_level=1 does not
598 # coincide with the default one in Arrow.
599 _check_roundtrip(table, expected=table, compression="gzip",
600 compression_level=5)
601
602 # Check that the user can provide a compression per column
603 _check_roundtrip(table, expected=table,
604 compression={'a': "gzip", 'b': "snappy"})
605
606 # Check that the user can provide a compression level per column
607 _check_roundtrip(table, expected=table, compression="gzip",
608 compression_level={'a': 2, 'b': 3})
609
610 # Check if both LZ4 compressors are working
611 # (level < 3 -> fast, level >= 3 -> HC)
612 _check_roundtrip(table, expected=table, compression="lz4",
613 compression_level=1)
614
615 _check_roundtrip(table, expected=table, compression="lz4",
616 compression_level=9)
617
618 # Check that specifying a compression level for a codec which does allow
619 # specifying one, results into an error.
620 # Uncompressed, snappy and lzo do not support specifying a compression
621 # level.
622 # GZIP (zlib) allows for specifying a compression level but as of up
623 # to version 1.2.11 the valid range is [-1, 9].
624 invalid_combinations = [("snappy", 4), ("gzip", -1337),
625 ("None", 444), ("lzo", 14)]
626 buf = io.BytesIO()
627 for (codec, level) in invalid_combinations:
628 with pytest.raises((ValueError, OSError)):
629 _write_table(table, buf, compression=codec,
630 compression_level=level)
631
632
633def 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