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

Function _export_import_batch_reader

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

Source from the content-addressed store, hash-verified

444
445
446def _export_import_batch_reader(ptr_stream, reader_factory):
447 # Prepare input
448 batches = make_batches()
449 schema = batches[0].schema
450
451 reader = reader_factory(schema, batches)
452 reader._export_to_c(ptr_stream)
453 # Delete and recreate C++ object from exported pointer
454 del reader, batches
455
456 reader_new = pa.RecordBatchReader._import_from_c(ptr_stream)
457 assert reader_new.schema == schema
458 got_batches = list(reader_new)
459 del reader_new
460 assert got_batches == make_batches()
461
462 # Test read_pandas()
463 if pd is not None:
464 batches = make_batches()
465 schema = batches[0].schema
466 expected_df = pa.Table.from_batches(batches).to_pandas()
467
468 reader = reader_factory(schema, batches)
469 reader._export_to_c(ptr_stream)
470 del reader, batches
471
472 reader_new = pa.RecordBatchReader._import_from_c(ptr_stream)
473 got_df = reader_new.read_pandas()
474 del reader_new
475 tm.assert_frame_equal(expected_df, got_df)
476
477
478def 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