
    ch&                        S SK r S SKrS SKJrJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJr  S SKJr   " S S\R,                  5      rSr\S-   S-   r " S S	\R4                  5      r " S
 S\R8                  5      r " S S\R<                  5      rS r S r!SS.S jr"S\ S3\"l#        SSS.S jr$SSS.S jr%S\ S3\%l#        S SSS.S jjr&SSS.S jr'SS.S jr(g)!    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                   (    \ rS rSrSrSSS.S jrSrg)RecordBatchStreamReader"   a  
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                :    [        U5      nU R                  XUS9  g )Nr    _ensure_default_ipc_read_options_open)selfsourcer   r   s       ^C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\pyarrow/ipc.py__init__ RecordBatchStreamReader.__init__2   s    27;

6
D     __name__
__module____qualname____firstlineno____doc__r!   __static_attributes__r$   r#   r    r   r   "   s     +/D 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.
zmetadata : 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                   ,    \ rS rSrS\ 3rSS.S jrSrg)RecordBatchStreamWriterS   z.Writer for the Arrow streaming binary format

Nr   c                :    [        U5      nU R                  XUS9  g Nr0   _get_legacy_format_defaultr   )r   sinkschemar   s       r    r!    RecordBatchStreamWriter.__init__X   s    ,W5

4
1r#   r$   )r&   r'   r(   r)   _ipc_writer_class_docr*   r!   r+   r$   r#   r    r.   r.   S   s#     G 15 2 2r#   r.   c                   ,    \ rS rSrSrSSSS.S jjrSrg)RecordBatchFileReader]   a  
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                :    [        U5      nU R                  XX4S9  g )Nfooter_offsetr   r   r   )r   r   r>   r   r   s        r    r!   RecordBatchFileReader.__init__p   s"    27;

6" 	 	=r#   r$   Nr%   r$   r#   r    r:   r:   ]   s    $=d!= =r#   r:   c                   .    \ rS rSrS\ 3rSSS.S jrSrg)RecordBatchFileWriterw   z/Writer to create the Arrow binary file format

Nr   metadatac                :    [        U5      nU R                  XX4S9  g NrD   r3   )r   r5   r6   r   rE   s        r    r!   RecordBatchFileWriter.__init__}   s    ,W5

4
Dr#   r$   )r&   r'   r(   r)   _ipc_file_writer_class_docr*   r!   r+   r$   r#   r    rB   rB   w   s'      G 15t E Er#   rB   c                    U (       a.  [        U [        5      (       d  [        S[        U 5       35      eU $ [        R
                  n[        [        [        R                  R                  SS5      5      5      n[        [        [        R                  R                  SS5      5      5      (       a  [        R                  n[        UUS9$ )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   rO   rN   s      r    r4   r4      s    '?33<T']OLMM&))S ;SABC C

?EFGG*--->,<> >r#   c                     U (       a,  [        U [        5      (       d  [        S[        U 5       35      eU =(       d
    [        5       $ )Nzexpected IpcReadOptions, got )rP   r   rQ   rR   r0   s    r    r   r      s6    z'>::7WGHH&n&&r#   r0   c                    [        XUS9$ r2   )r.   )r5   r6   r   s      r    
new_streamr\      s    "4+24 4r#   z5Create an Arrow columnar IPC stream writer instance

zS

Returns
-------
writer : RecordBatchStreamWriter
    A writer for the given sink
r   c                    [        XUS9$ )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_streamr^      s    & #6/:< <r#   rD   c                    [        XX#S9$ rG   )rB   )r5   r6   r   rE   s       r    new_filer`      s     wRRr#   z3Create an Arrow columnar IPC file writer instance

zQ

Returns
-------
writer : RecordBatchFileWriter
    A writer for the given sink
c                    [        XX#S9$ )ai  
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
r=   )r:   )r   r>   r   r   s       r    	open_filerb      s    , !2 2r#   nthreadspreserve_indexc                <   [         R                  R                  XUS9n[         R                  " 5       n[         R                  " XCR
                  5       nUR                  U5        SSS5        UR                  5       $ ! , (       d  f       UR                  5       $ = f)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.
rc   N)paRecordBatchfrom_pandasBufferOutputStreamr.   r6   write_batchgetvalue)dfrd   re   batchr5   writers         r    serialize_pandasrp      sy    ( NN&&r6D ' FE  "D		#	#D,,	765! 
8==? 
8	7==?s   A>>
BTuse_threadsc                    [         R                  " U 5      n[         R                  " U5       nUR                  5       nSSS5        WR	                  US9$ ! , (       d  f       N= f)aZ  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
Nrq   )rg   BufferReaderr   read_all	to_pandas)bufrr   buffer_readerreadertables        r    deserialize_pandasr{     sM     OOC(M		#	#M	2f! 
3??{?33 
3	2s   A
A#r@   ))rV   pyarrowrg   pyarrow.libr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   lib_RecordBatchStreamReaderr   r8   rI   _RecordBatchStreamWriterr.   _RecordBatchFileReaderr:   _RecordBatchFileWriterrB   r4   r   r\   r*   r^   r`   rb   rp   r{   r$   r#   r    <module>r      s)  ( 
 A A A A A Ec:: E*) $ 
,, 2c:: 2=C66 =4EC66 E>' )- 4
   	
  $(T <. '+T S   	 2Tt 26 &*$ 8 ,0 4r#   