U
    ÷Õ/e8  ã                   @  sŠ   d dl mZ d dlZd dlmZmZ ejdk r6edƒ‚e ej	¡dd„ ƒZ
e ej	¡dd	„ ƒZe ej¡d
d„ ƒZe ej¡dd„ ƒZdS )é    )ÚannotationsN)Údask_deserializeÚdask_serializez0.10zLNeed pyarrow >= 0.10 . See https://arrow.apache.org/docs/python/install.htmlc                 C  sB   t  ¡ }t  || j¡}| | ¡ | ¡  | ¡ }i }|g}||fS ©N)ÚpyarrowÚBufferOutputStreamÚRecordBatchStreamWriterÚschemaZwrite_batchÚcloseÚgetvalue)ÚbatchÚsinkÚwriterÚbufÚheaderÚframes© r   ú>/tmp/pip-unpacked-wheel-g426oqom/distributed/protocol/arrow.pyÚserialize_batch   s    
r   c                 C  s    |d }t  t  |¡¡}| ¡ S ©Nr   )r   ÚRecordBatchStreamReaderÚBufferReaderZread_next_batch©r   r   ZblobÚreaderr   r   r   Údeserialize_batch   s    r   c                 C  sB   t  ¡ }t  || j¡}| | ¡ | ¡  | ¡ }i }|g}||fS r   )r   r   r   r	   Zwrite_tabler
   r   )Ztblr   r   r   r   r   r   r   r   Úserialize_table!   s    
r   c                 C  s    |d }t  t  |¡¡}| ¡ S r   )r   r   r   Zread_allr   r   r   r   Údeserialize_table-   s    r   )Ú
__future__r   r   Zdistributed.protocol.serializer   r   Ú__version__ÚImportErrorÚregisterZRecordBatchr   r   ZTabler   r   r   r   r   r   Ú<module>   s   
ÿ






