/usr/local/lib64/python3.6/site-packages/pyarrow/__pycache__
NameSizeModeActions
benchmark.cpython-36.pyc2080644editdlrm
cffi.cpython-36.pyc14820644editdlrm
compat.cpython-36.pyc3810644editdlrm
compute.cpython-36.pyc202630644editdlrm
csv.cpython-36.pyc3820644editdlrm
cuda.cpython-36.pyc4050644editdlrm
dataset.cpython-36.pyc279700644editdlrm
feather.cpython-36.pyc77390644editdlrm
filesystem.cpython-36.pyc144020644editdlrm
flight.cpython-36.pyc13530644editdlrm
fs.cpython-36.pyc103950644editdlrm
hdfs.cpython-36.pyc70550644editdlrm
ipc.cpython-36.pyc73940644editdlrm
json.cpython-36.pyc2310644editdlrm
jvm.cpython-36.pyc80350644editdlrm
orc.cpython-36.pyc51400644editdlrm
pandas_compat.cpython-36.pyc276950644editdlrm
parquet.cpython-36.pyc666090644editdlrm
plasma.cpython-36.pyc40690644editdlrm
serialization.cpython-36.pyc137370644editdlrm
types.cpython-36.pyc120830644editdlrm
util.cpython-36.pyc41500644editdlrm
_generated_version.cpython-36.pyc2230644editdlrm
__init__.cpython-36.pyc164760644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/pyarrow/__pycache__/dataset.cpython-36.pyc (27970B)
3 9%Eg5@sldZddlZddlmZmZmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dZ)dZ*yddl+m,Z,dZ)Wne-k rYnXd d Z.d d Z/d dZ0d(ddZ1ddZ2ddZ3d)ddZ4d*ddZ5d+ddZ6d,ddZ7d-ddZ8d.dd Z9d/d!d"Z:d#d$Z;d0d&d'Z|dk r td|dkr4tj|dSt||S|dk rnt|trZtj|Stdjt|qtdnr|dkr|dk rtdq|dk rt|tjr|dkrt j|dSt ||Std jt|qt jSntd dS) a Specify a partitioning scheme. The supported schemes include: - "DirectoryPartitioning": this scheme expects one segment in the file path for each field in the specified schema (all fields are required to be present). For example given schema the path "/2009/11" would be parsed to ("year"_ == 2009 and "month"_ == 11). - "HivePartitioning": a scheme for "/$key=$value/" nested directories as found in Apache Hive. This is a multi-level, directory based partitioning scheme. Data is partitioned by static values of a particular column in the schema. Partition keys are represented in the form $key=$value in directory names. Field order is ignored, as are missing or unrecognized field names. For example, given schema, a possible path would be "/year=2009/month=11/day=15" (but the field order does not need to match). Parameters ---------- schema : pyarrow.Schema, default None The schema that describes the partitions present in the file path. If not specified, and `field_names` and/or `flavor` are specified, the schema will be inferred from the file path (and a PartitioningFactory is returned). field_names : list of str, default None A list of strings (field names). If specified, the schema's types are inferred from the file paths (only valid for DirectoryPartitioning). flavor : str, default None The default is DirectoryPartitioning. Specify ``flavor="hive"`` for a HivePartitioning. dictionaries : Dict[str, Array] If the type of any field of `schema` is a dictionary type, the corresponding entry of `dictionaries` must be an array containing every value which may be taken by the corresponding column or an error will be raised in parsing. Alternatively, pass `infer` to have Arrow discover the dictionary values, in which case a PartitioningFactory is returned. Returns ------- Partitioning or PartitioningFactory Examples -------- Specify the Schema for paths like "/2009/June": >>> partitioning(pa.schema([("year", pa.int16()), ("month", pa.string())])) or let the types be inferred by only specifying the field names: >>> partitioning(field_names=["year", "month"]) For paths like "/2009/June", the year will be inferred as int32 while month will be inferred as string. Specify a Schema with dictionary encoding, providing dictionary values: >>> partitioning( ... pa.schema([ ... ("year", pa.int16()), ... ("month", pa.dictionary(pa.int8(), pa.string())) ... ]), ... dictionaries={ ... "month": pa.array(["January", "February", "March"]), ... }) Alternatively, specify a Schema with dictionary encoding, but have Arrow infer the dictionary values: >>> partitioning( ... pa.schema([ ... ("year", pa.int16()), ... ("month", pa.dictionary(pa.int8(), pa.string())) ... ]), ... dictionaries="infer") Create a Hive scheme for a path like "/year=2009/month=11": >>> partitioning( ... pa.schema([("year", pa.int16()), ("month", pa.int8())]), ... flavor="hive") A Hive scheme can also be discovered from the directory structure (and types will be inferred): >>> partitioning(flavor="hive") Nz.Cannot specify both 'schema' and 'field_names'Zinfer)schemaz$Expected list of field names, got {}zSFor the default directory flavor, need to specify a Schema or a list of field namesZhivez.Cannot specify 'field_names' for flavor 'hive'z$Expected Schema for 'schema', got {}zUnsupported flavor) ValueErrorr Zdiscover isinstancelistr+typepaZSchemar)r3 field_namesflavorZ dictionariesr-r-r. partitioningss:]         r;cCs\|dkr nNt|tr t|d}n8t|tr6t|d}n"t|ttfrFntdjt||S)z~ Validate input and return a Partitioning(Factory). It passes None through if no partitioning scheme is defined. N)r:)r9z4Expected Partitioning or PartitioningFactory, got {}) r5strr;r6rrr4r+r7)schemer-r-r._ensure_partitionings     r>cCsdt|tr|S|dkrtS|dkr*tS|dkr8tS|dkrRtsLtttStdj |dS) NparquetipcarrowfeathercsvZorczformat '{}' is not supported>rBrAr@) r5r rrrr'r4r)r&r+)objr-r-r._ensure_format s rEc sddlm}m}m}m}m}dkr,|n|t||fpVt|oVtj|}fdd|D}|rxhj|D]Z}|j } | |j krqzqz| |j krt |j qz| |jkrtdj|j qztdj|j qzW|fS)aA Treat a list of paths as files belonging to a single file system If the file system is local then also validates that all paths are referencing existing *files* otherwise any non-file paths will be silently skipped (for example on a remote filesystem). Parameters ---------- paths : list of path-like Note that URIs are not allowed. filesystem : FileSystem or str, optional If an URI is passed, then its path component will act as a prefix for the file paths. Returns ------- (FileSystem, list of str) File system object and a list of normalized paths. Raises ------ TypeError If the passed filesystem has wrong type. IOError If the file system is local and a referenced path is not available or not a file. r)LocalFileSystemSubTreeFileSystem_MockFileSystemFileType_ensure_filesystemNcsg|]}jt|qSr-)normalize_pathr).0p) filesystemr-r. Ksz,_ensure_multiple_sources..zPath {} points to a directory, but only file paths are supported. To construct a nested or union dataset pass a list of dataset objects instead.zPath {} exists but its type is unknown (could be a special file such as a Unix socket or character device, or Windows NUL / CON / ...)) pyarrow.fsrFrGrHrIrJr5Zbase_fs get_file_infor7FileZNotFoundFileNotFoundErrorpath DirectoryIsADirectoryErrorr+IOError) pathsrNrFrGrHrIrJis_localinfo file_typer-)rNr._ensure_multiple_sourcess.       r\cCstddlm}m}m}|||\}}|j|}|j|}|j|jkrP||dd}n|j|jkrd|g}nt |||fS)a Treat path as either a recursively traversable directory or a single file. Parameters ---------- path : path-like filesystem : FileSystem or str, optional If an URI is passed, then its path component will act as a prefix for the file paths. Returns ------- (FileSystem, list of str or fs.Selector) File system object and either a single item list pointing to a file or an fs.Selector object pointing to a directory. Raises ------ TypeError If the passed filesystem has wrong type. FileNotFoundError If the referenced file or directory doesn't exist. r)rI FileSelector_resolve_filesystem_and_pathT) recursive) rPrIr]r^rKrQr7rUrRrS)rTrNrIr]r^ file_infopaths_or_selectorr-r-r._ensure_single_sourcegs    rbc Csht|pd}t|}t|ttfr2t||\}} nt||\}} t||||d} t|| || } | j |S)z Create a FileSystemDataset which can be used to build a Dataset. Parameters are documented in the dataset function. Returns ------- FileSystemDataset r?)r;partition_base_direxclude_invalid_filesselector_ignore_prefixes) rEr>r5r6tupler\rbrrfinish) sourcer3rNr;r+rcrdrefsraoptionsfactoryr-r-r._filesystem_datasets rlcKs(tdd|jDrtdt||S)Ncss|]}|dk VqdS)Nr-)rLvr-r-r. sz%_in_memory_dataset..z@For in-memory datasets, you cannot pass any additional arguments)anyvaluesr4r)rhr3kwargsr-r-r._in_memory_datasetsrrc sVtdd|jDrtddkr:tjdd|Dfdd|D}t|S)Ncss|]}|dk VqdS)Nr-)rLrmr-r-r.rnsz!_union_dataset..zIWhen passing a list of Datasets, you cannot pass any additional argumentscSsg|] }|jqSr-)r3)rLchildr-r-r.rOsz"_union_dataset..csg|]}|jqSr-)Zreplace_schema)rLrs)r3r-r.rOs)rorpr4r8Z unify_schemasr")childrenr3rqr-)r3r._union_datasetsruc Csddlm}m}|dkr t}nt|ts2td|dkrB|}n||}|jt|}t|t |d}t ||||d} | j |S)ax Create a FileSystemDataset from a `_metadata` file created via `pyarrrow.parquet.write_metadata`. Parameters ---------- metadata_path : path, Path pointing to a single file parquet metadata file schema : Schema, optional Optionally provide the Schema for the Dataset, in which case it will not be inferred from the source. filesystem : FileSystem or URI string, default None If a single path is given as source and filesystem is None, then the filesystem will be inferred from the path. If an URI string is passed, then a filesystem object is constructed using the URI's optional path component as a directory prefix. See the examples below. Note that the URIs on Windows must follow 'file:///C:...' or 'file:/C:...' patterns. format : ParquetFileFormat An instance of a ParquetFileFormat if special options needs to be passed. partitioning : Partitioning, PartitioningFactory, str, list of str The partitioning scheme specified with the ``partitioning()`` function. A flavor string can be used as shortcut, and with a list of field names a DirectionaryPartitioning will be inferred. partition_base_dir : str, optional For the purposes of applying the partitioning, paths will be stripped of the partition_base_dir. Files not matching the partition_base_dir prefix will be skipped for partitioning discovery. The ignored files will still be part of the Dataset, but will not have partition information. Returns ------- FileSystemDataset r)rFrJNz+format argument must be a ParquetFileFormat)rcr;)rj) rPrFrJrr5r4rKrrr>rrg) Z metadata_pathr3rNr+r;rcrFrJrjrkr-r-r.parquet_datasets'  rvc Cst|||||||d}t|r*t|f|St|ttfrtdd|DrVt|f|Stdd|Drtt|f|Stdd|Drt|f|St dd|D} dj dd| D} t d j | n2t|t jt jfrt|f|St d j t|jd S) a Open a dataset. Datasets provides functionality to efficiently work with tabular, potentially larger than memory and multi-file dataset. - A unified interface for different sources, like Parquet and Feather - Discovery of sources (crawling directories, handle directory-based partitioned datasets, basic schema normalization) - Optimized reading with predicate pushdown (filtering rows), projection (selecting columns), parallel reading or fine-grained managing of tasks. Note that this is the high-level API, to have more control over the dataset construction use the low-level API classes (FileSystemDataset, FilesystemDatasetFactory, etc.) Parameters ---------- source : path, list of paths, dataset, list of datasets, (list of) batchesor tables, iterable of batches, RecordBatchReader, or URI Path pointing to a single file: Open a FileSystemDataset from a single file. Path pointing to a directory: The directory gets discovered recursively according to a partitioning scheme if given. List of file paths: Create a FileSystemDataset from explicitly given files. The files must be located on the same filesystem given by the filesystem parameter. Note that in contrary of construction from a single file, passing URIs as paths is not allowed. List of datasets: A nested UnionDataset gets constructed, it allows arbitrary composition of other datasets. Note that additional keyword arguments are not allowed. (List of) batches or tables, iterable of batches, or RecordBatchReader: Create an InMemoryDataset. If an iterable or empty list is given, a schema must also be given. If an iterable or RecordBatchReader is given, the resulting dataset can only be scanned once; further attempts will raise an error. schema : Schema, optional Optionally provide the Schema for the Dataset, in which case it will not be inferred from the source. format : FileFormat or str Currently "parquet" and "ipc"/"arrow"/"feather" are supported. For Feather, only version 2 files are supported. filesystem : FileSystem or URI string, default None If a single path is given as source and filesystem is None, then the filesystem will be inferred from the path. If an URI string is passed, then a filesystem object is constructed using the URI's optional path component as a directory prefix. See the examples below. Note that the URIs on Windows must follow 'file:///C:...' or 'file:/C:...' patterns. partitioning : Partitioning, PartitioningFactory, str, list of str The partitioning scheme specified with the ``partitioning()`` function. A flavor string can be used as shortcut, and with a list of field names a DirectionaryPartitioning will be inferred. partition_base_dir : str, optional For the purposes of applying the partitioning, paths will be stripped of the partition_base_dir. Files not matching the partition_base_dir prefix will be skipped for partitioning discovery. The ignored files will still be part of the Dataset, but will not have partition information. exclude_invalid_files : bool, optional (default True) If True, invalid files will be excluded (file format specific check). This will incur IO for each files in a serial and single threaded fashion. Disabling this feature will skip the IO, but unsupported files may be present in the Dataset (resulting in an error at scan time). ignore_prefixes : list, optional Files matching any of these prefixes will be ignored by the discovery process. This is matched to the basename of a path. By default this is ['.', '_']. Note that discovery happens only if a directory is passed as source. Returns ------- dataset : Dataset Either a FileSystemDataset or a UnionDataset depending on the source parameter. Examples -------- Opening a single file: >>> dataset("path/to/file.parquet", format="parquet") Opening a single file with an explicit schema: >>> dataset("path/to/file.parquet", schema=myschema, format="parquet") Opening a dataset for a single directory: >>> dataset("path/to/nyc-taxi/", format="parquet") >>> dataset("s3://mybucket/nyc-taxi/", format="parquet") Opening a dataset from a list of relatives local paths: >>> dataset([ ... "part0/data.parquet", ... "part1/data.parquet", ... "part3/data.parquet", ... ], format='parquet') With filesystem provided: >>> paths = [ ... 'part0/data.parquet', ... 'part1/data.parquet', ... 'part3/data.parquet', ... ] >>> dataset(paths, filesystem='file:///directory/prefix, format='parquet') Which is equivalent with: >>> fs = SubTreeFileSystem("/directory/prefix", LocalFileSystem()) >>> dataset(paths, filesystem=fs, format='parquet') With a remote filesystem URI: >>> paths = [ ... 'nested/directory/part0/data.parquet', ... 'nested/directory/part1/data.parquet', ... 'nested/directory/part3/data.parquet', ... ] >>> dataset(paths, filesystem='s3://bucket/', format='parquet') Similarly to the local example, the directory prefix may be included in the filesystem URI: >>> dataset(paths, filesystem='s3://bucket/nested/directory', ... format='parquet') Construction of a nested dataset: >>> dataset([ ... dataset("s3://old-taxi-data", format="parquet"), ... dataset("local/path/to/data", format="ipc") ... ]) )r3rNr;r+rcrdrecss|]}t|VqdS)N)r)rLelemr-r-r.rnszdataset..css|]}t|tVqdS)N)r5r)rLrwr-r-r.rnscss |]}t|tjtjfVqdS)N)r5r8 RecordBatchTable)rLrwr-r-r.rnscss|]}t|jVqdS)N)r7__name__)rLrwr-r-r.rnsz, css|]}dj|VqdS)z{}N)r+)rLtr-r-r.rnszExpected a list of path-like or dataset objects, or a list of batches or tables. The given list contains the following types: {}z\Expected a path-like, list of path-likes or a list of Datasets instead of the given type: {}N)dictrrlr5rfr6allrurrsetjoin TypeErrorr+r8rxryr7rz) rhr3r+rNr;rcrdZignore_prefixesrqZ unique_types type_namesr-r-r.dataset s:       rcst|trtdt|tr*|r*tdnJt|ttfrZttjfdd|D|d}n|dkrtttjg|d}t|tstd|S)NzhA PartitioningFactory cannot be used. Did you call the partitioning function without supplying a schema?zKProviding a partitioning_flavor with a Partitioning object is not supportedcsg|]}j|qSr-)r0)rLf)r3r-r.rOsz._ensure_write_partitioning..)r3r:)r:zDpartitioning must be a Partitioning object or a list of column names) r5rr4rrfr6r;r8r3)partr3r:r-)r3r._ensure_write_partitionings   rerrorc  Csddlm} t|ttfr6|p&|dj}t||d}nlt|tjtj fr`|pP|j}t||d}nBt|tj j svt |rt j||dd}d}nt|tt fstd|dkrt|tr|j}nt|}|dkr|j}||jkrtdj|||dkrd |j}| dkrd } t|t r$|j}n|j}t|||d }| ||\}}t|trb|j| dd }n|dk rttd |}t||||||| | | dS)a Write a dataset to a given format and partitioning. Parameters ---------- data : Dataset, Table/RecordBatch, RecordBatchReader, list of Table/RecordBatch, or iterable of RecordBatch The data to write. This can be a Dataset instance or in-memory Arrow data. If an iterable is given, the schema must also be given. base_dir : str The root directory where to write the dataset. basename_template : str, optional A template string used to generate basenames of written data files. The token '{i}' will be replaced with an automatically incremented integer. If not specified, it defaults to "part-{i}." + format.default_extname format : FileFormat or str The format in which to write the dataset. Currently supported: "parquet", "ipc"/"feather". If a FileSystemDataset is being written and `format` is not specified, it defaults to the same format as the specified FileSystemDataset. When writing a Table or RecordBatch, this keyword is required. partitioning : Partitioning or list[str], optional The partitioning scheme specified with the ``partitioning()`` function or a list of field names. When providing a list of field names, you can use ``partitioning_flavor`` to drive which partitioning type should be used. partitioning_flavor : str, optional One of the partitioning flavors supported by ``pyarrow.dataset.partitioning``. If omitted will use the default of ``partitioning()`` which is directory partitioning. schema : Schema, optional filesystem : FileSystem, optional file_options : FileWriteOptions, optional FileFormat specific write options, created using the ``FileFormat.make_write_options()`` function. use_threads : bool, default True Write files in parallel. If enabled, then maximum parallelism will be used determined by the number of available CPU cores. max_partitions : int, default 1024 Maximum number of partitions any batch may be written into. file_visitor : Function If set, this function will be called with a WrittenFile instance for each file created during the call. This object will have both a path attribute and a metadata attribute. The path attribute will be a string containing the path to the created file. The metadata attribute will be the parquet metadata of the file. This metadata will have the file path attribute set and can be used to build a _metadata file. The metadata attribute will be None if the format is not parquet. Example visitor which simple collects the filenames created:: visited_paths = [] def file_visitor(written_file): visited_paths.append(written_file.path) existing_data_behavior : 'error' | 'overwrite_or_ignore' | 'delete_matching' Controls how the dataset will handle data that already exists in the destination. The default behavior ('error') is to raise an error if any data exists in the destination. 'overwrite_or_ignore' will ignore any existing data and will overwrite files with the same name as an output file. Other existing files will be ignored. This behavior, in combination with a unique basename_template for each write, will allow for an append workflow. 'delete_matching' is useful when you are writing a partitioned dataset. The first time each partition directory is encountered the entire directory will be deleted. This allows you to overwrite old partitions completely. r)r^)r3T)r3 use_asyncNzOnly Dataset, Scanner, Table/RecordBatch, RecordBatchReader, a list of Tables/RecordBatches, or iterable of batches are supported.zTSupplied FileWriteOptions have format {}, which doesn't match supplied FileFormat {}z part-{i}.i)r3r:) use_threadsrz.Cannot specify a schema when writing a Scanner)rPr^r5r6rfr3rr8rxryr@ZRecordBatchReaderrr Z from_batchesrr4r r+rEZmake_write_optionsrZdefault_extnameZdataset_schemarscannerr%)database_dirZbasename_templater+r;Zpartitioning_flavorr3rNZ file_optionsrZmax_partitionsZ file_visitorZexisting_data_behaviorr^Zpartitioning_schemarr-r-r. write_datasetsPS           r)NNNN)N)N)NNNNNNN)N)N)NNNNN)NNNNNNN) NNNNNNNTNNr)=__doc__Zpyarrowr8Z pyarrow.utilrrrZpyarrow._datasetrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r'r)Zpyarrow._dataset_orcr&r(r/r0r2r;r>rEr\rbrlrrrurvrrrr-r-r-r.sL$    L /    = 5