Ë
    kQêj  ã                  ó<  — d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZ ddlmZ  ed«      Z G d„ d	ee   ee   «      Z G d
„ de	e   ee   «      Zdd„Z G d„ dee   «      Z G d„ de«      Z G d„ de«      Z G d„ de	e   «      Z G d„ de«      Z G d„ de«      Zy)z"Lazy, resumable resource listings.é    )ÚannotationsN)ÚAnyÚAsyncIteratorÚCallableÚGenericÚIteratorÚOptionalÚTypeVaré   )ÚLOOPÚTc                  ó>   — e Zd ZdZd„ fd	d„Zd
d„Zdd„Zdd„Zdd„Zy)ÚAsyncListinga(  A lazy async iterator with inspectable pagination state.

    Returned by connection resource-listing methods. For example::

        async for name in connection.list_views(page_limit=20):
            print(name)

    Requests happen during iteration; request errors terminate the iterator.
    c                ó   — | S ©N© )Úvalues    úT/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/lancedb/listing.pyú<lambda>zAsyncListing.<lambda>   s   € Èu€ ó    c                ó    — || _         || _        y r   )Ú_innerÚ_convert)ÚselfÚinnerÚconverts      r   Ú__init__zAsyncListing.__init__   s   € ØˆŒØˆ�r   c                ó   — | S r   r   ©r   s    r   Ú	__aiter__zAsyncListing.__aiter__   ó   € Øˆr   c              ƒ  óp   K  — | j                  | j                  j                  «       ƒ d {  –—† «      S 7 Œ­wr   )r   r   Ú	__anext__r   s    r   r#   zAsyncListing.__anext__"   s(   è ø€ Ø�}‰} 4§;¡;×#8Ñ#8Ó#:×:Ó;Ð;Ð:ús   ‚)6«4¬	6c                ó6   — | j                   j                  «       S ©zDReturn the number of cached items available without another request.©r   Únum_page_resultsr   s    r   r'   zAsyncListing.num_page_results%   ó   € à�{‰{×+Ñ+Ó-Ð-r   c                ó6   — | j                   j                  «       S )a   Return the token for the next request.

        Initially this is the supplied starting token (``None`` starts at the
        beginning). After fetching the final page it is ``None``, even if items
        remain cached. Drain the cache before saving a token to avoid skipping
        items when resuming. A failed request terminates iteration and retains
        its token for retrying with a new iterator.
        ©r   Ú
page_tokenr   s    r   r+   zAsyncListing.page_token)   s   € ð �{‰{×%Ñ%Ó'Ð'r   N)r   r   r   zCallable[[Any], T])ÚreturnúAsyncListing[T]©r,   r   ©r,   Úint©r,   úOptional[str])	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r#   r'   r+   r   r   r   r   r      s'   „ ññ BUô  óó<ó.ô	(r   r   c                  ó8   — e Zd ZdZdd„Zd	d„Zd
d„Zdd„Zdd„Zy)ÚListingzìA lazy synchronous iterator with inspectable pagination state.

    For example::

        for name in connection.list_views(page_limit=20):
            print(name)

    Use ``list(connection.list_views())`` to collect all results.
    c                ó   — || _         y r   )r   ©r   r   s     r   r   zListing.__init__@   s	   € Øˆ�r   c                ó   — | S r   r   r   s    r   Ú__iter__zListing.__iter__C   r!   r   c                ó†   — 	 t        j                  | j                  j                  «       «      S # t        $ r t
        d ‚w xY wr   ©r   Úrunr   r#   ÚStopAsyncIterationÚStopIterationr   s    r   Ú__next__zListing.__next__F   ó:   € ð	*Ü—8‘8˜DŸK™K×1Ñ1Ó3Ó4Ð4øÜ!ò 	*Ü TÐ)ð	*úó	   ‚,/ ¯A c                ó6   — | j                   j                  «       S r%   r&   r   s    r   r'   zListing.num_page_resultsL   r(   r   c                ó6   — | j                   j                  «       S )z¶Return the next request's token.

        See [AsyncListing.page_token][lancedb.listing.AsyncListing.page_token]
        for initial, cached, final-page, and error behavior.
        r*   r   s    r   r+   zListing.page_tokenP   s   € ð �{‰{×%Ñ%Ó'Ð'r   N)r   r-   )r,   z
