o
    bi                     @   st   d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
Zd dlmZmZ d dlmZ er0d dlZG dd deZdS )    )BytesIO)TYPE_CHECKINGAnyDictIteratorListOptionalUnionN)BlockBlockAccessor)FileBasedDatasourcec                       sj   e Zd ZdZdZdgZ	ddeeee f de	e
eef  f fddZd	d
dedee fddZ  ZS )NumpyDatasourcez6Numpy datasource, for reading and writing Numpy files.datanpyNpathsnumpy_load_argsc                    s*   t  j|fi | |d u ri }|| _d S N)super__init__r   )selfr   r   file_based_datasource_kwargs	__class__ b/home/ubuntu/.local/lib/python3.10/site-packages/ray/data/_internal/datasource/numpy_datasource.pyr      s   
zNumpyDatasource.__init__fzpyarrow.NativeFilepathreturnc                 c   sL    t  }| }|| |d tdtj|fddi| jiV  d S )Nr   r   allow_pickleT)	r   readallwriteseekr   batch_to_blocknploadr   )r   r   r   bufr   r   r   r   _read_stream    s   


zNumpyDatasource._read_streamr   )__name__
__module____qualname____doc___COLUMN_NAME_FILE_EXTENSIONSr	   strr   r   r   r   r   r   r
   r&   __classcell__r   r   r   r   r      s    "r   )ior   typingr   r   r   r   r   r   r	   numpyr#   ray.data.blockr
   r   )ray.data.datasource.file_based_datasourcer   pyarrowr   r   r   r   r   <module>   s    $