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

Function test_compressed_recordbatch_stream

python/pyarrow/tests/test_io.py:1810–1825  ·  view source on GitHub ↗
(compression)

Source from the content-addressed store, hash-verified

1808 ["bz2", "brotli", "gzip", "lz4", "zstd"]
1809)
1810def test_compressed_recordbatch_stream(compression):
1811 if not Codec.is_available(compression):
1812 pytest.skip(f"{compression} support is not built")
1813
1814 # ARROW-4836: roundtrip a RecordBatch through a compressed stream
1815 table = pa.Table.from_arrays([pa.array([1, 2, 3, 4, 5])], ['a'])
1816 raw = pa.BufferOutputStream()
1817 stream = pa.CompressedOutputStream(raw, compression)
1818 writer = pa.RecordBatchStreamWriter(stream, table.schema)
1819 writer.write_table(table, max_chunksize=3)
1820 writer.close()
1821 stream.close() # Flush data
1822 buf = raw.getvalue()
1823 stream = pa.CompressedInputStream(pa.BufferReader(buf), compression)
1824 got_table = pa.RecordBatchStreamReader(stream).read_all()
1825 assert got_table == table
1826
1827
1828# ----------------------------------------------------------------------

Callers

nothing calls this directly

Calls 7

BufferOutputStreamMethod · 0.80
BufferReaderMethod · 0.80
arrayMethod · 0.45
write_tableMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected