a
    yn„fŽ  ã                   @  sj   d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 dZ
e	 ¡ Zeƒ ddddd	œd
d„ƒZdd„ ZdS )é    )ÚannotationsN)Úhigh_level_function)ÚHighLevelContext)ÚNumpyMetadata)Ú
from_arrowFT)Úgenerate_bitmasksÚ	highlevelÚbehaviorÚattrsc                C  s   t | ||||ƒS )a˜  
    Args:
        array (`pyarrow.Array`, `pyarrow.ChunkedArray`, `pyarrow.RecordBatch`, or `pyarrow.Table`):
            Apache Arrow array to convert into an  Awkward Array.
        generate_bitmasks (bool): If enabled and Arrow/Parquet does not have Awkward
            metadata, `generate_bitmasks=True` creates empty bitmasks for nullable
            types that don't have bitmasks in the Arrow/Parquet data, so that the
            Form (BitMaskedForm vs UnmaskedForm) is predictable.
        highlevel (bool): If True, return an #ak.Array; otherwise, return
            a low-level #ak.contents.Content subclass.
        behavior (None or dict): Custom #ak.behavior for the output array, if
            high-level.
        attrs (None or dict): Custom attributes for the output array, if
            high-level.

    Converts an Apache Arrow array into an Awkward Array.

    This function always preserves the values of a dataset; i.e. the Python objects
    returned by #ak.to_list are identical to the Python objects returned by Arrow's
    `to_pylist` method. If #ak.to_arrow was invoked with `extensionarray=True`, this
    function also preserves the data type (high-level #ak.types.Type, though not the
    low-level #ak.forms.Form), even through Parquet, making Parquet a good way to save
    Awkward Arrays for later use.

    See also #ak.to_arrow, #ak.to_arrow_table, #ak.from_parquet, #ak.from_arrow_schema.
    )Ú_impl)Úarrayr   r   r	   r
   © r   úc/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_from_arrow.pyr      s    r   c                 C  sÒ   dd l }|jjj}t||d� ¡ }|jjj| |dd�}t| |jj|jj	fƒr®|jj 
| j¡\}	}
|	d u r†t|tjjƒr®|jj |¡}n(|	jdv rž|jj |¡}|	jr®| d¡}dd„ }tj ||¡ |j||d�S )	Nr   )r	   r
   T)r   Zpass_empty_field)NZIndexedArrayc                 [  s   t | dƒr| `d S )NÚ__pyarrow_original)Úhasattrr   )ZlayoutÚkwargsr   r   r   Úremove_revertableK   s    
z _impl.<locals>.remove_revertable)r   )Zawkward._connect.pyarrowÚ_connectÚpyarrowr   ÚfinalizeZhandle_arrowÚ
isinstanceÚlibZArrayZChunkedArrayZto_awkwardarrow_storage_typesÚtypeÚakÚcontentsZUnmaskedArrayZremove_optiontypeZ	mask_typeZrecord_is_scalarZ_getitem_atZ_doZrecursively_applyÚwrap)r   r   r   r	   r
   Úawkwardr   ÚctxÚoutZawkwardarrow_typeZstorage_typer   r   r   r   r   0   s*    
ÿý

r   )Ú
__future__r   r   r   Zawkward._dispatchr   Zawkward._layoutr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r   r   r   r   r   Ú<module>   s   ÿ 