| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../api/../generated/../../cpp/api/filesystem.html | [Back] [Original] |
FileSystem entry type.
Values:
Entry is not found.
Entry exists but its type is unknown.
This can designate a special file such as a Unix socket or character device, or Windows NUL / CON /
Entry is a regular file.
Entry is a directory.
FileSystem entry info.
Public Functions
The full file path in the filesystem.
The file base name (component after the last directory separator)
The size in bytes, if available.
Only regular files are guaranteed to have a size.
The file extension (excluding the dot)
The time of last modification, if available.
Function object implementing less-than comparison and hashing by path, to support sorting infos, using them as keys, and other interactions with the STL.
File selector for filesystem APIs.
Public Members
The directory in which to select files.
If the path exists but doesnt point to a directory, this should be an error.
The behavior if base_dir isnt found in the filesystem.
If false, an error is returned. If true, an empty selection is returned.
Whether to recurse into subdirectories.
The maximum number of subdirectories to recurse into.
Abstract file system API.
Subclassed by arrow::fs::AzureFileSystem, arrow::fs::GcsFileSystem, arrow::fs::HadoopFileSystem, arrow::fs::LocalFileSystem, arrow::fs::S3FileSystem, arrow::fs::SlowFileSystem, arrow::fs::SubTreeFileSystem, arrow::fs::internal::MockFileSystem
Public Functions
EXPERIMENTAL: The IOContext associated with this filesystem.
Normalize path for the given filesystem.
The default implementation of this method is a no-op, but subclasses may allow normalizing irregular path forms (such as Windows local paths).
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Make a URI from which FileSystemFromUri produces an equivalent filesystem.
path The path component to use in the resulting URI. Must be absolute.
A URI string, or an error if an equivalent URI cannot be produced
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, for many targets at once.
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Async version of GetFileInfo.
Streaming async version of GetFileInfo.
The returned generator is not async-reentrant, i.e. you need to wait for the returned future to complete before calling the generator again.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
Async version of DeleteDirContents.
Async version of DeleteDirContents.
This overload allows missing directories.
EXPERIMENTAL: Delete the root directorys contents, recursively.
Implementations may decide to raise an error if this operation is too dangerous.
Delete many files.
The default implementation issues individual delete operations in sequence.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input stream for sequential reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an input file for random access reading.
Open an input file for random access reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Async version of OpenInputStream.
Async version of OpenInputStream.
Async version of OpenInputFile.
Async version of OpenInputFile.
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Ensure all registered filesystem implementations are finalized.
Individual finalizers may wait for concurrent calls to finish so as to avoid race conditions. After this function has been called, all filesystem APIs will fail with an error.
The user is responsible for synchronization of calls to this function.
Create a new FileSystem by URI.
Recognized schemes are file, mock, hdfs, viewfs, s3, gs, gcs, abfs and abfss.
Support for other schemes can be added using RegisterFileSystemFactory.
uri [in] a URI-based path, ex: file:///some/local/path
out_path [out] (optional) Path inside the filesystem.
out_fs FileSystem instance.
Create a new FileSystem by URI with extended backend-specific filesystem options.
Recognized schemes are file, mock, hdfs, viewfs, s3, gs, gcs, abfs and abfss.
Support for other schemes can be added using RegisterFileSystemFactory.
uri [in] the URI to give access to
options [in] a list of backend-specific filesystem options Each option is a (name, value) pair. The expected type is specific to the backend and option name. Options are forwarded to schemes dispatched through a registered FileSystemFactory. Non-empty options return NotImplemented for a registered FileSystemFactory that does not support them or for schemes not handled by a registered factory.
out_path [out] (optional) Path inside the filesystem.
out_fs FileSystem instance.
Create a new FileSystem by URI with a custom IO context.
Recognized schemes are file, mock, hdfs, viewfs, s3, gs, gcs, abfs and abfss.
Support for other schemes can be added using RegisterFileSystemFactory.
uri [in] a URI-based path, ex: file:///some/local/path
io_context [in] an IOContext which will be associated with the filesystem
out_path [out] (optional) Path inside the filesystem.
out_fs FileSystem instance.
Create a new FileSystem by URI with a custom IO context with backend-specific filesystem options.
Recognized schemes are file, mock, hdfs, viewfs, s3, gs, gcs, abfs and abfss.
Support for other schemes can be added using RegisterFileSystemFactory.
uri [in] a URI-based path, ex: file:///some/local/path
options [in] a list of backend-specific filesystem options Each option is a (name, value) pair. The expected type is specific to the backend and option name. Options are forwarded to schemes dispatched through a registered FileSystemFactory. Non-empty options return NotImplemented for a registered FileSystemFactory that does not support them or for schemes not handled by a registered factory.
io_context [in] an IOContext which will be associated with the filesystem
out_path [out] (optional) Path inside the filesystem.
out_fs FileSystem instance.
Create a new FileSystem by URI.
Support for other schemes can be added using RegisterFileSystemFactory.
Same as FileSystemFromUri, but in addition also recognize non-URIs and treat them as local filesystem paths. Only absolute local filesystem paths are allowed.
Create a new FileSystem by URI with a custom IO context.
Support for other schemes can be added using RegisterFileSystemFactory.
Same as FileSystemFromUri, but in addition also recognize non-URIs and treat them as local filesystem paths. Only absolute local filesystem paths are allowed.
Register a FileSystem factory.
Support for custom URI schemes can be added by registering a factory for the corresponding FileSystem.
scheme [in] a Uri scheme which the factory will handle. If a factory has already been registered for a scheme, the new factory will be ignored.
factory [in] a function which can produce a FileSystem for Uris which match scheme.
finalizer [in] a function which must be called to finalize the factory before the process exits, or nullptr if no finalization is necessary.
raises KeyError if a name collision occurs.
Register FileSystem factories from a shared library.
FileSystem implementations may be housed in separate shared libraries and only registered when the shared library is explicitly loaded. FileSystemRegistrar is provided to simplify definition of such libraries: each instance at namespace scope in the library will register a factory for a scheme. Any library which uses FileSystemRegistrars and which must be dynamically loaded should be loaded using LoadFileSystemFactories(), which will additionally merge registries are if necessary (static linkage to arrow can produce isolated registries).
A FileSystem implementation that delegates to another implementation after prepending a fixed base path.
This is useful to expose a logical view of a subtree of a filesystem, for example a directory in a LocalFileSystem. This works on abstract paths, i.e. paths using forward slashes and and a single root /. Windows paths are not guaranteed to work. This makes no security guarantee. For example, symlinks may allow to escape the subtree and access other parts of the underlying filesystem.
Public Functions
Normalize path for the given filesystem.
The default implementation of this method is a no-op, but subclasses may allow normalizing irregular path forms (such as Windows local paths).
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Streaming async version of GetFileInfo.
The returned generator is not async-reentrant, i.e. you need to wait for the returned future to complete before calling the generator again.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
EXPERIMENTAL: Delete the root directorys contents, recursively.
Implementations may decide to raise an error if this operation is too dangerous.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input stream for sequential reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an input file for random access reading.
Open an input file for random access reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Async version of OpenInputStream.
Async version of OpenInputStream.
Async version of OpenInputFile.
Async version of OpenInputFile.
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Options for the LocalFileSystem implementation.
Public Members
Whether OpenInputStream and OpenInputFile return a mmaped file, or a regular one.
Options related to GetFileInfoGenerator interface.
EXPERIMENTAL: The maximum number of directories processed in parallel by GetFileInfoGenerator.
EXPERIMENTAL: The maximum number of entries aggregated into each FileInfoVector chunk by GetFileInfoGenerator.
Since each FileInfo entry needs a separate stat system call, a directory with a very large number of files may take a lot of time to process entirely. By generating a FileInfoVector after this chunk size is reached, we ensure FileInfo entries can start being consumed from the FileInfoGenerator with less initial latency.
Public Static Functions
Initialize with defaults.
A FileSystem implementation accessing files on the local machine.
This class handles only /-separated paths. If desired, conversion from Windows backslash-separated paths should be done by the caller. Details such as symlinks are abstracted away (symlinks are always followed, except when deleting an entry).
Public Functions
Normalize path for the given filesystem.
The default implementation of this method is a no-op, but subclasses may allow normalizing irregular path forms (such as Windows local paths).
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Make a URI from which FileSystemFromUri produces an equivalent filesystem.
path The path component to use in the resulting URI. Must be absolute.
A URI string, or an error if an equivalent URI cannot be produced
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Streaming async version of GetFileInfo.
The returned generator is not async-reentrant, i.e. you need to wait for the returned future to complete before calling the generator again.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
EXPERIMENTAL: Delete the root directorys contents, recursively.
Implementations may decide to raise an error if this operation is too dangerous.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input file for random access reading.
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Options for the S3FileSystem implementation.
Public Functions
Configure with the default AWS credentials provider chain.
Configure with anonymous credentials. This will only let you access public buckets.
Configure with explicit access and secret key.
Configure with credentials from an assumed role.
Configure with credentials from role assumed using a web identity token.
Public Members
Smart defaults for option values.
The possible values for this setting are explained in the AWS docs: https://docs.aws.amazon.com/sdkref/latest/guide/feature-smart-config-defaults.html
AWS region to connect to.
If unset, the AWS SDK will choose a default value. The exact algorithm depends on the SDK version. Before 1.8, the default is hardcoded to us-east-1. Since 1.8, several heuristics are used to determine the region (environment variables, configuration profile, EC2 metadata server).
Socket connection timeout, in seconds.
If negative, the AWS SDK default value is used (typically 1 second).
Socket read timeout on Windows and macOS, in seconds.
If negative, the AWS SDK default value is used (typically 3 seconds). This option is ignored on non-Windows, non-macOS systems.
If non-empty, override region with a connect string such as localhost:9000.
S3 connection transport, default https.
ARN of role to assume.
Optional identifier for an assumed role session.
Optional external identifier to pass to STS when assuming a role.
Frequency (in seconds) to refresh temporary credentials from assumed role.
If connection is through a proxy, set options here.
AWS credentials provider.
Type of credentials being used. Set along with credentials_provider.
Whether to use virtual addressing of buckets.
If true, then virtual addressing is always enabled. If false, then virtual addressing is only enabled if endpoint_override is empty.
This can be used for non-AWS backends that only support virtual hosted-style access.
Whether OutputStream writes will be issued in the background, without blocking.
Whether to allow creation of buckets.
When S3FileSystem creates new buckets, it does not pass any non-default settings. In AWS S3, the bucket and all objects will be not publicly visible, and there will be no bucket policies and no resource tags. To have more control over how buckets are created, use a different API to create them.
Whether to allow deletion of buckets.
Whether to allow pessimistic directory creation in CreateDir function.
By default, CreateDir function will try to create the directory without checking its existence. Its an optimization to try directory creation and catch the error, rather than issue two dependent I/O calls. Though for key/value storage like Google Cloud Storage, too many creation calls will breach the rate limit for object mutation operations and cause serious consequences. Its also possible you dont have creation access for the parent directory. Set it to be true to address these scenarios.
Whether to allow file-open methods to return before the actual open.
Enabling this may reduce the latency of OpenInputStream, OpenOutputStream, and similar methods, by reducing the number of roundtrips necessary. It may also allow usage of more efficient S3 APIs for small files. The downside is that failure conditions such as attempting to open a file in a non-existing bucket will only be reported when actual I/O is done (at worse, when attempting to close the file).
Default metadata for OpenOutputStream.
This will be ignored if non-empty metadata is passed to OpenOutputStream.
Optional retry strategy to determine which error types should be retried, and the delay between retries.
Optional customer-provided key for server-side encryption (SSE-C).
This should be the 32-byte AES-256 key, unencoded.
Optional path to a single PEM file holding all TLS CA certificates.
If empty, global filesystem options will be used (see FileSystemGlobalOptions); if the corresponding global filesystem option is also empty, the underlying TLS librarys defaults will be used.
Note this option may be ignored on some systems (Windows, macOS).
Optional path to a directory holding TLS CA.
The given directory should contain CA certificates as individual PEM files named along the OpenSSL hashed format.
If empty, global filesystem options will be used (see FileSystemGlobalOptions); if the corresponding global filesystem option is also empty, the underlying TLS librarys defaults will be used.
Note this option may be ignored on some systems (Windows, macOS).
Whether to verify the S3 endpoints TLS certificate.
This option applies if the scheme is https.
Public Static Functions
Initialize with default credentials provider chain.
This is recommended if you use the standard AWS environment variables and/or configuration file.
Initialize with anonymous credentials.
This will only let you access public buckets.
Initialize with explicit access and secret key.
Optionally, a session token may also be provided for temporary credentials (from STS).
Initialize from an assumed role.
Initialize from an assumed role with web-identity.
Uses the AWS SDK which uses environment variables to generate temporary credentials.
Equivalent to FromUri() with specific backend options that cant be represented on the URI or are better kept out of it (such as credentials).
Each option is a (name, value) pair. Recognized keys:
access_key (std::string)
secret_key (std::string)
session_token (std::string)
retry_strategy (std::shared_ptr<S3RetryStrategy>)
default_metadata (std::shared_ptr<const KeyValueMetadata>) Options appearing both in the URI and in the options list return Status::Invalid; unknown keys or invalid values return Status::Invalid.
S3-backed FileSystem implementation.
Some implementation notes:
buckets are special and the operations available on them may be limited or more expensive than desired.
Public Functions
Return the actual region this filesystem connects to.
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Make a URI from which FileSystemFromUri produces an equivalent filesystem.
path The path component to use in the resulting URI. Must be absolute.
A URI string, or an error if an equivalent URI cannot be produced
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Streaming async version of GetFileInfo.
The returned generator is not async-reentrant, i.e. you need to wait for the returned future to complete before calling the generator again.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
Async version of DeleteDirContents.
EXPERIMENTAL: Delete the root directorys contents, recursively.
Implementations may decide to raise an error if this operation is too dangerous.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Create a sequential input stream for reading from a S3 object.
NOTE: Reads from the stream will be synchronous and unbuffered. You way want to wrap the stream in a BufferedInputStream or use a custom readahead strategy to avoid idle waits.
Create a sequential input stream for reading from a S3 object.
This override avoids a HEAD request by assuming the FileInfo contains correct information.
Create a random access file for reading from a S3 object.
See OpenInputStream for performance notes.
Create a random access file for reading from a S3 object.
This override avoids a HEAD request by assuming the FileInfo contains correct information.
Create a sequential output stream for writing to a S3 object.
NOTE: Writes to the stream will be buffered. Depending on S3Options.background_writes, they can be synchronous or not. It is recommended to enable background_writes unless you prefer implementing your own background execution strategy.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Public Static Functions
Create a S3FileSystem instance from the given options.
Initialize the S3 APIs with the specified set of options.
It is required to call this function at least once before using S3FileSystem.
Once this function is called you MUST call FinalizeS3 before the end of the application in order to avoid a segmentation fault at shutdown.
Options for the HDFS implementation.
HDFS-backed FileSystem implementation.
implementation notes:
This is a wrapper of arrow/io/hdfs, so we can use FileSystem API to handle hdfs.
Public Functions
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
EXPERIMENTAL: Delete the root directorys contents, recursively.
Implementations may decide to raise an error if this operation is too dangerous.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input file for random access reading.
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Public Static Functions
Create a HdfsFileSystem instance from the given options.
Options for the GcsFileSystem implementation.
Public Functions
Equivalent to GcsOptions::Defaults().
Public Members
Location to use for creating buckets.
If set used to control total time allowed for retrying underlying errors.
The default policy is to retry for up to 15 minutes.
Default metadata for OpenOutputStream.
This will be ignored if non-empty metadata is passed to OpenOutputStream.
The project to use for creating buckets.
If not set, the library uses the GOOGLE_CLOUD_PROJECT environment variable. Most I/O operations do not need a project id, only applications that create new buckets need a project id.
Public Static Functions
Initialize with Google Default Credentials.
Create options configured to use Application Default Credentials. The details of this mechanism are too involved to describe here, but suffice is to say that applications can override any defaults using an environment variable (GOOGLE_APPLICATION_CREDENTIALS), and that the defaults work with most Google Cloud Platform deployment environments (GCE, GKE, Cloud Run, etc.), and that have the same behavior as the gcloud CLI tool on your workstation.
Initialize with anonymous credentials.
Initialize with access token.
These credentials are useful when using an out-of-band mechanism to fetch access tokens. Note that access tokens are time limited, you will need to manually refresh the tokens created by the out-of-band mechanism.
Initialize with service account impersonation.
Service account impersonation allows one principal (a user or service account) to impersonate a service account. It requires that the calling principal has the necessary permissions on the service account.
Creates service account credentials from a JSON object in string form.
The json_object is expected to be in the format described by aip/4112. Such an object contains the identity of a service account, as well as a private key that can be used to sign tokens, showing the caller was holding the private key.
In GCP one can create several keys for each service account, and these keys are downloaded as a JSON key file. The contents of such a file are in the format required by this function. Remember that key files and their contents should be treated as any other secret with security implications, think of them as passwords (because they are!), dont store them or output them where unauthorized persons may read them.
Most applications should probably use default credentials, maybe pointing them to a file with these contents. Using this function may be useful when the json object is obtained from a Cloud Secret Manager or a similar service.
Initialize from URIs such as gs://bucket/object.
GCS-backed FileSystem implementation.
GCS (Google Cloud Storage - https://cloud.google.com/storage) is a scalable object storage system for any amount of data. The main abstractions in GCS are buckets and objects. A bucket is a namespace for objects, buckets can store any number of objects, tens of millions and even billions is not uncommon. Each object contains a single blob of data, up to 5TiB in size. Buckets are typically configured to keep a single version of each object, but versioning can be enabled. Versioning is important because objects are immutable, once created one cannot append data to the object or modify the object data in any way.
GCS buckets are in a global namespace, if a Google Cloud customer creates a bucket named foo no other customer can create a bucket with the same name. Note that a principal (a user or service account) may only list the buckets they are entitled to, and then only within a project. It is not possible to list all the buckets.
Within each bucket objects are in flat namespace. GCS does not have folders or directories. However, following some conventions it is possible to emulate directories. To this end, this class:
All buckets are treated as directories at the root
Creating a root directory results in a new bucket being created, this may be slower than most GCS operations.
The class creates marker objects for a directory, using a metadata attribute to annotate the file.
GCS can list all the objects with a given prefix, this is used to emulate listing of directories.
In object lists GCS can summarize all the objects with a common prefix as a single entry, this is used to emulate non-recursive lists. Note that GCS list time is proportional to the number of objects in the prefix. Listing recursively takes almost the same time as non-recursive lists.
Public Functions
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents, recursively.
Delete a directorys contents, recursively.
Like DeleteDir, but doesnt delete the directory itself. Passing an empty path ( or /) is disallowed, see DeleteRootDirContents.
This is not implemented in GcsFileSystem, as it would be too dangerous.
Move / rename a file or directory.
If the destination exists:
if it is a non-empty directory, an error is returned
otherwise, if it has the same type as the source, it is replaced
otherwise, behavior is unspecified (implementation-dependent).
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input stream for sequential reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an input file for random access reading.
Open an input file for random access reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Public Static Functions
Create a GcsFileSystem instance from the given options.
Options for the AzureFileSystem implementation.
By default, authentication is handled by the Azure SDKs credential chain which may read from multiple environment variables, such as:
AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
AZURE_AUTHORITY_HOST
AZURE_CLIENT_CERTIFICATE_PATH
AZURE_FEDERATED_TOKEN_FILE
Functions are provided for explicit configuration of credentials if that is preferred.
Public Members
The name of the Azure Storage Account being accessed.
All service URLs will be constructed using this storage account name. ConfigureAccountKeyCredential assumes the user wants to authenticate this account.
hostname[:port] of the Azure Blob Storage Service.
If the hostname is a relative domain name (one that starts with a .), then storage account URLs will be constructed by prepending the account name to the hostname. If the hostname is a fully qualified domain name, then the hostname will be used as-is and the account name will follow the hostname in the URL path.
Default: .blob.core.windows.net
hostname[:port] of the Azure Data Lake Storage Gen 2 Service.
If the hostname is a relative domain name (one that starts with a .), then storage account URLs will be constructed by prepending the account name to the hostname. If the hostname is a fully qualified domain name, then the hostname will be used as-is and the account name will follow the hostname in the URL path.
Default: .dfs.core.windows.net
Azure Blob Storage connection transport.
Default: https
Azure Data Lake Storage Gen 2 connection transport.
Default: https
Default metadata for OpenOutputStream.
This will be ignored if non-empty metadata is passed to OpenOutputStream.
Whether OutputStream writes will be issued in the background, without blocking.
Public Static Functions
Construct a new AzureOptions from an URI.
Supported formats:
abfs[s]://<account>.blob.core.windows.net[/<container>[/<path>]]
abfs[s]://<container>@<account>.dfs.core.windows.net[/path]
abfs[s]://[<account@]<host[.domain]>[<:port>][/<container>[/path]]
abfs[s]://[<account@]<container>[/path]
(1) and (2) are compatible with the Azure Data Lake Storage Gen2 URIs 1, (3) is for Azure Blob Storage compatible service including Azurite, and (4) is a shorter version of (1) and (2).
Note that there is no difference between abfs and abfss. HTTPS is used with abfs by default. You can force to use HTTP by specifying enable_tls=false query.
Supported query parameters:
blob_storage_authority: Set AzureOptions::blob_storage_authority
dfs_storage_authority: Set AzureOptions::dfs_storage_authority
enable_tls: If its false or 0, HTTP not HTTPS is used.
credential_kind: One of default, anonymous, workload_identity, environment or cli. If default is specified, its just ignored. If anonymous is specified, AzureOptions::ConfigureAnonymousCredential() is called. If workload_identity is specified, AzureOptions::ConfigureWorkloadIdentityCredential() is called. If environment is specified, AzureOptions::ConfigureEnvironmentCredential() is called. If cli is specified, AzureOptions::ConfigureCLICredential() is called.
tenant_id: You must specify client_id and client_secret too. AzureOptions::ConfigureClientSecretCredential() is called.
client_id: If you dont specify tenant_id and client_secret, AzureOptions::ConfigureManagedIdentityCredential() is called. If you specify tenant_id and client_secret too, AzureOptions::ConfigureClientSecretCredential() is called.
client_secret: You must specify tenant_id and client_id too. AzureOptions::ConfigureClientSecretCredential() is called.
A SAS token is made up of several query parameters. Appending a SAS token to the URI configures SAS token auth by calling AzureOptions::ConfigureSASCredential().
FileSystem implementation backed by Azure Blob Storage (ABS) 1 and Azure Data Lake Storage Gen2 (ADLS Gen2) 2.
ADLS Gen2 isnt a dedicated service or account type. Its a set of capabilities that support high throughput analytic workloads, built on Azure Blob Storage. All the data ingested via the ADLS Gen2 APIs is persisted as blobs in the storage account. ADLS Gen2 provides filesystem semantics, file-level security, and Hadoop compatibility. ADLS Gen1 exists as a separate object that will retired on 2024-02-29 and new ADLS accounts use Gen2 instead.
ADLS Gen2 and Blob APIs can operate on the same data, but there are some limitations 3. The ones that are relevant to this implementation are listed here:
You cant use Blob APIs, and ADLS APIs to write to the same instance of a file. If you write to a file by using ADLS APIs then that files blocks wont be visible to calls to the GetBlockList Blob API. The only exception is when youre overwriting.
When you use the ListBlobs operation without specifying a delimiter, the results include both directories and blobs. If you choose to use a delimiter, use only a forward slash (/) the only supported delimiter.
If you use the DeleteBlob API to delete a directory, that directory is deleted only if its empty. This means that you cant use the Blob API delete directories recursively.
Public Functions
Return the original Azure options when constructing the filesystem.
Get info for the given target.
Any symlink is automatically dereferenced, recursively. A nonexistent or unreachable file returns an Ok status and has a FileType of value NotFound. An error status indicates a truly exceptional condition (low-level I/O error, etc.).
Same, according to a selector.
The selectors base directory will not be part of the results, even if it exists. If it doesnt exist, see FileSelector::allow_not_found.
Create a directory and subdirectories.
This function succeeds if the directory already exists.
Delete a directory and its contents recursively.
Atomicity is guaranteed only on Hierarchical Namespace Storage accounts.
Non-atomically deletes the contents of a directory.
This function can return a bad Status after only partially deleting the contents of the directory.
Deletion of all the containers in the storage account (not implemented for safety reasons).
Deletes a file.
Supported on both flat namespace and Hierarchical Namespace storage accounts. A check is made to guarantee the parent directory doesnt disappear after the blob is deleted and while this operation is running, no other client can delete the parent directory due to the use of leases.
This means applications can safely retry this operation without coordination to guarantee only one client/process is trying to delete the same file.
Move/rename a file or directory.
There are no files immediately at the root directory, so paths like /segment always refer to a container of the storage account and are treated as directories.
If dest exists but the operation fails for some reason, Move guarantees dest is not lost.
Conditions for a successful move:
src must exist.
dest cant contain a strict path prefix of src. More generally, a directory cant be made a subdirectory of itself.
If dest already exists and its a file, src must also be a file. dest is then replaced by src.
All components of dest must exist, except for the last.
If dest already exists and its a directory, src must also be a directory and dest must be empty. dest is then replaced by src and its contents.
Leases are used to guarantee the pre-condition checks and the rename operation are atomic: other clients cant invalidate the pre-condition in the time between the checks and the actual rename operation.
This is possible because Move() is only support on storage accounts with Hierarchical Namespace Support enabled.
Limitations
Moves are not supported on storage accounts without Hierarchical Namespace support enabled
Moves across different containers are not supported
Moving a path of the form /container is not supported as it would require moving all the files in a container to another container. The only exception is a Move("/container_a", "/container_b") where both containers are empty or container_b doesnt even exist. The atomicity of the emptiness checks followed by the renaming operation is guaranteed by the use of leases.
Copy a file.
If the destination exists and is a directory, an error is returned. Otherwise, it is replaced.
Open an input stream for sequential reading.
Open an input stream for sequential reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an input file for random access reading.
Open an input file for random access reading.
This override assumes the given FileInfo validly represents the files characteristics, and may optimize access depending on them (for example avoid querying the file size or its existence).
Open an output stream for sequential writing.
If the target already exists, existing data is truncated.
Open an output stream for appending.
If the target doesnt exist, a new empty file is created.
Note: some filesystem implementations do not support efficient appending to an existing file, in which case this method will return NotImplemented. Consider writing to multiple files (using e.g. the dataset layer) instead.
Ensure a URI (or path) is compatible with the given filesystem and return the path.
This method will check to ensure the given filesystem is compatible with the URI. This can be useful when the user provides both a URI and a filesystem or when a user provides multiple URIs that should be compatible with the same filesystem.
uri_string can be an absolute path instead of a URI. In that case it will ensure the filesystem (if supplied) is the local filesystem (or some custom filesystem that is capable of reading local paths) and will normalize the paths file separators.
Note, this method only checks to ensure the URI scheme is valid. It will not detect inconsistencies like a mismatching region or endpoint override.
uri_string A URI representing a resource in the given filesystem.
The path inside the filesystem that is indicated by the URI.
| Web Proxy Viewer | New URL | Original Page |