IFdbDirectory
Namespace: FoundationDB.Client · interface
Represents a directory in the DirectoryLayer. A Directory stores the path at which it is located and the layer that was used to create it.
Remarks
The IFdbDirectory interface contains methods to operate on itself and its subdirectories.
Properties
DirectoryLayer
FdbDirectoryLayer DirectoryLayer { get; }
Get the DirectoryLayer that was used to create this Directory.
FullName
string FullName { get; }
Full name of this Directory
This string does not include the layer id of each path segments. Please use dir.Path.ToString() in order to get a roundtrip-able string representation of the path of this subspace.
Layer
string Layer { get; }
Gets the layer id that was stored when this Directory was created.
Location
FdbDirectorySubspaceLocation Location { get; }
Gets the location that points to this Directory
Name
string Name { get; }
Name of this Directory.
Path
FdbPath Path { get; }
Gets the path represented by this Directory.
This path includes the layers id of the directory and all its parent.
Methods
ChangeLayerAsync
Task<FdbDirectorySubspace> ChangeLayerAsync(IFdbTransaction trans, string newLayer)
Change the layer id of this directory
trans— Transaction to use for the operationnewLayer— New layer id of this directory
CheckLayer
void CheckLayer(string layer)
Ensure that this directory was registered with the correct layer id
layer— Expected layer id (if not empty)
CreateAsync
Task<FdbDirectorySubspace> CreateAsync(IFdbTransaction trans, FdbPath subPath)
Creates a subdirectory with the given subPath (creating intermediate subdirectories if necessary). An exception is thrown if the given subdirectory already exists.
trans— Transaction to use for the operationsubPath— Relative path of the subdirectory to create
CreateOrOpenAsync
Task<FdbDirectorySubspace> CreateOrOpenAsync(IFdbTransaction trans, FdbPath subPath)
Opens a subdirectory with the given path. If the subdirectory does not exist, it is created (creating intermediate subdirectories if necessary). If layer is specified, it is checked against the layer of an existing subdirectory or set as the layer of a new subdirectory.
ExistsAsync
Task<bool> ExistsAsync(IFdbReadOnlyTransaction trans, FdbPath subPath = null)
Checks if this directory exists
trans— Transaction to use for the operationsubPath— Path of the directory to test
Returns: Returns true if the directory exists, otherwise false.
ListAsync
Task<List<FdbPath>> ListAsync(IFdbReadOnlyTransaction trans, FdbPath subPath = null)
Returns the list of all the subdirectories of the current directory.
trans— Transaction to use for the operationsubPath— Path of the directory to list
MoveAsync
Task<FdbDirectorySubspace> MoveAsync(IFdbTransaction trans, FdbPath oldPath, FdbPath newPath)
Moves the specified subdirectory to newPath. There is no effect on the physical prefix of the given directory, or on clients that already have the directory open. An error is raised if a directory already exists at new_path.
trans— Transaction to use for the operationoldPath— Relative path under this directory of the subdirectory to be movednewPath— Relative path under this directory where the subdirectory will be moved to
Returns: Returns the directory at its new location if successful.
MoveToAsync
Task<FdbDirectorySubspace> MoveToAsync(IFdbTransaction trans, FdbPath newAbsolutePath)
Moves the current directory to newAbsolutePath. There is no effect on the physical prefix of the given directory, or on clients that already have the directory open. An error is raised if a directory already exists at new_path, or if the new path points to a child of the current directory.
trans— Transaction to use for the operationnewAbsolutePath— Full path (from the root) where this directory will be moved
Returns: Returns the directory at its new location if successful.
OpenAsync
Task<FdbDirectorySubspace> OpenAsync(IFdbReadOnlyTransaction trans, FdbPath path)
Opens a subdirectory with the given path. An exception is thrown if the subdirectory does not exist, or if a layer is specified and a different layer was specified when the subdirectory was created.
trans— Transaction to use for the operationpath— Relative path of the subdirectory to open
RegisterAsync
Task<FdbDirectorySubspace> RegisterAsync(IFdbTransaction trans, FdbPath subPath, Slice prefix)
Registers an existing prefix as a directory with the given subPath (creating parent directories if necessary). This method is only indented for advanced use cases.
trans— Transaction to use for the operationsubPath— Path of the directory to createprefix— The directory will be created with the given physical prefix; otherwise a prefix is allocated automatically.
RemoveAsync
Task RemoveAsync(IFdbTransaction trans, FdbPath subPath = null)
Removes a directory, its contents, and all subdirectories. Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
trans— Transaction to use for the operationsubPath— Path of the directory to remove. Will remove the current directory ifsubPathis empty
TryCreateAsync
Task<FdbDirectorySubspace> TryCreateAsync(IFdbTransaction trans, FdbPath subPath)
Creates a subdirectory with the given subPath (creating intermediate subdirectories if necessary), unless it already exists. An exception is thrown if the given subdirectory already exists.
trans— Transaction to use for the operationsubPath— Relative path of the subdirectory to create
TryListAsync
Task<List<FdbPath>> TryListAsync(IFdbReadOnlyTransaction trans, FdbPath subPath = null)
Returns the list of all the subdirectories of the current directory, if it exists.
trans— Transaction to use for the operationsubPath— Path of the directory to list
TryMoveAsync
Task<FdbDirectorySubspace> TryMoveAsync(IFdbTransaction trans, FdbPath oldPath, FdbPath newPath)
Attempts to move the specified subdirectory to newPath. There is no effect on the physical prefix of the given directory, or on clients that already have the directory open. An error is raised if a directory already exists at new_path.
trans— Transaction to use for the operationoldPath— Relative path under this directory of the subdirectory to be movednewPath— Relative path under this directory where the subdirectory will be moved to
Returns: Returns the directory at its new location if successful. If the directory doesn't exist, then null is returned.
TryMoveToAsync
Task<FdbDirectorySubspace> TryMoveToAsync(IFdbTransaction trans, FdbPath newAbsolutePath)
Attempts to move the current directory to newAbsolutePath. There is no effect on the physical prefix of the given directory, or on clients that already have the directory open. An error is raised if a directory already exists at new_path, or if the new path points to a child of the current directory.
trans— Transaction to use for the operationnewAbsolutePath— Full path (from the root) where this directory will be moved
Returns: Returns the directory at its new location if successful. If the directory doesn't exist, then null is returned.
TryOpenAsync
Task<FdbDirectorySubspace> TryOpenAsync(IFdbReadOnlyTransaction trans, FdbPath path)
Attempts to open the directory with the given path.
trans— Transaction to use for the operationpath— Relative path of the subdirectory to open
Returns: Returns the directory if it exists, or null if it was not found
TryOpenCachedAsync
ValueTask<FdbDirectorySubspace> TryOpenCachedAsync(IFdbReadOnlyTransaction trans, FdbPath path)
Attempts to open a subdirectory with the given path, using the partition's cache context.
Returns: Returns the directory if it exists, or null if it was not found
The instance returned MUST NOT be stored or kept outside the context of the transaction! You must call on every new transaction to obtain either the previously cached instance, or a new instance. Attempting to use a cached instance outside the transaction that produced it may throw exceptions!
ValueTask<FdbDirectorySubspace[]> TryOpenCachedAsync(IFdbReadOnlyTransaction trans, IEnumerable<FdbPath> paths)
Opens multiple subdirectories with the given paths, using the partition's cache context.
Returns: Returns the list directories, in the same order. If a directory does not exist, the corresponding slot will contain null
The instances returned MUST NOT be stored or kept outside the context of the transaction! You must call on every new transaction to obtain either the previously cached instances, or a new instances. Attempting to use a cached instances outside the transaction that produced them may throw exceptions!
TryRemoveAsync
Task<bool> TryRemoveAsync(IFdbTransaction trans, FdbPath subPath = null)
Attempts to remove the directory, its contents, and all subdirectories. Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
trans— Transaction to use for the operationsubPath— Path of the directory to remove. Will remove the current directory ifsubPathis empty