public class DirectorySubspace extends Subspace implements Directory
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.
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<DirectorySubspace> |
create(TransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] otherLayer,
byte[] prefix)
Creates a subdirectory of this
Directory located at subpath
(creating parent directories if necessary). |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
createOrOpen(TransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] otherLayer)
Creates or opens the subdirectory of this
Directory located at subpath
(creating parent directories, if necessary). |
boolean |
equals(java.lang.Object rhs)
Returns whether this
DirectorySubspace is equal to rhs. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
exists(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath)
Checks if the subdirectory of this
Directory located at subpath exists. |
DirectoryLayer |
getDirectoryLayer()
Get the
DirectoryLayer that was used to create this Directory. |
byte[] |
getLayer()
Gets the layer byte string that was stored when this
Directory
was created. |
java.util.List<java.lang.String> |
getPath()
Gets the path represented by this
Directory. |
int |
hashCode()
Computes a hash code compatible with the
equals() method of
this class. |
java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> |
list(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath)
List the subdirectories of this directory at a given
subpath. |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
move(TransactionContext tcx,
java.util.List<java.lang.String> oldSubpath,
java.util.List<java.lang.String> newSubpath)
Moves the subdirectory of this
Directory located at oldSubpath to newSubpath. |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
moveTo(TransactionContext tcx,
java.util.List<java.lang.String> newAbsolutePath)
Moves this
Directory to the specified newAbsolutePath. |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
open(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] otherLayer)
Opens the subdirectory of this
Directory located at subpath. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
remove(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Removes the subdirectory of this
Directory located at subpath and all of its subdirectories,
as well as all of their contents. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
removeIfExists(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Removes the subdirectory of this
Directory located at subpath and all of its subdirectories,
as well as all of their contents. |
java.lang.String |
toString()
Create a human-readable string representation of this subspace.
|
contains, get, get, getKey, pack, pack, pack, packWithVersionstamp, range, range, subspace, unpackcreate, create, createOrOpen, exists, list, open, remove, removeIfExistspublic java.lang.String toString()
Subspacepublic boolean equals(java.lang.Object rhs)
DirectorySubspace is equal to rhs.
Two DirectorySubspaces are equal if they were created by the same
DirectoryLayer and have the same path, layer, and subspace prefix.public int hashCode()
equals() method of
this class. In particular, it will produce a hash code that is based off of the hashes
of its path, its layer, and its subspace prefix.public java.util.List<java.lang.String> getPath()
DirectoryDirectory.public byte[] getLayer()
DirectoryDirectory
was created.public DirectoryLayer getDirectoryLayer()
DirectoryDirectoryLayer that was used to create this Directory.getDirectoryLayer in interface DirectoryDirectoryLayer that created this Directorypublic java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
DirectoryDirectory located at subpath
(creating parent directories, if necessary). If the directory is new, then the layer
byte string will be recorded as its layer. If the directory already exists, the layer
byte string will be compared against the layer set when the directory was created.
The returned CompletableFuture can be set to the following errors:
MismatchedLayerException - if the directory has already been created with a different layer byte stringcreateOrOpen in interface Directorytcx - the TransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryotherLayer - a byte[] specifying a layer to set on a new directory or check for on an existing directoryCompletableFuture which will be set to the created or opened DirectorySubspacepublic java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
DirectoryDirectory located at subpath.
The layer byte string will be compared against the layer set when
the directory was created.
The returned CompletableFuture can be set to the following errors:
MismatchedLayerException - if the directory was created with a different layer byte stringNoSuchDirectoryException - if the directory does not existopen in interface Directorytcx - the ReadTransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryotherLayer - a byte[] specifying the expected layerCompletableFuture which will be set to the opened DirectorySubspacepublic java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer, byte[] prefix)
DirectoryDirectory located at subpath
(creating parent directories if necessary). The layer byte string will be recorded as
the new directory's layer and checked by future calls to Directory.open(ReadTransactionContext, List, byte[]).
The specified prefix will be used for this directory's contents instead of allocating a
prefix automatically.
The returned CompletableFuture can be set to the following errors:
DirectoryAlreadyExistsException - if the given directory already existscreate in interface Directorytcx - the TransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryotherLayer - a byte[] specifying a layer to set for the directoryprefix - a byte[] specifying the key prefix to use for the directory's contentsCompletableFuture which will be set to the created DirectorySubspacepublic java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Directorysubpath.
The returned CompletableFuture can be set to the following errors:
NoSuchDirectoryException - if no directory exists at subpathlist in interface Directorytcx - the ReadTransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryCompletableFuture which will be set to a List<String> of names of the subdirectories
of the directory at subpath. Each name is a unicode string representing the last component
of a subdirectory's path.public java.util.concurrent.CompletableFuture<DirectorySubspace> move(TransactionContext tcx, java.util.List<java.lang.String> oldSubpath, java.util.List<java.lang.String> newSubpath)
DirectoryDirectory located at oldSubpath to newSubpath.
There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
It is invalid to move a directory to:
The returned CompletableFuture can be set to the following errors:
NoSuchDirectoryException - if no Directory exists at oldSubpathDirectoryAlreadyExistsException - if a directory already exists at newSubpathDirectoryMoveException - if an invalid move location is specifiedmove in interface Directorytcx - the TransactionContext to execute this operation inoldSubpath - a List<String> specifying the subpath of the directory to movenewSubpath - a List<String> specifying the subpath to move toCompletableFuture which will be set to the DirectorySubspace for this Directory
at its new location.public java.util.concurrent.CompletableFuture<DirectorySubspace> moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)
DirectoryDirectory to the specified newAbsolutePath.
There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
It is invalid to move a directory to:
The returned CompletableFuture can be set to the following errors:
NoSuchDirectoryException - if this Directory doesn't existDirectoryAlreadyExistsException - if a directory already exists at newAbsolutePathDirectoryMoveException - if an invalid move location is specifiedmoveTo in interface Directorytcx - the TransactionContext to execute this operation innewAbsolutePath - a List<String> specifying the new absolute path for this DirectoryCompletableFuture which will be set to the DirectorySubspace for this Directory
at its new location.public java.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)
DirectoryDirectory located at subpath and all of its subdirectories,
as well as all of their contents.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
The returned CompletableFuture can be set to the following errors:
NoSuchDirectoryException - if no directory exists at subpathremove in interface Directorytcx - the TransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryCompletableFuture which will be set once the Directory has been removedpublic java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx, java.util.List<java.lang.String> subpath)
DirectoryDirectory located at subpath and all of its subdirectories,
as well as all of their contents.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
removeIfExists in interface Directorytcx - the TransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryCompletableFuture which will be set to true once the Directory has been removed,
or false if it didn't exist.public java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
DirectoryDirectory located at subpath exists.exists in interface Directorytcx - the TransactionContext to execute this operation insubpath - a List<String> specifying a subpath of this DirectoryCompletableFuture which will be set to true if the specified subdirectory exists, or false if it
doesn't