FdbDirectorySubspaceLocation
Namespace: FoundationDB.Client · class
Implements: ISubspaceLocation<FdbDirectorySubspace>, ISubspaceLocation, IEquatable<ISubspaceLocation>, IFdbDirectory, IFdbLayer<FdbDirectorySubspace, FdbDirectoryLayer>, IFdbLayer
Constructors
FdbDirectorySubspaceLocation
FdbDirectorySubspaceLocation(FdbPath path)
Creates a new location that points to the Directory Subspace at the given path.
path— Absolute path of the target Directory Subspace
Properties
IsPartition
bool IsPartition { get; }
Returns true if this location points to a directory partition.
Item
FdbDirectorySubspaceLocation Item { get; }
FdbDirectorySubspaceLocation Item { get; }
FdbDirectorySubspaceLocation Item { get; }
FdbDirectorySubspaceLocation Item { get; }
FdbDirectorySubspaceLocation Item { get; }
Layer
string Layer { get; }
Gets the layer id that was stored when this Directory was created.
Path
FdbPath Path { get; }
Path of the directory subspace that contains the subspace.
This path is always absolute. Relative paths are not allowed. Can be if this subspace is located at the root of the database (ie: not using the Directory Layer)
Methods
CreateAsync
Task<FdbDirectorySubspace> CreateAsync(IFdbTransaction trans, FdbPath subPath = null)
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 = null)
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.
Equals
bool Equals(object obj)
bool Equals(ISubspaceLocation other)
ExistsAsync
Task<bool> ExistsAsync(IFdbReadOnlyTransaction trans, FdbPath path = null)
Checks if this directory exists
trans— Transaction to use for the operation
Returns: Returns true if the directory exists, otherwise false.
GetHashCode
int GetHashCode()
ListAsync
Task<List<FdbPath>> ListAsync(IFdbReadOnlyTransaction trans, FdbPath path = null)
Returns the list of all the subdirectories of the current directory.
trans— Transaction to use for the operation
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 = null)
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
RemoveAsync
Task RemoveAsync(IFdbTransaction trans, FdbPath path = 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 operation
Resolve
ValueTask<FdbDirectorySubspace> Resolve(IFdbReadOnlyTransaction tr, FdbDirectoryLayer directory = null)
Returns the actual subspace that corresponds to this location, or throws if it does not exist.
tr— Current transactiondirectory— DirectoryLayer instance to use for the resolve. If null, uses the default database directory layer.
Returns: Key subspace using the resolved key prefix of this location in the context of the current transaction
The instance resolved for this transaction SHOULD NOT be used in the context of a different transaction, because its location in the Directory Layer may have been changed concurrently!
Re-using cached subspace instances MAY lead to DATA CORRUPTION if not used carefully! The best practice is to call Resolve() every time it is needed by a new transaction.
ResolveOrCreate
ValueTask<FdbDirectorySubspace> ResolveOrCreate(IFdbTransaction tr, FdbDirectoryLayer directory = null)
Returns the actual subspace that corresponds to this location, or create it if it does not exist.
This should only be called by infrastructure code that needs to initialize the database or perform maintenance operation.
Regular business logic should mostly call TryResolve or Resolve and not attempt to initialize the database by themselves!
ToString
string ToString()
TryCreateAsync
Task<FdbDirectorySubspace> TryCreateAsync(IFdbTransaction trans, FdbPath subPath = null)
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 path = null)
Returns the list of all the subdirectories of the current directory, if it exists.
trans— Transaction to use for the operation
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 = null)
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 = null)
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 path = 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 operation
TryResolve
ValueTask<FdbDirectorySubspace> TryResolve(IFdbReadOnlyTransaction tr, FdbDirectoryLayer directory = null)
Returns the actual subspace that corresponds to this location, if it exists.
tr— Current transactiondirectory— DirectoryLayer instance to use for the resolve. If null, uses the default database directory layer.
Returns: Key subspace using the resolved key prefix of this location in the context of the current transaction, or null if the directory does not exist
The instance resolved for this transaction SHOULD NOT be used in the context of a different transaction, because its location in the Directory Layer may have been changed concurrently!
Re-using cached subspace instances MAY lead to DATA CORRUPTION if not used carefully! The best practice is to call TryResolve() every time it is needed by a new transaction.
WithLayer
FdbDirectorySubspaceLocation WithLayer(string layerId)
Returns the same location, but with an explicit Layer identifier
layerId— Layer Identifier to use for this location
This can be used to force a specific LayerId, or to add one if it is missing