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

Function test_mock_output_stream

python/pyarrow/tests/test_io.py:1038–1069  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1036
1037
1038def test_mock_output_stream():
1039 # Make sure that the MockOutputStream and the BufferOutputStream record the
1040 # same size
1041
1042 # 10 bytes
1043 val = b'dataabcdef'
1044
1045 f1 = pa.MockOutputStream()
1046 f2 = pa.BufferOutputStream()
1047
1048 K = 1000
1049 for i in range(K):
1050 f1.write(val)
1051 f2.write(val)
1052
1053 assert f1.size() == len(f2.getvalue())
1054
1055 # Do the same test with a table
1056 record_batch = pa.RecordBatch.from_arrays([pa.array([1, 2, 3])], ['a'])
1057
1058 f1 = pa.MockOutputStream()
1059 f2 = pa.BufferOutputStream()
1060
1061 stream_writer1 = pa.RecordBatchStreamWriter(f1, record_batch.schema)
1062 stream_writer2 = pa.RecordBatchStreamWriter(f2, record_batch.schema)
1063
1064 stream_writer1.write_batch(record_batch)
1065 stream_writer2.write_batch(record_batch)
1066 stream_writer1.close()
1067 stream_writer2.close()
1068
1069 assert f1.size() == len(f2.getvalue())
1070
1071
1072# ----------------------------------------------------------------------

Callers

nothing calls this directly

Calls 8

lenFunction · 0.85
BufferOutputStreamMethod · 0.80
write_batchMethod · 0.80
writeMethod · 0.45
sizeMethod · 0.45
arrayMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected