我的目标是序列化RecordBatch
,通过websocket频道发送
在接收端反序列化。你知道吗
在接收器端,在接收到数据包并重构之后
一个带有pa.py_buffer
的pyarrow.lib.Buffer
对象,我
无法将其反序列化回RecordBatch
。你知道吗
远离websocket的样板文件这是一个总结我要做的事情的片段:
import pyarrow as pa
indicators = [(1, 'A'), (2, 'B')]
id = pa.int16()
name = pa.string()
data = pa.array(indicators, type=pa.struct([('id', id), ('name', name)]))
batch = pa.RecordBatch.from_arrays([data], ['indicators'])
buffer = batch.serialize()
# How to get back a RecordBatch from buffer?
#
# ???
当使用这样的
serialize
方法时,您可以使用read_record_batch
函数给定的已知模式:但这意味着您需要了解接收方的模式。要将其封装在序列化数据中,请改用
RecordBatchStreamWriter
:参见https://arrow.apache.org/docs/python/ipc.html上的文档
相关问题 更多 >
编程相关推荐