B
    °F.\A  ã               @   s’   d dl mZmZmZ ddlmZmZ d dlZejdk r>e	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 )é    )Úprint_functionÚdivisionÚabsolute_importé   )Údask_serializeÚdask_deserializeNz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)ZbatchÚsinkÚwriterÚbufÚheaderÚframes© r   ú9lib/python3.7/site-packages/distributed/protocol/arrow.pyÚserialize_batch   s    
r   c             C   s    |d }t  t  |¡¡}| ¡ S )Nr   )r   ÚRecordBatchStreamReaderÚBufferReaderZread_next_batch)r   r   ÚblobÚreaderr   r   r   Údeserialize_batch   s    r   c             C   sB   t  ¡ }t  || j¡}| | ¡ | ¡  | ¡ }i }|g}||fS )N)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 )Nr   )r   r   r   Zread_all)r   r   r   r   r   r   r   Údeserialize_table*   s    r   )Z
__future__r   r   r   Z	serializer   r   r   Ú__version__ÚImportErrorÚregisterZRecordBatchr   r   ZTabler   r   r   r   r   r   Ú<module>   s   