Listing[T]r.   r/   r1   )	r3   r4   r5   r6   r   r<   rB   r'   r+   r   r   r   r8   r8   5   s    „ ñóóó*ó.ô(r   r8   c                óT   — | �&t        | t        «      r
| dk  s| dkD  rt        d«      ‚yy)zEValidate the legacy limit argument before passing it to the bindings.Nr   iÿÿÿz&limit must be between 0 and 2147483647)Ú
isinstancer0   Ú
ValueError)Úlimits    r   Úvalidate_page_limitrK   Y   s6   € àÐÜ�uœcÔ" e¨a¢i°5¸9Ò3DäÐAÓBÐBð 4Eð r   c                  óp   — e Zd ZdZ	 dddœ	 	 	 	 	 dd„Zedd„«       Zdd„Zdd„Zdd	„Z	d
„ Z
d„ Zd„ Zdd„Zy)Ú_AsyncPagedNameListingzFAn async listing with an inspectable copy of its current backend page.NF)Úemptyc               ó’   — || _         || _        |rg nd | _        d| _        || _        d | _        t        j                  «       | _        y )Nr   )	r   Ú_tokenÚ_pageÚ	_positionÚ_doneÚ_failureÚasyncioÚLockÚ_lock)r   r   r+   rN   s       r   r   z_AsyncPagedNameListing.__init__d   s?   € ð ˆŒØ ˆŒÙ05©"¸4ˆŒ
ØˆŒØˆŒ
Ø15ˆŒÜ—\‘\“^ˆ�
r   c                ó   — | j                   S )z4The continuation token for the next backend request.)rP   r   s    r   r+   z!_AsyncPagedNameListing.page_tokeno   s   € ð �{‰{Ðr   c                ób   — | j                   €dS t        | j                   «      | j                  z
  S )z.Count the remaining names in the current page.r   )rQ   ÚlenrR   r   s    r   r'   z'_AsyncPagedNameListing.num_page_resultst   s'   € à—J‘JÐ&ˆqÐL¬C°·
