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

Class IpcFixture

python/pyarrow/tests/test_ipc.py:44–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44class IpcFixture:
45 write_stats = None
46
47 def __init__(self, sink_factory=lambda: io.BytesIO()):
48 self._sink_factory = sink_factory
49 self.sink = self.get_sink()
50
51 def get_sink(self):
52 return self._sink_factory()
53
54 def get_source(self):
55 return self.sink.getvalue()
56
57 def write_batches(self, num_batches=5, as_table=False):
58 nrows = 5
59 schema = pa.schema([('one', pa.float64()), ('two', pa.utf8())])
60
61 writer = self._get_writer(self.sink, schema)
62
63 batches = []
64 for i in range(num_batches):
65 batch = pa.record_batch(
66 [[random.random() for _ in range(nrows)],
67 ['foo', None, 'bar', 'bazbaz', 'qux']],
68 schema=schema)
69 batches.append(batch)
70
71 if as_table:
72 table = pa.Table.from_batches(batches)
73 writer.write_table(table)
74 else:
75 for batch in batches:
76 writer.write_batch(batch)
77
78 self.write_stats = writer.stats
79 writer.close()
80 return batches
81
82
83class FileFormatFixture(IpcFixture):

Callers 1

ipc_fixtureFunction · 0.85

Calls

no outgoing calls

Tested by 1

ipc_fixtureFunction · 0.68