§
    Ò¬¸j^  ã                  ó†   — d dl mZ d dlmZ d dlmZmZ d dlZerd dl	m
Z
 d dlmZmZ d dlmZ ddd	œdd„Z	 ddddœdd„ZdS )é    )Úannotations)Úpartial)ÚTYPE_CHECKINGÚAnyN)ÚIterator)Ú	DataFrameÚ	LazyFrame©ÚpyarrowT)Úallow_pyarrow_filterÚ
batch_sizeÚdsúpa.dataset.Datasetr   Úboolr   ú
int | NoneÚreturnr	   c               ó€   — t          t          | ||¬¦  «        }t          j                             | j        ||¬¦  «        S )a'  
    Pickle the partially applied function `_scan_pyarrow_dataset_impl`.

    The bytes are then sent to the polars logical plan. It can be deserialized once
    executed and ran.

    Parameters
    ----------
    ds
        pyarrow dataset
    allow_pyarrow_filter
        Allow predicates to be pushed down to pyarrow. This can lead to different
        results if comparisons are done with null values as pyarrow handles this
        different than polars does.
    batch_size
        The maximum row count for scanned pyarrow record batches.
    ©r   Úuser_batch_sizer
   )r   Ú_scan_pyarrow_dataset_implÚplr	   Ú_scan_python_functionÚschema)r   r   r   Úfuncs       úx/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/polars/io/pyarrow_dataset/anonymous_scan.pyÚ_scan_pyarrow_datasetr      sO   € õ2 Ý"Ø
Ø1Ø"ð	ñ ô €Dõ Œ<×-Ò-Ø
Œ	�4Ð!5ð .ñ ô ð ó    r   Úwith_columnsúlist[str] | NoneÚ	predicateúpa.compute.Expression | NoneÚn_rowsr   ú tuple[Iterator[DataFrame], bool]c               óp   ‡ ‡‡
— d}|r|�‰€|}||dœŠ
|�|n|}|�|‰
d<   dˆ
ˆ ˆfd„}|du}	 |¦   «         |	fS )a™  
    Take the projected columns and materialize an arrow table.

    Parameters
    ----------
    ds
        pyarrow dataset.
    with_columns
        Columns that are projected.
    predicate
        pyarrow expression (when `allow_pyarrow_filter=True`) or
        serialized Polars predicate bytes (when `allow_pyarrow_filter=False`).
    n_rows:
        Materialize only `n` rows from the arrow dataset.
    batch_size
        The maximum row count for scanned pyarrow record batches.
    allow_pyarrow_filter
        If True, evaluate predicate and return DataFrame directly.
        If False, return `(generator, False)` tuple for IOPlugin path.
    user_batch_size
        User-specified `batch_size` (takes precedence over Rust-provided `batch_size`).

    Returns
    -------
    tuple[Iterator[DataFrame], bool]
    A generator over the DataFrames and a boolean indicating if the
    predicates is applied.
    N)ÚcolumnsÚfilterr   r   úIterator[DataFrame]c               3  óà   •K  — ‰}  ‰j         di ‰¤ŽD ]Z}|j        dk    rŒ| �4| dk    r d S |j        | k    r|                     d| ¦  «        }| |j        z  } t          j        |¦  «        V — Œ[d S )Nr   © )Ú
to_batchesÚnum_rowsÚslicer   Ú
from_arrow)Ú	remainingÚbatchÚcommon_paramsr   r"   s     €€€r   Úframesz*_scan_pyarrow_dataset_impl.<locals>.framesg   s¤   øè è € Øˆ	à"�R”]Ð3Ð3 ]Ð3Ð3ð 	'ð 	'ˆEØŒ~ Ò"Ð"Øð Ð$Ø ’>�>Ø�E�EØ”> IÒ-Ð-Ø!ŸKšK¨¨9Ñ5Ô5�EØ˜Uœ^Ñ+�	å”- Ñ&Ô&Ð&Ð&Ð&Ð&ð	'ð 	'r   )r   r'   r)   )r   r   r    r"   r   r   r   Úfilter_r1   Ú"applies_predicate_in_this_functionr0   s   `  `      @r   r   r   3   s–   øøø€ ðR €Gàð   	Ð 5Øˆ>ØˆGà0<ÈÐ$PÐ$P€MØ$3Ð$?��ÀZ€JØÐØ&0ˆ�lÑ#ð'ð 'ð 'ð 'ð 'ð 'ð 'ð 'ð" *1¸Ð)<Ð&Øˆ6‰8Œ8Ð7Ð7Ð7r   )r   r   r   r   r   r   r   r	   )N)r   r   r   r   r    r!   r"   r   r   r   r   r   r   r   r   r#   )Ú
__future__r   Ú	functoolsr   Útypingr   r   Úpolarsr   Úcollections.abcr   r   r	   Úpolars._dependenciesr   Úpar   r   r)   r   r   ú<module>r;      sû   ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð àð 3Ø(Ð(Ð(Ð(Ð(Ð(à+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ø2Ð2Ð2Ð2Ð2Ð2ð "&Ø!ð	!ð !ð !ð !ð !ð !ðR "ðF8ð "&Ø"&ðF8ð F8ð F8ð F8ð F8ð F8ð F8ð F8r   