/usr/local/lib/python3.6/site-packages/fsspec/__pycache__
NameSizeModeActions
archive.cpython-36.pyc26790644editdlrm
asyn.cpython-36.pyc232500644editdlrm
caching.cpython-36.pyc133250644editdlrm
callbacks.cpython-36.pyc59270644editdlrm
compression.cpython-36.pyc46450644editdlrm
config.cpython-36.pyc27400644editdlrm
conftest.cpython-36.pyc13610644editdlrm
core.cpython-36.pyc202340644editdlrm
dircache.cpython-36.pyc32920644editdlrm
exceptions.cpython-36.pyc7330644editdlrm
fuse.cpython-36.pyc101100644editdlrm
gui.cpython-36.pyc142140644editdlrm
mapping.cpython-36.pyc82080644editdlrm
parquet.cpython-36.pyc111810644editdlrm
registry.cpython-36.pyc76210644editdlrm
spec.cpython-36.pyc522480644editdlrm
transaction.cpython-36.pyc31780644editdlrm
utils.cpython-36.pyc144030644editdlrm
_version.cpython-36.pyc4640644editdlrm
__init__.cpython-36.pyc13940644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/fsspec/__pycache__/parquet.cpython-36.pyc (11181B)
3 8%EgJL @sddlZddlZddlZddlmZddlmZdd d Zdd dZdddZ ddZ ddZ ddZ GdddZ GdddZdS)N) url_to_fs)merge_offset_rangesrbFauto@B@Bc  Ks|dkrt||pidd}|dk r>t|dkr>|j||dSt|}t|g|||||| | | d } | rrtt| n|}| jdij}|j|f|d|| j |i|dd | S) a Return a file-like object for a single Parquet file. The specified parquet `engine` will be used to parse the footer metadata, and determine the required byte ranges from the file. The target path will then be opened with the "parts" (`KnownPartsOfAFile`) caching strategy. Note that this method is intended for usage with remote file systems, and is unlikely to improve parquet-read performance on local file systems. Parameters ---------- path: str Target file path. mode: str, optional Mode option to be passed through to `fs.open`. Default is "rb". metadata: Any, optional Parquet metadata object. Object type must be supported by the backend parquet engine. For now, only the "fastparquet" engine supports an explicit `ParquetFile` metadata object. If a metadata object is supplied, the remote footer metadata will not need to be transferred into local memory. fs: AbstractFileSystem, optional Filesystem object to use for opening the file. If nothing is specified, an `AbstractFileSystem` object will be inferred. engine : str, default "auto" Parquet engine to use for metadata parsing. Allowed options include "fastparquet", "pyarrow", and "auto". The specified engine must be installed in the current environment. If "auto" is specified, and both engines are installed, "fastparquet" will take precedence over "pyarrow". columns: list, optional List of all column names that may be read from the file. row_groups : list, optional List of all row-groups that may be read from the file. This may be a list of row-group indices (integers), or it may be a list of `RowGroup` metadata objects (if the "fastparquet" engine is used). storage_options : dict, optional Used to generate an `AbstractFileSystem` object if `fs` was not specified. strict : bool, optional Whether the resulting `KnownPartsOfAFile` cache should fetch reads that go beyond a known byte-range boundary. If `False` (the default), any read that ends outside a known part will be zero padded. Note that using `strict=True` may be useful for debugging. max_gap : int, optional Neighboring byte ranges will only be merged when their inter-range gap is <= `max_gap`. Default is 64KB. max_block : int, optional Neighboring byte ranges will only be merged when the size of the aggregated range is <= `max_block`. Default is 256MB. footer_sample_size : int, optional Number of bytes to read from the end of the path to look for the footer metadata. If the sampled bytes do not contain the footer, a second read request will be required, and performance will suffer. Default is 1MB. **kwargs : Optional key-word arguments to pass to `fs.open` N)storage_optionsr)mode)metadatacolumns row_groupsenginemax_gap max_blockfooter_sample_size cache_optionsparts)datastrict)r Z cache_typer) rlenopen _set_engine_get_parquet_byte_rangesnextiterpopcopyget)pathr fsr r rr rrrrrkwargsrfnoptionsr%8/usr/local/lib/python3.6/site-packages/fsspec/parquet.pyopen_parquet_files2Q  r'c  Cst|trt|}|dk r0t|||||||dS|j|} i} g} g} g} d}|dkr|dkrxbt|D]V\}}i| |<xDtd| ||D]0}| j|| j|| jt||| |qWqhWd}ng}g}x>t|D]2\}}|j| |t d| ||}|j|qW|j |||}|j }d}xbt|D]V\}}t j ||d dd}| ||d}|||kr6|||<t ||d}q6W|rtjd |d x= .)rfooter footer_start)rrsorti) isinstancestrr&_get_parquet_byte_ranges_from_metadatasizes enumeraterangeappendminmax cat_rangesrint from_byteswarningswarn_parquet_byte_rangesrr_transfer_ranges_add_header_magic)pathsr!r r rrrrrZ file_sizesresult data_paths data_starts data_endsZadd_header_magicir bZ footer_startsZ footer_endsZ sample_sizeZfooter_samplesZmissing_footer_startsZ large_footerZ footer_sizeZreal_footer_startblockZpath_data_startsZpath_data_endsr%r%r&rs       "rc Csb|j|||d\}}} t||| ||dd\}}} ddtt|D} t|| ||| t| | S)zSimplified version of `_get_parquet_byte_ranges` for the case that an engine-specific `metadata` object is provided, and the remote footer metadata does not need to be transferred before calculating the required byte ranges. )rr F)rrr.cSsi|] }i|qSr%r%).0r#r%r%r& Csz:_get_parquet_byte_ranges_from_metadata..)r>rlistsetr?r@) r r!rr rrrrCrDrErBr%r%r&r2"sr2c CsD|||f}x4t||j|fD]\}}}} | ||||f<q WdS)N)zipr9) r!blocksrAZstartsZendsrangesr startstoprr%r%r&r?Ls "r?cCsjxdtt|jD]P\}}d}x2||jD]"}|ddkr,|ddkr,d}Pq,W|rd||d<qWdS)NTrrr)FsPAR1)rr))r4rKkeys)rrFr Z add_magickr%r%r&r@Ssr@c Cs|dkrd}n2t|ts"tdn|d kr:t|dn|g}xB|D]:}y |dkrZtS|dkrhtSWqFtk r~YqFXqFWtd|ddS) Nr fastparquetpyarrowzMFailed to set parquet engine! Please pass 'fastparquet', 'pyarrow', or 'auto'z) engine not supported by `fsspec.parquet`zLThe following parquet engines are not installed in your python environment: zS.Please install 'fastparquert' or 'pyarrow' to utilize the `fsspec.parquet` module.)rTrU)rTrU)r0r1 ValueErrorFastparquetEngine PyarrowEngine ImportError)Z engine_strZ try_enginesrr%r%r&r_s$    rc@s&eZdZddZddZdddZdS) rWcCsddl}||_dS)Nr)rTfp)selfrZr%r%r&__init__szFastparquetEngine.__init__cCs |j|S)N)Zrow_group_filename)r[ row_grouppfr%r%r&_row_group_filenamesz%FastparquetEngine._row_group_filenameNcCsx|}ggg}}} |dkr.|jjtj|}|dkr:dnt|} | dk rxt|drxdd|jjdgD} | t| O} |rt|dt  rd} n |} |j }xt |D]\} }| dks| | kr|j ||}x|j D]}|jjd}| dks|| kr|jj}|dkr |jj}|jj}|dks&||kr|j||j|| jt|||pR||qWqW|rp||| fS|| fS)Npandas_metadatacSsg|]}t|ts|qSr%)r0dict)rIindr%r%r& sz:FastparquetEngine._parquet_byte_ranges.. index_columnsr)rZ ParquetFileioBytesIOrLhasattrr`rr0r:rr4r_r Z meta_datapath_in_schemadictionary_page_offsetdata_page_offsettotal_compressed_sizer6r7)r[r rr r,r-r^rCrDrE column_setmd_indexZrow_group_indicesrr]r#columnname file_offset0 num_bytesr%r%r&r>sB         z&FastparquetEngine._parquet_byte_ranges)NNNN)__name__ __module__ __qualname__r\r_r>r%r%r%r&rWs rWc@s&eZdZddZddZdddZdS) rXcCsddlj}||_dS)Nr)Zpyarrow.parquetZparquetpq)r[rwr%r%r&r\s zPyarrowEngine.__init__cCstdS)N)NotImplementedError)r[r]r r%r%r&r_sz!PyarrowEngine._row_group_filenameNcCsf|dk rtdgg}}|jjtj|j}|dkr:dnt|} | dk r|jj} | jdk ofd| jk} | rddt j | jdj dj dgD} | t| O} xt |jD]} |dks| |kr|j| }xt |jD]}|j|}|j}|jdd}| dks|| ks|| kr|j}|dkr*|j}|j}||kr|j||jt|||qWqW||fS) Nz.metadata input not supported for PyarrowEnginespandascSsg|]}t|ts|qSr%)r0ra)rIrbr%r%r&rcsz6PyarrowEngine._parquet_byte_ranges..utf8rdr+r)rVrwrerfrgr rLschemaZto_arrow_schemajsonloadsdecoderr5Znum_row_groupsr]Z num_columnsrprisplitrjrkrlr6r7)r[r rr r,r-rDrEZmdrmrzZhas_pandas_metadatarnror]crprqZ split_namerrrsr%r%r&r>sB           z"PyarrowEngine._parquet_byte_ranges)NNNN)rtrurvr\r_r>r%r%r%r&rXs rX) rNNNNNFrrrr )NNNrrr r)NNrr)rfr{r<corerutilsrr'rr2r?r@rrWrXr%r%r%r&s@   u  # $X