Ë
    kQêj¤  ã                   ó  — d dl mZ d dlmZmZmZmZmZ d dlm	Z	m
Z
 d dlZddlmZ  G d„ d«      Zd	ej                   d
eej"                  ej                   f   fd„Zed
ej&                  fd„«       Zej+                  ej"                  «      dej"                  d
ej&                  fd„«       Zej+                  ej&                  «      dej&                  d
ej&                  fd„«       Zej+                  e«      ded
ej&                  fd„«       Zy)é    )Úsingledispatch)ÚAsyncIteratorÚListÚOptionalÚTupleÚUnion)Ú
LanceModelÚmodel_to_dictNé   )ÚRecordBatchStreamc                   ó  — e Zd ZdZ	 ddeeej                  f   dee	   fd„Z
edej                  deej                     dd fd	„«       Zdeej                     fd
„Zd„ Zdej                  fd„Ze	 ddej                  dee	   fd„«       Zy)ÚAsyncRecordBatchReaderzo
    An async iterator over a stream of RecordBatches.

    Also allows access to the schema of the stream
    NÚinnerÚmax_batch_lengthc                 óô   — |  t        |t        j                  «      r)| j                  ||«      | _        |j
                  | _        yt        |t        «      r|| _        |j
                  | _        yt        d«      ‚)zÔ

        Attributes
        ----------
        schema : pa.Schema
            The schema of the batches produced by the stream.
            Accessing the schema does not consume any data from the stream
        z,inner must be a RecordBatchStream or a TableN)Ú
isinstanceÚpaÚTableÚ_async_iter_from_tableÚ_innerÚschemar   Ú	TypeError)Úselfr   r   s      úR/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/lancedb/arrow.pyÚ__init__zAsyncRecordBatchReader.__init__   s^   € ñ 	Ü�eœRŸX™XÔ&Ø×5Ñ5°eÐ=MÓNˆDŒKØ%*§\¡\ˆD�KÜ˜Ô0Ô1ØˆDŒKØ%*§\¡\ˆD�KäÐJÓKÐKó    r   ÚbatchesÚreturnc                 óD   — | j                  | «      }||_        ||_        |S )z<Wrap a transformed stream without consuming its first batch.)Ú__new__r   r   )Úclsr   r   Úreaders       r   Ú_from_batchesz$AsyncRecordBatchReader._from_batches+   s%   € ð
 —‘˜SÓ!ˆØˆŒØˆŒØˆr   c              ƒ   óD   K  — | 2 �cg c3 d{  –—† }|‘Œ7 Œ6 c}S c c}w ­w)zÓ
        Read all the record batches from the stream

        This consumes the entire stream and returns a list of record batches

        If there are a lot of results this may consume a lot of memory
        N© )r   Úbatchs     r   Úread_allzAsyncRecordBatchReader.read_all5   s#   è ø€ ð *.×.Ô. ’Ð.øÒ.Ð.ùÒ.ùs$   ‚ ‡‰�
Ž‘•—˜ c                 ó   — | S ©Nr%   ©r   s    r   Ú	__aiter__z AsyncRecordBatchReader.__aiter__?   s   € Øˆr   c              ƒ   óR   K  — | j                   j                  «       ƒ d {  –—† S 7 Œ­wr)   )r   Ú	__anext__r*   s    r   r-   z AsyncRecordBatchReader.__anext__B   s   è ø€ Ø—[‘[×*Ñ*Ó,×,Ð,Ð,ús   ‚' %¡'Útablec                óH   K  — | j                  |¬«      }|D ]  }|­–— Œ	 y­w)z¢
        Create an AsyncRecordBatchReader from a Table

        This is useful when you have a Table that you want to iterate
        over asynchronously
        )Úmax_chunksizeN)Ú
