§
    !P„jƒ%  ã                   ó¤  — d dl Z d dlZd dlmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ d dlmZ  G d„ dej        ¦  «        ZdZedz   dz   Z G d„ d	ej        ¦  «        Z G d
„ dej        ¦  «        Z G d„ dej        ¦  «        Zd„ Z d„ Z!ddœd„Z"de› d�e"_#        dddœd„Z$dddœd„Z%de› d�e%_#        d dddœd„Z&dddœd„Z'ddœd„Z(dS )!é    N)ÚIpcReadOptionsÚIpcWriteOptionsÚ	ReadStatsÚ
WriteStatsÚMessageÚMessageReaderÚRecordBatchReaderÚ_ReadPandasMixinÚMetadataVersionÚ	AlignmentÚread_messageÚread_record_batchÚread_schemaÚread_tensorÚwrite_tensorÚget_record_batch_sizeÚget_tensor_sizec                   ó    — e Zd ZdZdddœd„ZdS )ÚRecordBatchStreamReadera  
    Reader for the Arrow streaming binary format.

    Parameters
    ----------
    source : bytes/buffer-like, pyarrow.NativeFile, or file-like Python object
        Either an in-memory buffer, or a readable file object.
        If you want to use memory map use MemoryMappedFile as source.
    options : pyarrow.ipc.IpcReadOptions
        Options for IPC deserialization.
        If None, default values will be used.
    memory_pool : MemoryPool, default None
        If None, default memory pool is used.
    N©ÚoptionsÚmemory_poolc                óT   — t          |¦  «        }|                      |||¬¦  «         d S )Nr   ©Ú _ensure_default_ipc_read_optionsÚ_open)ÚselfÚsourcer   r   s       úP/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/pyarrow/ipc.pyÚ__init__z RecordBatchStreamReader.__init__2   s-   € Ý2°7Ñ;Ô;ˆØ�
Š
�6 7¸ˆ
ÑDÔDÐDÐDÐDó    ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    © r!   r   r   r   "   sE   € € € € € ðð ð +/¸Dð Eð Eð Eð Eð Eð Eð Er!   r   aO  Parameters
----------
sink : str, pyarrow.NativeFile, or file-like Python object
    Either a file path, or a writable file object.
schema : pyarrow.Schema
    The Arrow schema for data to be written to the file.
options : pyarrow.ipc.IpcWriteOptions
    Options for IPC serialization.

    If None, default values will be used: the legacy format will not
    be used unless overridden by setting the environment variable
    ARROW_PRE_0_15_IPC_FORMAT=1, and the V5 metadata version will be
    used unless overridden by setting the environment variable
    ARROW_PRE_1_0_METADATA_VERSION=1.ú
zÎmetadata : dict | pyarrow.KeyValueMetadata, optional
    Key/value pairs (both must be bytes-like) that will be stored
    in the file footer and are retrievable via
    pyarrow.ipc.open_file(...).metadata.c                   ó$   — e Zd Zde› �Zddœd„ZdS )ÚRecordBatchStreamWriterz.Writer for the Arrow streaming binary format

N©r   c                óT   — t          |¦  «        }|                      |||¬¦  «         d S ©Nr+   ©Ú_get_legacy_format_defaultr   )r   ÚsinkÚschemar   s       r   r    z RecordBatchStreamWriter.__init__X   s-   € Ý,¨WÑ5Ô5ˆØ�
Š
�4˜¨ˆ
Ñ1Ô1Ð1Ð1Ð1r!   )r#   r$   r%   Ú_ipc_writer_class_docr&   r    r'   r!   r   r*   r*   S   sF   € € € € € ðàðð €Gð 15ð 2ð 2ð 2ð 2ð 2ð 2ð 2r!   r*   c                   ó"   — e Zd ZdZddddœd„ZdS )ÚRecordBatchFileReadera»  
    Class for reading Arrow record batch data from the Arrow binary file format

    Parameters
    ----------
    source : bytes/buffer-like, pyarrow.NativeFile, or file-like Python object
        Either an in-memory buffer, or a readable file object.
        If you want to use memory map use MemoryMappedFile as source.
    footer_offset : int, default None
        If the file is embedded in some larger file, this is the byte offset to
        the very end of the file data
    options : pyarrow.ipc.IpcReadOptions
        Options for IPC serialization.
        If None, default values will be used.
    memory_pool : MemoryPool, default None
        If None, default memory pool is used.
    Nr   c                óV   — t          |¦  «        }|                      ||||¬¦  «         d S )N©Úfooter_offsetr   r   r   )r   r   r7   r   r   s        r   r    zRecordBatchFileReader.__init__p   s=   € å2°7Ñ;Ô;ˆØ�
