Interface Directory
-
- All Known Implementing Classes:
DirectoryLayer
,DirectorySubspace
public interface Directory
Represents a directory in theDirectoryLayer
. ADirectory
stores the path at which it is located and the layer that was used to create it. TheDirectory
interface contains methods to operate on itself and its subdirectories.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.concurrent.CompletableFuture<DirectorySubspace>
create(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary).default java.util.concurrent.CompletableFuture<DirectorySubspace>
create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary).java.util.concurrent.CompletableFuture<DirectorySubspace>
create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer, byte[] prefix)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary).default java.util.concurrent.CompletableFuture<DirectorySubspace>
createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Creates or opens the subdirectory of thisDirectory
located atsubpath
(creating parent directories, if necessary).java.util.concurrent.CompletableFuture<DirectorySubspace>
createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Creates or opens the subdirectory of thisDirectory
located atsubpath
(creating parent directories, if necessary).default java.util.concurrent.CompletableFuture<java.lang.Boolean>
exists(ReadTransactionContext tcx)
Checks if thisDirectory
exists.java.util.concurrent.CompletableFuture<java.lang.Boolean>
exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Checks if the subdirectory of thisDirectory
located atsubpath
exists.DirectoryLayer
getDirectoryLayer()
Get theDirectoryLayer
that was used to create thisDirectory
.byte[]
getLayer()
Gets the layer byte string that was stored when thisDirectory
was created.java.util.List<java.lang.String>
getPath()
Gets the path represented by thisDirectory
.default java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>>
list(ReadTransactionContext tcx)
List the subdirectories of this directory.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 givensubpath
.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 thisDirectory
located atoldSubpath
tonewSubpath
.java.util.concurrent.CompletableFuture<DirectorySubspace>
moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)
Moves thisDirectory
to the specifiednewAbsolutePath
.default java.util.concurrent.CompletableFuture<DirectorySubspace>
open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Opens the subdirectory of thisDirectory
located atsubpath
.java.util.concurrent.CompletableFuture<DirectorySubspace>
open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Opens the subdirectory of thisDirectory
located atsubpath
.default java.util.concurrent.CompletableFuture<java.lang.Void>
remove(TransactionContext tcx)
Removes thisDirectory
and all of its subdirectories, as well as all of their contents.java.util.concurrent.CompletableFuture<java.lang.Void>
remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Removes the subdirectory of thisDirectory
located atsubpath
and all of its subdirectories, as well as all of their contents.default java.util.concurrent.CompletableFuture<java.lang.Boolean>
removeIfExists(TransactionContext tcx)
Removes thisDirectory
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 thisDirectory
located atsubpath
and all of its subdirectories, as well as all of their contents.
-
-
-
Method Detail
-
getPath
java.util.List<java.lang.String> getPath()
Gets the path represented by thisDirectory
.- Returns:
- this
Directory
's path
-
getLayer
byte[] getLayer()
Gets the layer byte string that was stored when thisDirectory
was created.- Returns:
- this
Directory
's layer byte string
-
getDirectoryLayer
DirectoryLayer getDirectoryLayer()
Get theDirectoryLayer
that was used to create thisDirectory
.- Returns:
- the
DirectoryLayer
that created thisDirectory
-
createOrOpen
default java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Creates or opens the subdirectory of thisDirectory
located atsubpath
(creating parent directories, if necessary).- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set to the created or openedDirectorySubspace
-
createOrOpen
java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Creates or opens the subdirectory of thisDirectory
located atsubpath
(creating parent directories, if necessary). If the directory is new, then thelayer
byte string will be recorded as its layer. If the directory already exists, thelayer
byte string will be compared against thelayer
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 differentlayer
byte string
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
layer
- abyte[]
specifying a layer to set on a new directory or check for on an existing directory- Returns:
- a
CompletableFuture
which will be set to the created or openedDirectorySubspace
-
open
default java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Opens the subdirectory of thisDirectory
located atsubpath
.The returned
CompletableFuture
can be set to the following errors:NoSuchDirectoryException
- if the directory does not exist
- Parameters:
tcx
- theReadTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set to the openedDirectorySubspace
-
open
java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Opens the subdirectory of thisDirectory
located atsubpath
. Thelayer
byte string will be compared against thelayer
set when the directory was created.The returned
CompletableFuture
can be set to the following errors:MismatchedLayerException
- if the directory was created with a differentlayer
byte stringNoSuchDirectoryException
- if the directory does not exist
- Parameters:
tcx
- theReadTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
layer
- abyte[]
specifying the expected layer- Returns:
- a
CompletableFuture
which will be set to the openedDirectorySubspace
-
create
default java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary).The returned
CompletableFuture
can be set to the following errors:DirectoryAlreadyExistsException
- if the given directory already exists
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set to the createdDirectorySubspace
-
create
default java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary). Thelayer
byte string will be recorded as the new directory's layer and checked by future calls toopen(ReadTransactionContext, List, byte[])
.The returned
CompletableFuture
can be set to the following errors:DirectoryAlreadyExistsException
- if the given directory already exists
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
layer
- abyte[]
specifying a layer to set for the directory- Returns:
- a
CompletableFuture
which will be set to the createdDirectorySubspace
-
create
java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer, byte[] prefix)
Creates a subdirectory of thisDirectory
located atsubpath
(creating parent directories if necessary). Thelayer
byte string will be recorded as the new directory's layer and checked by future calls toopen(ReadTransactionContext, List, byte[])
. The specifiedprefix
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 exists
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
layer
- abyte[]
specifying a layer to set for the directoryprefix
- abyte[]
specifying the key prefix to use for the directory's contents- Returns:
- a
CompletableFuture
which will be set to the createdDirectorySubspace
-
moveTo
java.util.concurrent.CompletableFuture<DirectorySubspace> moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)
Moves thisDirectory
to the specifiednewAbsolutePath
.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:
- A location where a directory already exists
- A location whose parent does not exist
- A subdirectory of itself
- A different partition
The returned
CompletableFuture
can be set to the following errors:NoSuchDirectoryException
- if thisDirectory
doesn't existDirectoryAlreadyExistsException
- if a directory already exists atnewAbsolutePath
DirectoryMoveException
- if an invalid move location is specified
- Parameters:
tcx
- theTransactionContext
to execute this operation innewAbsolutePath
- aList<String>
specifying the new absolute path for thisDirectory
- Returns:
- a
CompletableFuture
which will be set to theDirectorySubspace
for thisDirectory
at its new location.
-
move
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 thisDirectory
located atoldSubpath
tonewSubpath
.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:
- A location where a directory already exists
- A location whose parent does not exist
- A subdirectory of itself
- A different partition
The returned
CompletableFuture
can be set to the following errors:NoSuchDirectoryException
- if noDirectory
exists atoldSubpath
DirectoryAlreadyExistsException
- if a directory already exists atnewSubpath
DirectoryMoveException
- if an invalid move location is specified
- Parameters:
tcx
- theTransactionContext
to execute this operation inoldSubpath
- aList<String>
specifying the subpath of the directory to movenewSubpath
- aList<String>
specifying the subpath to move to- Returns:
- a
CompletableFuture
which will be set to theDirectorySubspace
for thisDirectory
at its new location.
-
remove
default java.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx)
Removes thisDirectory
and all of its subdirectories, as well as all of their contents. This should not be called on the root directory, or it will result in the returned future being set to aDirectoryException
.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 thisDirectory
doesn't existDirectoryException
- if this is called on the root directory
- Parameters:
tcx
- theTransactionContext
to execute this operation in- Returns:
- a
CompletableFuture
which will be set once thisDirectory
has been removed
-
remove
java.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Removes the subdirectory of thisDirectory
located atsubpath
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 atsubpath
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set once theDirectory
has been removed
-
removeIfExists
default java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx)
Removes thisDirectory
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.
- Parameters:
tcx
- theTransactionContext
to execute this operation in- Returns:
- a
CompletableFuture
which will be set to true once thisDirectory
has been removed, or false if it didn't exist.
-
removeIfExists
java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Removes the subdirectory of thisDirectory
located atsubpath
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.
- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set to true once theDirectory
has been removed, or false if it didn't exist.
-
list
default java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx)
List the subdirectories of this directory.The returned
CompletableFuture
can be set to the following errors:NoSuchDirectoryException
- if thisDirectory
doesn't exists
- Parameters:
tcx
- theReadTransactionContext
to execute this operation in- Returns:
- a
CompletableFuture
which will be set to aList<String>
of names of the subdirectories of thisDirectory
. Each name is a unicode string representing the last component of a subdirectory's path.
-
list
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 givensubpath
.The returned
CompletableFuture
can be set to the following errors:NoSuchDirectoryException
- if no directory exists atsubpath
- Parameters:
tcx
- theReadTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set to aList<String>
of names of the subdirectories of the directory atsubpath
. Each name is a unicode string representing the last component of a subdirectory's path.
-
exists
default java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx)
Checks if thisDirectory
exists.- Parameters:
tcx
- theReadTransactionContext
to execute this operation in- Returns:
- a
CompletableFuture
which will be set totrue
if thisDirectory
exists, orfalse
if it doesn't
-
exists
java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Checks if the subdirectory of thisDirectory
located atsubpath
exists.- Parameters:
tcx
- theTransactionContext
to execute this operation insubpath
- aList<String>
specifying a subpath of thisDirectory
- Returns:
- a
CompletableFuture
which will be set totrue
if the specified subdirectory exists, orfalse
if it doesn't
-
-