to_batches)r.   r   r   r&   s       r   r   z-AsyncRecordBatchReader._async_iter_from_tableE   s0   è ø€ ð ×"Ñ"Ð1AÐ"ÓBˆØò 	ˆEØŒKñ	ùs   ‚ "r)   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   Úintr   ÚclassmethodÚSchemar   ÚRecordBatchr#   r   r'   r+   r-   Ústaticmethodr   r%   r   r   r   r      sË   „ ñð +/ñLàÐ&¨¯©Ð0Ñ1ðLð # 3™-óLð. ðØ—Y‘YðØ)6°r·~±~Ñ)Fðà	!òó ðð/  R§^¡^Ñ 4ó /òð- §¡ó -ð à;?ñØ�x‰xðØ+3°C©=òó ñr   r   r"   r   c                 óÞ   ‡ ‡— t        ‰ t        j                  «      st        d«      ‚‰ j	                  «       Šˆˆ fd„}‰t        j                  j                  ‰j                   |«       «      fS )Nz"reader must be a RecordBatchReaderc               3   ó.   •K  — ‰ –— ‰E d {  –—†  y 7 Œ­wr)   r%   )r&   r"   s   €€r   Úall_batchesz peek_reader.<locals>.all_batches[   s   øè ø€ ØŠØ×Òús   ƒ
�Ž)r   r   ÚRecordBatchReaderr   Úread_next_batchÚfrom_batchesr   )r"   r=   r&   s   ` @r   Úpeek_readerrA   T   sZ   ù€ ô �fœb×2Ñ2Ô3ÜÐ<Ó=Ð=Ø×"Ñ"Ó$€Eõð ”"×&Ñ&×3Ñ3°E·L±LÁ+Ã-ÓPÐPÐPr   c                 ó0   — t        dt        | «      › �«      ‚)z+Convert a single data object to a pa.Table.z"to_arrow not implemented for type )ÚNotImplementedErrorÚtype©Údatas    r   Úto_arrowrG   b   s   € ô Ð BÄ4ÈÃ:À,ÐOÓ
PÐPr   rF   c                 óB   — t         j                  j                  | g«      S r)   )r   r   r@   rE   s    r   Ú_arrow_from_batchrI   h   s   € ä�8‰8× Ñ  $ Ó(Ð(r   c                 ó   — | S r)   r%   rE   s    r   Ú_arrow_from_tablerK   m   s   € à€Kr   c                 ó6  — | st        d«      ‚t        | d   t        «      rV| d   j                  j	                  «       }| D �cg c]  }t        |«      ‘Œ }}t        j                  j                  ||¬«      S t        j                  j                  | «      S c c}w )Nz4Cannot create table from empty list without a schemar   )r   )	Ú
ValueErrorr   r	   Ú	__class__Úto_arrow_schemar
   r   r   Úfrom_pylist)rF   r   ÚdÚdictss       r   Ú_arrow_from_listrS   r   sƒ   € áÜÐOÓPÐPä�$�q‘'œ:Ô&Ø�a‘×"Ñ"×2Ñ2Ó4ˆØ+/Ö0 a”˜qÕ!Ð0ˆÐ0Ü�x‰x×#Ñ# E°&Ð#Ó9Ð9ä�8‰8×Ñ Ó%Ð%ùò 1s   ÁB)Ú	functoolsr   Útypingr   r   r   r   r   Úlancedb.pydanticr	   r
   Úpyarrowr   Ú_lancedbr   r   r>   r9   rA   r   rG   ÚregisterrI   rK   ÚlistrS   r%   r   r   ú<module>r[      s  ðõ %ß >Õ >ç 6Û å '÷Dñ DðNQØ× Ñ ðQà
ˆ2�>‰>˜2×/Ñ/Ð/Ñ0óQð ðQ�b—h‘hò Qó ðQð
 
×Ñ�2—>‘>Ó"ð)˜BŸN™Nð )¨r¯x©xò )ó #ð)ð 
×Ñ�2—8‘8Óð˜BŸH™Hð ¨¯©ò ó ðð 
×Ñ�4Óð	&˜4ð 	& B§H¡Hò 	&ó ñ	&r   