Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions python/pyfory/tests/test_cross_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ def test_record_batch(data_file_path):
record_batch_bytes = f.read()
buf = pa.py_buffer(record_batch_bytes)
reader = pa.ipc.open_stream(buf)
foo_schema_without_meta = pa.schema(
[pa.field(f.name, f.type, f.nullable) for f in create_foo_schema()]
)
foo_schema_without_meta = pa.schema([pa.field(f.name, f.type, f.nullable) for f in create_foo_schema()])
assert reader.schema == foo_schema_without_meta
# debug_print(f"reader.schema {reader.schema}")
batches = [batch for batch in reader]
Expand Down Expand Up @@ -404,9 +402,7 @@ def test_serialize_arrow_out_of_band(int_band_file, out_of_band_file):
objects = fory.deserialize(in_band_buffer, buffers=buffers)
assert objects == [batch, table]
buffer_objects = []
in_band_buffer = fory.serialize(
[batch, table], buffer_callback=buffer_objects.append
)
in_band_buffer = fory.serialize([batch, table], buffer_callback=buffer_objects.append)
buffers = [o.to_buffer() for o in buffer_objects]
with open(int_band_file, "wb+") as f:
f.write(in_band_buffer)
Expand Down Expand Up @@ -584,9 +580,7 @@ def xwrite(self, buffer, value):
self.fory.xserialize_ref(buffer, value.f3)

def xread(self, buffer):
obj = ComplexObject1(
*([None] * len(typing.get_type_hints(ComplexObject1).keys()))
)
obj = ComplexObject1(*([None] * len(typing.get_type_hints(ComplexObject1).keys())))
self.fory.ref_resolver.reference(obj)
obj.f1 = self.fory.xdeserialize_ref(buffer)
obj.f2 = self.fory.xdeserialize_ref(buffer)
Expand Down Expand Up @@ -660,10 +654,7 @@ def buffer_callback(binary_object):
# in_band_bytes size may be different because it may contain language-specific meta.
debug_print(f"{len(serialized), len(in_band_bytes)}")
debug_print(f"deserialized from other language {new_obj}")
debug_print(
f"deserialized from python "
f"{fory.deserialize(serialized, [o.to_buffer() for o in buffer_objects])}"
)
debug_print(f"deserialized from python {fory.deserialize(serialized, [o.to_buffer() for o in buffer_objects])}")
fory.deserialize(serialized, [o.to_buffer() for o in buffer_objects])
with open(in_band_file_path, "wb+") as f:
f.write(serialized)
Expand All @@ -676,6 +667,12 @@ def buffer_callback(binary_object):


if __name__ == "__main__":
"""This file will be executed by CrossLanguageTest.java in fory-core/fory-format module and
fory_xlang_test.go in go/fory module
The test cases in this file are used to test the cross-language serialization and deserialization
functionality.
"""

import sys

print(f"Execute {sys.argv}")
Expand Down
Loading