Š
�6¨Ø"°ð 	ñ 	=ô 	=ð 	=ð 	=ð 	=r!   ©Nr"   r'   r!   r   r4   r4   ]   sA   € € € € € ðð ð$=¸dØ!ð=ð =ð =ð =ð =ð =ð =r!   r4   c                   ó&   — e Zd Zde› �Zdddœd„ZdS )ÚRecordBatchFileWriterz/Writer to create the Arrow binary file format

N©r   Úmetadatac                óV   — t          |¦  «        }|                      ||||¬¦  «         d S ©Nr;   r.   )r   r0   r1   r   r<   s        r   r    zRecordBatchFileWriter.__init__}   s/   € Ý,¨WÑ5Ô5ˆØ�
Š
�4˜¨¸8ˆ
ÑDÔDÐDÐDÐDr!   )r#   r$   r%   Ú_ipc_file_writer_class_docr&   r    r'   r!   r   r:   r:   w   sO   € € € € € ð àð ð  €Gð 15¸tð Eð Eð Eð Eð Eð Eð Er!   r:   c                 ó¬  — | r6t          | t          ¦  «        st          dt          | ¦  «        › �¦  «        ‚| S t          j        }t          t          t          j	         
                    dd¦  «        ¦  «        ¦  «        }t          t          t          j	         
                    dd¦  «        ¦  «        ¦  «        rt          j        }t          ||¬¦  «        S )Nzexpected IpcWriteOptions, got ÚARROW_PRE_0_15_IPC_FORMATÚ0ÚARROW_PRE_1_0_METADATA_VERSION)Úuse_legacy_formatÚmetadata_version)Ú
isinstancer   Ú	TypeErrorÚtyper   ÚV5ÚboolÚintÚosÚenvironÚgetÚV4)r   rE   rD   s      r   r/   r/   ‚   sÀ   € Øð Ý˜'¥?Ñ3Ô3ð 	NÝÐL½TÀ'¹]¼]ÐLÐLÑMÔMÐMØˆå&Ô)Ðå�S•”—’Ð ;¸SÑAÔAÑBÔBÑCÔCð å�C•”
—’Ð?ÀÑEÔEÑFÔFÑGÔGð .Ý*Ô-ÐÝÐ->Ø,<ð>ñ >ô >ð >r!   c                 óŽ   — | r4t          | t          ¦  «        st          dt          | ¦  «        › �¦  «        ‚| pt          ¦   «         S )Nzexpected IpcReadOptions, got )rF   r   rG   rH   r+   s    r   r   r   ‘   sK   € Øð I•z '­>Ñ:Ô:ð IÝÐG½¸W¹¼ÐGÐGÑHÔHÐHØÐ&•nÑ&Ô&Ð&r!   r+   c                ó&   — t          | ||¬¦  «        S r-   )r*   )r0   r1   r   s      r   Ú
new_streamrR   —   s    € Ý" 4¨Ø+2ð4ñ 4ô 4ð 4r!   z5Create an Arrow columnar IPC stream writer instance

zS

Returns
-------
writer : RecordBatchStreamWriter
    A writer for the given sink
r   c                ó&   — t          | ||¬¦  «        S )a  
    Create reader for Arrow streaming format.

    Parameters
    ----------
    source : bytes/buffer-like, pyarrow.NativeFile, or file-like Python object
        Either an in-memory buffer, or a readable file object.
    options : pyarrow.ipc.IpcReadOptions
        Options for IPC serialization.
        If None, default values will be used.
    memory_pool : MemoryPool, default None
        If None, default memory pool is used.

    Returns
    -------
    reader : RecordBatchStreamReader
        A reader for the given source
    r   )r   )r   r   r   s      r   Úopen_streamrT   ¨   s"   € õ& # 6°7Ø/:ð<ñ <ô <ð <r!   r;   c                ó(   — t          | |||¬¦  «        S r>   )r:   )r0   r1   r   r<   s       r   Únew_filerV   ¿   s   € Ý   v°wÈÐRÑRÔRÐRr!   z3Create an Arrow columnar IPC file writer instance

zQ

Returns
-------
writer : RecordBatchFileWriter
    A writer for the given sink
