FdbDirectorySubspace
Namespace: FoundationDB.Client · class
Implements: KeySubspace, IKeySubspace, ISpanEncodable, IEquatable<IKeySubspace>, IComparable<IKeySubspace>, ISpanFormattable, IFormattable, IFdbDirectory
A Directory Subspace represents the contents of a directory, but it also remembers the path with which it was opened and offers convenience methods to operate on the directory at that path.
Remarks
An instance of DirectorySubspace can be used for all the usual subspace operations. It can also be used to operate on the directory with which it was opened.
Properties
Cached
bool Cached { get; }
DirectoryLayer
FdbDirectoryLayer DirectoryLayer { get; }
Instance of the DirectoryLayer that was used to create or open 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 complete string representation of the path of this subspace.
IsPartition
bool IsPartition { get; }
Regular directory subspaces are not a partition.
Layer
string Layer { get; }
Layer id of this directory
Location
FdbDirectorySubspaceLocation Location { get; }
Gets the location that points to this Directory
Name
string Name { get; }
Name of the directory
Path
FdbPath Path { get; }
Absolute path of this directory, from the root 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 path)
Creates a subdirectory with the given path (creating intermediate subdirectories if necessary). An exception is thrown if the given subdirectory already exists.
trans— Transaction to use for the operationpath— Relative path of the subdirectory to create. It must include all the necessary layer ids (including the parents).
CreateOrOpenAsync
Task<FdbDirectorySubspace> CreateOrOpenAsync(IFdbTransaction trans, FdbPath path)
Opens a subdirectory with the given path. If the subdirectory does not exist, it is created (creating intermediate subdirectories if necessary).
trans— Transaction to use for the operationpath— Relative path of the subdirectory to create or open. It must include all the necessary layer ids (including the parents).
Returns: The corresponding directory subspace.
DumpKey
string DumpKey(Slice key, bool absolute = false)
Return a user-friendly representation of a key from this subspace
key— Key that is contained in this subspace
Returns: Printable version of this key, minus the subspace prefix
ExistsAsync
Task<bool> ExistsAsync(IFdbReadOnlyTransaction trans)
Checks if this directory exists
Returns: Returns true if the directory exists, otherwise false.
Task<bool> ExistsAsync(IFdbReadOnlyTransaction trans, FdbPath path)
Checks if a subdirectory exists
Returns: Returns true if the directory exists, otherwise false.
GetPath
FdbPath GetPath()
Returns the path of the subspace, if there is one.
Returns: Path of the subspace, or Empty if this subspace is not part of the Directory Layer
ListAsync
Task<List<FdbPath>> ListAsync(IFdbReadOnlyTransaction trans, FdbPath path = null)
Returns the list of all the subdirectories of a subdirectory.
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. It must include all the necessary layer ids (including the parents).
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 path, Slice prefix)
Registers an existing prefix as a directory with the given path (creating parent directories if necessary). This method is only indented for advanced use cases.
trans— Transaction to use for the operationpath— Path of the directory to create. It must include all the necessary layer ids (including the parents).prefix— The directory will be created with the given physical prefix; otherwise a prefix is allocated automatically.
RemoveAsync
Task RemoveAsync(IFdbTransaction trans)
Removes 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 operation
Task RemoveAsync(IFdbTransaction trans, FdbPath path)
Removes a subdirectory, 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 operationpath— Path of the subdirectory to remove (relative to this directory)
ToString
string ToString(string format, IFormatProvider provider = null)
Returns a user-friendly description of this directory
TryCreateAsync
Task<FdbDirectorySubspace> TryCreateAsync(IFdbTransaction trans, FdbPath path)
Creates a subdirectory with the given path (creating intermediate subdirectories if necessary).
trans— Transaction to use for the operationpath— Relative path of the subdirectory to create
Returns: Newly created directory subspace, or null if it already existed in the database.
TryFormat
bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider)
TryListAsync
Task<List<FdbPath>> TryListAsync(IFdbReadOnlyTransaction trans, FdbPath path = null)
Returns the list of all the subdirectories of the current directory, if it exists.
TryMoveToAsync
Task<FdbDirectorySubspace> TryMoveToAsync(IFdbTransaction trans, FdbPath newPath)
Attempts to move the current directory to newPath. There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
trans— Transaction to use for the operationnewPath— Full path (from the root) where this directory will be moved. It must include all the necessary layer ids (including the parents).
TryOpenAsync
Task<FdbDirectorySubspace> TryOpenAsync(IFdbReadOnlyTransaction trans, FdbPath path)
Opens a subdirectory with the given path. An exception is thrown if the subdirectory is 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
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)
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 operation
Task<bool> TryRemoveAsync(IFdbTransaction trans, FdbPath path)
Attempts to remove a subdirectory, 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 operationpath— Path of the subdirectory to remove (relative to this directory)