/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__/caching.cpython-36.pyc (13325B)
3 8%Eg[A @sddlZddlZddlZddlZddlZddlZejdZGdddeZ Gddde Z Gddde Z Gd d d e Z Gd d d e Z Gd dde ZGddde ZGddde Ze e ee e e eedZdS)NZfsspecc@s$eZdZdZdZddZddZdS) BaseCacheagPass-though cache: doesn't keep anything, calls every time Acts as base class for other cachers Parameters ---------- blocksize: int How far to read ahead in numbers of bytes fetcher: func Function of the form f(start, end) which gets bytes from remote as specified size: int How big this file is nonecCs||_||_||_dS)N) blocksizefetchersize)selfrrrr8/usr/local/lib/python3.6/site-packages/fsspec/caching.py__init__szBaseCache.__init__cCs<|dkr d}|dkr|j}||jks,||kr0dS|j||S)Nr)rr)rstartstoprrr _fetch"szBaseCache._fetchN)__name__ __module__ __qualname____doc__namer rrrrr r srcsFeZdZdZdZdfdd ZddZdd Zd d Zd d Z Z S) MMapCachezmemory-mapped sparse file cache Opens temporary file, which is filled blocks-wise when data is requested. Ensure there is enough disc space in the temporary location. This cache method might only work on posix mmapNcs8tj||||dkrtn||_||_|j|_dS)N)superr setblockslocation _makefilecache)rrrrrr) __class__rr r 7szMMapCache.__init__cCsddl}ddl}|jdkr tS|jdks:tjj|j r|jdkrV|j}t |_ nt j |jd}|j |jd|jd|jnt j |jd}|j|j|jS)Nrzwb+1zrb+)rtempfiler bytearrayrospathexists TemporaryFilerrioopenseekwriteflushfileno)rrrfdrrr r=s     zMMapCache._makefilec stjd|d||dkr"d}|dkr0j}|jksB||krFdS|j}|j}fddt||dD}xl|r|jd}|j}t|jj}tjd|d |d|j||j||<j j |qxWj||S) NzMMap cache fetching -rr csg|]}|jkr|qSr)r).0i)rrr ]sz$MMapCache._fetch..rzMMap get block #z () loggerdebugrrrangepopminrrradd) rr endZ start_blockZ end_blockZneedr.Zsstartsendr)rr rSs$    zMMapCache._fetchcCs|jj}|d=|S)Nr)__dict__copy)rstaterrr __getstate__js zMMapCache.__getstate__cCs|jj||j|_dS)N)r8updaterr)rr:rrr __setstate__ps zMMapCache.__setstate__)NN) rrrrrr rrr;r= __classcell__rr)rr r,srcs,eZdZdZdZfddZddZZS)ReadAheadCachea!Cache which reads only when we get beyond a block of data This is a much simpler version of BytesCache, and does not attempt to fill holes in the cache or keep fragments alive. It is best suited to many small reads in a sequential order (e.g., reading lines from a file). readaheadcs&tj|||d|_d|_d|_dS)Nr r)rr rr r6)rrrr)rrr r szReadAheadCache.__init__cCs|dkr d}|dks||jkr$|j}||jks6||kr:dS||}||jkrp||jkrp|j||j||jS|j|ko|jknr|j||jd}|t|8}|j}nd}t|j||j}|j|||_||_|jt|j|_||jd|S)Nrr )rr r6rlenr4rr)rr r6lpartrrr rs& zReadAheadCache._fetch)rrrrrr rr>rr)rr r?vs r?cs,eZdZdZdZfddZddZZS)FirstChunkCachezCaches the first block of a file only This may be useful for file types where the metadata is stored in the header, but is randomly accessed. firstcstj|||d|_dS)N)rr r)rrrr)rrr r szFirstChunkCache.__init__cCs|pd}|p|j}||jkr|jdkrh||jkrX|jd|}|d|j|_||dS|jd|j|_|j||}||jkr||j|j|7}|S|j||SdS)Nr)rrrr)rr r6datarCrrr rs       zFirstChunkCache._fetch)rrrrrr rr>rr)rr rDs rDcsbeZdZdZdZdfdd ZddZdd Zd d Zd d Z ddZ fddZ ddZ Z S) BlockCachea Cache holding memory as a set of blocks. Requests are only ever made `blocksize` at a time, and are stored in an LRU cache. The least recently accessed block is discarded when more than `maxblocks` are stored. Parameters ---------- blocksize : int The number of bytes to store in each block. Requests are only ever made for `blocksize`, so this should balance the overhead of making a request against the granularity of the blocks. fetcher : Callable size : int The total size of the file being cached. maxblocks : int The maximum number of blocks to cache for. The maximum memory use for this cache is then ``blocksize * maxblocks``. Z blockcache cs<tj|||tj|||_||_tj||j|_ dS)N) rr mathceilnblocks maxblocks functools lru_cache _fetch_block_fetch_block_cached)rrrrrL)rrr r szBlockCache.__init__cCsdj|j|j|jS)Nz.)formatrrrK)rrrr __repr__szBlockCache.__repr__cCs |jjS)z The statistics on the block cache. Returns ---------- NamedTuple Returned directly from the LRU Cache used internally. )rP cache_info)rrrr rSs zBlockCache.cache_infocCs|j}|d=|S)NrP)r8)rr:rrr r;szBlockCache.__getstate__cCs&|jj|tj|d|j|_dS)NrL)r8r<rMrNrOrP)rr:rrr r=s  zBlockCache.__setstate__cCsx|dkr d}|dkr|j}||jks,||kr0dS||j}||j}x t||dD]}|j|qTW|j||||dS)Nrr r)start_block_numberend_block_number)rrr2rP _read_cache)rr r6rTrU block_numberrrr rs  zBlockCache._fetchcsN||jkrtdj||j||j}||j}tjd|tj||}|S)z= Fetch the block of data for `block_number`. z;'block_number={}' is greater than the number of blocks ({})zBlockCache fetching block %d)rK ValueErrorrQrr0inforr)rrWr r6Zblock_contents)rrr rOs     zBlockCache._fetch_blockc Cs||j}||j}||kr2|j|}|||Sg}|j|j||dx&t|d|D]} |j|j| q^W|j|j|d|dj|SdS)z Read from our block cache. Parameters ---------- start, end : int The start and end byte positions. start_block_number, end_block_number : int The start and end block numbers. Nrr )rrPappendr2join) rr r6rTrU start_posend_posblockoutrWrrr rV!s    zBlockCache._read_cache)rH)rrrrrr rRrSr;r=rrOrVr>rr)rr rGs  rGcs6eZdZdZdZd fdd ZddZdd ZZS) BytesCacheaKCache which holds data in a in-memory bytes object Implements read-ahead by the block size, for semi-random reads progressing through the file. Parameters ---------- trim: bool As we read more data, whether to discard the start of the buffer when we are more than a blocksize ahead of it. bytesTcs,tj|||d|_d|_d|_||_dS)Nr )rr rr r6trim)rrrrrb)rrr r Ss zBytesCache.__init__cCs&|dkr d}|dkr|j}||jks,||kr0dS|jdk rx||jkrx|jdk rx||jkrx||j}|j||||S|jrt|j||j}n|}||ks||jkrdS|jdks||jkr|jdks||jkr|j|||_||_n||jkr@|j||jkr|j|||_||_n |j||j}||_||j|_n^||jkr|j|jkr\nB||j|jkr|j|||_||_n|j|j|}|j||_|jt|j|_||j}|j||||}|jr"|j|j|jd}|dkr"|j|j|7_|j|j|d|_|S)Nrr r) rr r6rrr4rrArb)rr r6offsetZbendnewr_numrrr rZsZ          zBytesCache._fetchcCs t|jS)N)rAr)rrrr __len__szBytesCache.__len__)T) rrrrrr rrfr>rr)rr r`Ds  =r`cs.eZdZdZdZdfdd ZddZZS) AllBytesz!Cache entire contents of the fileallNcs0tj||||dkr&|jd|j}||_dS)Nr)rr rrrF)rrrrrF)rrr r szAllBytes.__init__cCs|j||S)N)rF)rr r6rrr rszAllBytes._fetch)NNNN)rrrrrr rr>rr)rr rgsrgcs6eZdZdZdZidffdd ZfddZZS)KnownPartsOfAFilea Cache holding known file parts. Parameters ---------- blocksize: int How far to read ahead in numbers of bytes fetcher: func Function of the form f(start, end) which gets bytes from remote as specified size: int How big this file is data: dict A dictionary mapping explicit `(start, stop)` file-offset tuples with known bytes. strict: bool, default True Whether to fetch reads that go beyond a known byte-range boundary. If `False`, any read that ends outside a known part will be zero padded. Note that zero padding will not be used for reads that begin outside a known byte-range. partsTc stt|j|||||_|rtt|j}|dg}|j|dg} xv|ddD]f\} } |d\} } | | kr| | f|d<| d|j| | f7<qV|j| | f| j|j| | fqVWt t || |_ n||_ dS)Nrrrkrk) rrir strictsortedlistkeysr3rZdictziprF)rrrrrFrl_Z old_offsetsoffsetsrr r Zstart0Zstop0)rrr r s   zKnownPartsOfAFile.__init__csd}x|jjD]\\}}}||ko.|knr||}|||||}|j sp||koj|knr|d||t|7}|S|}PqW|jdkrtd||fdtjd||fdtj d|d||t j ||S)Nr z&Read is outside the known file parts: z. z%. IO/caching performance may be poor!z!KnownPartsOfAFile cache fetching r,) rFitemsrlrArrXwarningswarnr0r1rr)rr r r_Zloc0loc1rFoff)rrr rs   zKnownPartsOfAFile._fetch)rrrrrr rr>rr)rr risri)rrrar@r^rErhrj)rMr%loggingrIr!rv getLoggerr0objectrrr?rDrGr`rgricachesrrrr s. !J*WV