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, unpack
create, create, createOrOpen, exists, list, open, remove, removeIfExists
public java.lang.String toString()
Subspace
public boolean equals(java.lang.Object rhs)
DirectorySubspace
is equal to rhs
.
Two DirectorySubspace
s 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()
Directory
Directory
.public byte[] getLayer()
Directory
Directory
was created.public DirectoryLayer getDirectoryLayer()
Directory
DirectoryLayer
that was used to create this Directory
.getDirectoryLayer
in interface Directory
DirectoryLayer
that created this Directory
public java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
Directory
Directory
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 Directory
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
otherLayer
- 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 DirectorySubspace
public java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
Directory
Directory
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 Directory
tcx
- the ReadTransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
otherLayer
- a byte[]
specifying the expected layerCompletableFuture
which will be set to the opened DirectorySubspace
public java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer, byte[] prefix)
Directory
Directory
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 Directory
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
otherLayer
- 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 DirectorySubspace
public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
subpath
.
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if no directory exists at subpath
list
in interface Directory
tcx
- the ReadTransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
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)
Directory
Directory
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 oldSubpath
DirectoryAlreadyExistsException
- if a directory already exists at newSubpath
DirectoryMoveException
- if an invalid move location is specifiedmove
in interface Directory
tcx
- 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)
Directory
Directory
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 newAbsolutePath
DirectoryMoveException
- if an invalid move location is specifiedmoveTo
in interface Directory
tcx
- the TransactionContext
to execute this operation innewAbsolutePath
- a List<String>
specifying the new absolute path for this Directory
CompletableFuture
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)
Directory
Directory
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 subpath
remove
in interface Directory
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
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)
Directory
Directory
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 Directory
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
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)
Directory
Directory
located at subpath
exists.exists
in interface Directory
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to true
if the specified subdirectory exists, or false
if it
doesn't