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

Function _export_import_batch_reader

python/pyarrow/tests/test_cffi.py:413–442  ·  view source on GitHub ↗
(ptr_stream, reader_factory)

Source from the content-addressed store, hash-verified

411
412
413def _export_import_batch_reader(ptr_stream, reader_factory):
414 # Prepare input
415 batches = make_batches()
416 schema = batches[0].schema
417
418 reader = reader_factory(schema, batches)
419 reader._export_to_c(ptr_stream)
420 # Delete and recreate C++ object from exported pointer
421 del reader, batches
422
423 reader_new = pa.RecordBatchReader._import_from_c(ptr_stream)
424 assert reader_new.schema == schema
425 got_batches = list(reader_new)
426 del reader_new
427 assert got_batches == make_batches()
428
429 # Test read_pandas()
430 if pd is not None:
431 batches = make_batches()
432 schema = batches[0].schema
433 expected_df = pa.Table.from_batches(batches).to_pandas()
434
435 reader = reader_factory(schema, batches)
436 reader._export_to_c(ptr_stream)
437 del reader, batches
438
439 reader_new = pa.RecordBatchReader._import_from_c(ptr_stream)
440 got_df = reader_new.read_pandas()
441 del reader_new
442 tm.assert_frame_equal(expected_df, got_df)
443
444
445def make_ipc_stream_reader(schema, batches):

Callers 1

Calls 3

listFunction · 0.85
make_batchesFunction · 0.70
read_pandasMethod · 0.45

Tested by

no test coverage detected