±
«O¸d¿n¹nÑ,LÐLr   c                ód   — | j                   €t        d«      ‚| j                   j                  «       S )Nz4Await or iterate the listing before reading its page)rQ   ÚRuntimeErrorÚcopyr   s    r   Ú
_page_copyz!_AsyncPagedNameListing._page_copyx   s)   € Ø�:‰:ÐÜÐUÓVÐVØ�z‰z�‰Ó Ð r   c              ƒ  óV  K  — 	 | j                   j                  «       ƒ d {  –—† }|€g | _        d | _        d| _        d| _	        y |d   | _        |d   | _        | j                  d u | _        d| _	        y 7 ŒR# t        j                  $ r ‚ t        $ r}|| _        d| _        ‚ d }~ww xY w­w)NTÚitemsr+   r   )
r   Ú	next_pagerU   ÚCancelledErrorÚBaseExceptionrT   rS   rQ   rP   rR   )r   ÚpageÚexcs      r   Ú_fetch_pagez"_AsyncPagedNameListing._fetch_page}   s«   è ø€ ð	ØŸ™×.Ñ.Ó0×0ˆDð ˆ<ØˆDŒJØˆDŒKØˆDŒJð
 ˆ�ð ˜g™ˆDŒJØ˜|Ñ,ˆDŒKØŸ™¨Ð,ˆDŒJØˆ�ð 1ùÜ×%Ñ%ò 	ØÜò 	ØˆDŒMØˆDŒJØûð	üs8   ‚B)„A6 ¡A4¢A6 ¦AB)Á4A6 Á6B&ÂB!Â!B&Â&B)c              ƒ  ó  K  — | j                   4 ƒd {  –—†  | j                  �| j                  ‚| j                  €| j                  «       ƒ d {  –—†  d d d «      ƒd {  –—†  | S 7 ŒR7 Œ7 Œ
# 1 ƒd {  –—†7  sw Y   | S xY w­wr   )rW   rT   rQ   rf   r   s    r   Ú_load_initialz$_AsyncPagedNameListing._load_initial�   s€   è ø€ Ø—:‘:÷ 	)ñ 	)Ø�}‰}Ð(Ø—m‘mÐ#Ø�z‰zÐ!Ø×&Ñ&Ó(×(Ð(÷		)÷ 	)ð
 ˆð	)øð )øð		)ø÷ 	)÷ 	)ð 	)ð
 ˆüsV   ‚B“A&”B—8A,ÁA(ÁA,ÁBÁA*Á BÁ(A,Á*BÁ,A?Á2A5Á3A?Á:Bc                ó>   — | j                  «       j                  «       S r   )rh   Ú	__await__r   s    r   rj   z _AsyncPagedNameListing.__await__˜   s   € Ø×!Ñ!Ó#×-Ñ-Ó/Ð/r   c                ó   — | S r   r   r   s    r   r    z _AsyncPagedNameListing.__aiter__›   r!   r   c              ƒ  ót  K  — | j                   4 ƒd {  –—†  | j                  �t        ‚| j                  €| j	                  «       ƒ d {  –—†  | j                  €J ‚| j
                  t        | j                  «      k\  r[| j                  rt        ‚| j	                  «       ƒ d {  –—†  | j                  €J ‚| j
                  t        | j                  «      k\  rŒ[| j                  | j
                     }| xj
                  dz  c_        |cd d d «      ƒd {  –—†  S 7 �Œ7 ŒÓ7 Œ{7 Œ# 1 ƒd {  –—†7  sw Y   y xY w­w)Nr   )rW   rT   r@   rQ   rf   rR   rZ   rS   )r   Úitems     r   r#   z _AsyncPagedNameListing.__anext__ž   s  è ø€ Ø—:‘:÷ 	ñ 	Ø�}‰}Ð(Ü(Ð(Ø�z‰zÐ!Ø×&Ñ&Ó(×(Ð(Ø—:‘:Ð)Ð)Ð)Ø—.‘.¤C¨¯
©
£OÒ3Ø—:’:Ü,Ð,Ø×&Ñ&Ó(×(Ð(Ø—z‘zÐ-Ð-Ð-ð	 —.‘.¤C¨¯
©
£OÓ3ð
 —:‘:˜dŸn™nÑ-ˆDØ�NŠN˜aÑ�NØ÷	÷ 	ò 	ùð )øð
 )øð	ø÷ 	÷ 	ñ 	üso   ‚D8“D”D8—2D#Á	DÁ
AD#Â#DÂ$4D#Ã/D#ÄD8ÄD!ÄD8ÄD#ÄD#Ä!D8Ä#D5Ä)D,Ä*D5Ä1D8r   )r   r   r+   r2   rN   Úboolr1   r/   ©r,   z	list[str])r,   ÚNone©r,   Ústr)r3   r4   r5   r6   r   Úpropertyr+   r'   r^   rf   rh   rj   r    r#   r   r   r   rM   rM   a   sg   „ ÙPð 7;ð	$ØMRñ	$Øð	$Ø&3ð	$ØFJó	$ð òó ðóMó!ó
ò&ò0òôr   rM   c                  ó"   — e Zd ZdZedd„«       Zy)ÚAsyncTableListingzñAwaitable table iterator; awaiting loads one page.

    For example::

        page = await db.list_tables(limit=20)
        print(page.tables, page.page_token)
        async for name in db.list_tables(limit=20):
            print(name)
    c                ó"   — | j                  «       S )z=A copy of every table name in the most recently fetched page.©r^   r   s    r   ÚtableszAsyncTableListing.tablesº   ó   € ð �‰Ó Ð r   Nro   ©r3   r4   r5   r6   rs   rx   r   r   r   ru   ru   ¯   s   „ ñð ò!ó ñ!r   ru   c                  ó"   — e Zd ZdZedd„«       Zy)ÚAsyncNamespaceListingz±Awaitable namespace iterator; awaiting loads one page.

    For example::

        page = await db.list_namespaces(limit=20)
        print(page.namespaces, page.page_token)
    c                ó"   — | j                  «       S )z7A copy of every name in the most recently fetched page.rw   r   s    r   Ú
namespacesz AsyncNamespaceListing.namespacesÉ   ry   r   Nro   ©r3   r4   r5   r6   rs   r~   r   r   r   r|   r|   À   s   „ ñð ò!ó ñ!r   r|   c                  ó<   — e Zd Zdd„Zd„ Zdd„Zed	d„«       Zd
d„Zy)Ú_PagedNameListingc                óX   — || _         t        j                  |j                  «       «       y r   )r   r   r?   rh   r:   s     r   r   z_PagedNameListing.__init__Ð   s   € ØˆŒÜ�‰�×$Ñ$Ó&Õ'r   c                ó   — | S r   r   r   s    r   r<   z_PagedNameListing.__iter__Ô   r!   r   c                ó†   — 	 t        j                  | j                  j                  «       «      S # t        $ r t
        d ‚w xY wr   r>   r   s    r   rB   z_PagedNameListing.__next__×   rC   rD   c                ó.   — | j                   j                  S r   r*   r   s    r   r+   z_PagedNameListing.page_tokenÝ   ó   € à�{‰{×%Ñ%Ð%r   c                ó6   — | j                   j                  «       S r   r&   r   s    r   r'   z"_PagedNameListing.num_page_resultsá   s   € Ø�{‰{×+Ñ+Ó-Ð-r   N)r   rM   rq   r1   r/   )	r3   r4   r5   r   r<   rB   rs   r+   r'   r   r   r   r�   r�   Ï   s*   „ ó(òó*ð ò&ó ð&ô.r   r�   c                  ó"   — e Zd ZdZedd„«       Zy)ÚTableListingzçTable iterator retaining the current page as a list.

    For example::

        page = db.list_tables(limit=20)
        print(page.tables, page.page_token)
        for name in db.list_tables(limit=20):
            print(name)
    c                ó.   — | j                   j                  S r   )r   rx   r   s    r   rx   zTableListing.tablesð   s   € à�{‰{×!Ñ!Ð!r   Nro   rz   r   r   r   r‰   r‰   å   s   „ ñð ò"ó ñ"r   r‰   c                  ó"   — e Zd ZdZedd„«       Zy)ÚNamespaceListingz­Namespace iterator retaining the current page as a list.

    For example::

        page = db.list_namespaces(limit=20)
        print(page.namespaces, page.page_token)
    c                ó.   — | j                   j                  S r   )r   r~   r   s    r   r~   zNamespaceListing.namespacesþ   r†   r   Nro   r   r   r   r   rŒ   rŒ   õ   s   „ ñð ò&ó ñ&r   rŒ   )rJ   zOptional[int]r,   rp   )r6   Ú
__future__r   rU   Útypingr   r   r   r   r   r	   r
   Úbackground_loopr   r   r   r8   rK   rr   rM   ru   r|   r�   r‰   rŒ   r   r   r   ú<module>r‘      s²   ðñ )å "ã ß U× UÑ Uå !áˆCƒL€ô"(�= Ñ# W¨Q¡Zô "(ôJ!(ˆh�q‰k˜7 1™:ô !(óHCôK˜]¨3Ñ/ô Kô\!Ð.ô !ô"!Ð2ô !ô.˜ ™ô .ô,"Ð$ô "ô &Ð(õ &r   