The hierarchical namespace feature organizes objects into a directory hierarchy, enabling atomic directory and object renames without listing all objects that share a prefix. Unlike the default flat namespace that simulates directories with forward slashes (/), hierarchical namespace significantly improves directory management performance.
Benefits
-
Atomic operations on directories
In a flat namespace, applications may need to process millions of objects for a single directory-level task. With hierarchical namespace, a parent directory update is a single atomic operation that completes multiple directory-level tasks simultaneously.
-
Optimized performance
Hierarchical namespace eliminates the need to replicate or convert data before analysis, improving directory management performance. This is critical for big data frameworks such as Hive and Spark, which write results to temporary directories and rename them after task completion. In a flat namespace, the rename often takes longer than the task itself.
Procedure
-
Enable hierarchical namespace.
Hierarchical namespace can only be enabled during bucket creation and cannot be disabled afterward. For more information about how to enable hierarchical namespace, see Create buckets.
-
Perform directory operations on a hierarchical namespace bucket.
The following table lists the methods for managing directories in a hierarchical namespace bucket.
Implementation method
Description
OSS console
Web-based management console
SDK code samples for directory operations
Usage notes
-
Supported regions
Hierarchical namespace is available only in the following regions: US (Silicon Valley), Japan (Tokyo), UK (London), and Malaysia (Kuala Lumpur).
-
Create directories
A directory name cannot contain consecutive forward slashes (/).
Data cannot be written to directories. The Content-Length of a directory can be set only to 0.
The Content-Type of a directory can be set only to
application/x-directory. -
Rename a directory or object
A renamed directory or object cannot share a name with an existing directory or object in the same bucket.
The parent directory in the destination path must exist. For example, to rename a directory to
destfolder/examplefolder/test, the parent directorydestfolder/examplefoldermust exist in the bucket. -
Delete directories
-
Recursive delete
Deletes a directory and all its objects and subdirectories. Requires the DeleteObject permission on the directory and all its contents.
For example, to recursively delete dest/testfolder, you need the DeleteObject permission on
dest/testfolderanddest/testfolder/*.ImportantIf a concurrent write request targets a directory during recursive deletion, the delete may fail.
-
Non-recursive delete
Deletes empty directories only. Requires the DeleteObject permission on the target directory.
-
Unsupported features
The following table lists the features not supported by hierarchical namespace buckets.
|
Category |
Description |
|
Bucket features |
|
|
Object features |
|