c                ó(   — t          | |||¬¦  «        S )a±  
    Create reader for Arrow file format.

    Parameters
    ----------
    source : bytes/buffer-like, pyarrow.NativeFile, or file-like Python object
        Either an in-memory buffer, or a readable file object.
    footer_offset : int, default None
        If the file is embedded in some larger file, this is the byte offset to
        the very end of the file data.
    options : pyarrow.ipc.IpcReadOptions
        Options for IPC serialization.
        If None, default values will be used.
    memory_pool : MemoryPool, default None
        If None, default memory pool is used.

    Returns
    -------
    reader : RecordBatchFileReader
        A reader for the given source
    r6   )r4   )r   r7   r   r   s       r   Ú	open_filerX   Ï   s%   € õ, !Ø˜mØ [ð2ñ 2ô 2ð 2r!   ©ÚnthreadsÚpreserve_indexc                ó"  — t           j                             | ||¬¦  «        }t          j        ¦   «         }t          j        ||j        ¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |                     ¦   «         S )a   
    Serialize a pandas DataFrame into a buffer protocol compatible object.

    Parameters
    ----------
    df : pandas.DataFrame
    nthreads : int, default None
        Number of threads to use for conversion to Arrow, default all CPUs.
    preserve_index : bool, default None
        The default of None will store the index as a column, except for
        RangeIndex which is stored as metadata only. If True, always
        preserve the pandas index data as a column. If False, no index
        information is saved and the result will have a default RangeIndex.

    Returns
    -------
    buf : buffer
        An object compatible with the buffer protocol.
    rY   N)ÚpaÚRecordBatchÚfrom_pandasÚBufferOutputStreamr*   r1   Úwrite_batchÚgetvalue)ÚdfrZ   r[   Úbatchr0   Úwriters         r   Úserialize_pandasrf   ê   sÀ   € õ( ŒN×&Ò& r°HØ6Dð 'ñ Fô F€EåÔ Ñ"Ô"€DÝ	Ô	# D¨%¬,Ñ	7Ô	7ð "¸6Ø×Ò˜5Ñ!Ô!Ð!ð"ð "ð "ñ "ô "ð "ð "ð "ð "ð "ð "øøøð "ð "ð "ð "à�=Š=‰?Œ?Ðs   ÁA2Á2A6Á9A6T©Úuse_threadsc                óÖ   — t          j        | ¦  «        }t          j        |¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   |                     |¬¦  «        S )a†  Deserialize a buffer protocol compatible object into a pandas DataFrame.

    Parameters
    ----------
    buf : buffer
        An object compatible with the buffer protocol.
    use_threads : bool, default True
        Whether to parallelize the conversion using multiple threads.

    Returns
    -------
    df : pandas.DataFrame
        The buffer deserialized as pandas DataFrame
    Nrg   )r]   ÚBufferReaderr   Úread_allÚ	to_pandas)Úbufrh   Úbuffer_readerÚreaderÚtables        r   Údeserialize_pandasrq     s™   € õ ”O CÑ(Ô(€MÝ	Ô	# MÑ	2Ô	2ð "°fØ—’Ñ!Ô!ˆð"ð "ð "ñ "ô "ð "ð "ð "ð "ð "ð "øøøð "ð "ð "ð "à�?Š? {ˆ?Ñ3Ô3Ð3s   ©A
Á
AÁAr8   ))rL   Úpyarrowr]   Úpyarrow.libr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   ÚlibÚ_RecordBatchStreamReaderr   r2   r?   Ú_RecordBatchStreamWriterr*   Ú_RecordBatchFileReaderr4   Ú_RecordBatchFileWriterr:   r/   r   rR   r&   rT   rV   rX   rf   rq   r'   r!   r   ú<module>ry      s#  ðð( 
€	€	€	à Ð Ð Ð ðAð Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Ð Ð Ð Ð Ð ðEð Eð Eð Eð E˜cÔ:ñ Eô Eð Eð*)Ð ð$ Ø
ñð,ñ,ð ð2ð 2ð 2ð 2ð 2˜cÔ:ñ 2ô 2ð 2ð=ð =ð =ð =ð =˜CÔ6ñ =ô =ð =ð4Eð Eð Eð Eð E˜CÔ6ñ Eô Eð Eð>ð >ð >ð'ð 'ð 'ð )-ð 4ð 4ð 4ð 4ð 4ð
	ð ð	ð 	ð 	€
Ô ð $(°Tð <ð <ð <ð <ð <ð. '+°Tð Sð Sð Sð Sð Sð	ð ð	ð 	ð 	€Ô ð2°TÀtð 2ð 2ð 2ð 2ð 2ð6 &*¸$ð ð ð ð ð ð8 ,0ð 4ð 4ð 4ð 4ð 4ð 4ð 4r!   