U ŸDx`Êã@sfddlmZddlmZddlmZddlmZddlm Z dd„Z dd „Z d d „Z Gd d „d ƒZ dS)é)Úcount)ÚIntegral)Útypes)ÚSchemaNcCsBt |¡o@t |j¡o@|jjdko@|jdjdko@|jdjdkS)NérÚkeyéÚvalue)rÚis_listÚ is_structÚ value_typeÚ num_fieldsÚname)Útyp©rú2/tmp/pip-target-oguziej0/lib/python/pyarrow/orc.pyÚ_is_maps  ÿ þýürccsÌt|tƒst |¡rZ|D]>}|jf}|t|ƒfVt|j|ƒD]\}}|||fVq>qnnt|ƒrvt|j |ƒEdHnRt  |¡rœt|ƒt|j |ƒEdHn,t  |¡rÈ|D]}t|ƒt||ƒD]}qÀqªdS©N) Ú isinstancerrr rÚnextÚ _traverseÚtyperr r Zis_union)rÚcounterÚfieldÚpathÚsubÚcZdtypeZsub_crrrr#s   rcCsdd„t|tdƒƒDƒS)NcSsi|]\}}d |¡|“qS)Ú.)Újoin)Ú.0ÚirrrrÚ :sz&_schema_to_indices..r)rr)ÚschemarrrÚ_schema_to_indices9sr#c@sZeZdZdZdd„Zedd„ƒZedd„ƒZedd „ƒZdd d „Z dd d„Z ddd„Z d S)ÚORCFilea  Reader interface for a single ORC file Parameters ---------- source : str or pyarrow.io.NativeFile Readable source. For passing Python file objects or byte buffers, see pyarrow.io.PythonFileInterface or pyarrow.io.BufferReader. cCs&t ¡|_|j |¡t|jƒ|_dSr)Ú_orcZ ORCReaderÚreaderÚopenr#r"Ú_column_index_lookup)ÚselfÚsourcerrrÚ__init__Hs  zORCFile.__init__cCs |j ¡S)z#The file schema, as an arrow schema)r&r"©r)rrrr"MszORCFile.schemacCs |j ¡S)zThe number of rows in the file)r&Únrowsr,rrrr-Rsz ORCFile.nrowscCs |j ¡S)z!The number of stripes in the file)r&Únstripesr,rrrr.WszORCFile.nstripesNcCsš|dkr dS|j}g}|D]z}t|tƒrlt|ƒ}d|krHt|ƒkrXnn ||j}ntdt|ƒ|fƒ‚||jkrˆ| |j|¡qtd|ƒ‚q|S)Nrz/Column indices must be in 0 <= ind < %d, got %dzUnknown column name %r) r"rrÚintÚlenrÚ ValueErrorr(Úappend)r)Úcolumnsr"ÚindicesÚcolrrrÚ_select_indices\s    ÿ zORCFile._select_indicescCs| |¡}|jj||dS)aÎRead a single stripe from the file. Parameters ---------- n : int The stripe index columns : list If not None, only these columns will be read from the stripe. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e' Returns ------- pyarrow.lib.RecordBatch Content of the stripe as a RecordBatch. ©Úinclude_indices)r6r&Ú read_stripe)r)Únr3r8rrrr9qs zORCFile.read_stripecCs| |¡}|jj|dS)a‚Read the whole file. Parameters ---------- columns : list If not None, only these columns will be read from the file. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e' Returns ------- pyarrow.lib.Table Content of the file as a Table. r7)r6r&Úread)r)r3r8rrrr;…s z ORCFile.read)N)N)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r+Úpropertyr"r-r.r6r9r;rrrrr$=s      r$)Ú itertoolsrÚnumbersrZpyarrowrZ pyarrow.librZ pyarrow._orcr%rrr#r$rrrrÚs