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

Function test_export_import_field

python/pyarrow/tests/test_cffi.py:161–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

159
160@needs_cffi
161def test_export_import_field():
162 c_schema = ffi.new("struct ArrowSchema*")
163 ptr_schema = int(ffi.cast("uintptr_t", c_schema))
164
165 gc.collect() # Make sure no Arrow data dangles in a ref cycle
166 old_allocated = pa.total_allocated_bytes()
167
168 field = pa.field("test", pa.list_(pa.int32()), nullable=True)
169 field._export_to_c(ptr_schema)
170 assert pa.total_allocated_bytes() > old_allocated
171 # Delete and recreate C++ object from exported pointer
172 del field
173 assert pa.total_allocated_bytes() > old_allocated
174
175 field_new = pa.Field._import_from_c(ptr_schema)
176 assert field_new == pa.field("test", pa.list_(pa.int32()), nullable=True)
177 assert pa.total_allocated_bytes() == old_allocated
178
179 # Now released
180 with assert_schema_released:
181 pa.Field._import_from_c(ptr_schema)
182
183
184def check_export_import_array(array_type, exporter, importer):

Callers

nothing calls this directly

Calls 3

newMethod · 0.45
castMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected