Class DirectorySubspace
- java.lang.Object
-
- com.apple.foundationdb.subspace.Subspace
-
- com.apple.foundationdb.directory.DirectorySubspace
-
- All Implemented Interfaces:
Directory
public class DirectorySubspace extends Subspace implements Directory
A DirectorySubspace 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.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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<DirectorySubspace>create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer, byte[] prefix)Creates a subdirectory of thisDirectorylocated atsubpath(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 thisDirectorylocated atsubpath(creating parent directories, if necessary).booleanequals(java.lang.Object rhs)Returns whether thisDirectorySubspaceis equal torhs.java.util.concurrent.CompletableFuture<java.lang.Boolean>exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)Checks if the subdirectory of thisDirectorylocated atsubpathexists.DirectoryLayergetDirectoryLayer()Get theDirectoryLayerthat was used to create thisDirectory.byte[]getLayer()Gets the layer byte string that was stored when thisDirectorywas created.java.util.List<java.lang.String>getPath()Gets the path represented by thisDirectory.inthashCode()Computes a hash code compatible with theequals()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 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 thisDirectorylocated atoldSubpathtonewSubpath.java.util.concurrent.CompletableFuture<DirectorySubspace>moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)Moves thisDirectoryto the specifiednewAbsolutePath.java.util.concurrent.CompletableFuture<DirectorySubspace>open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)Opens the subdirectory of thisDirectorylocated atsubpath.java.util.concurrent.CompletableFuture<java.lang.Void>remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)Removes the subdirectory of thisDirectorylocated atsubpathand 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 thisDirectorylocated atsubpathand all of its subdirectories, as well as all of their contents.java.lang.StringtoString()Create a human-readable string representation of this subspace.-
Methods inherited from class com.apple.foundationdb.subspace.Subspace
contains, get, get, getKey, pack, pack, pack, packWithVersionstamp, range, range, subspace, unpack
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.directory.Directory
create, create, createOrOpen, exists, list, open, remove, removeIfExists
-
-
-
-
Method Detail
-
toString
public java.lang.String toString()
Description copied from class:SubspaceCreate a human-readable string representation of this subspace. This is really only useful for debugging purposes, but it includes information on what raw prefix the subspace is using.
-
equals
public boolean equals(java.lang.Object rhs)
Returns whether thisDirectorySubspaceis equal torhs. TwoDirectorySubspaces are equal if they were created by the sameDirectoryLayerand have the same path, layer, and subspace prefix.
-
hashCode
public int hashCode()
Computes a hash code compatible with theequals()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.
-
getPath
public java.util.List<java.lang.String> getPath()
Description copied from interface:DirectoryGets the path represented by thisDirectory.
-
getLayer
public byte[] getLayer()
Description copied from interface:DirectoryGets the layer byte string that was stored when thisDirectorywas created.
-
getDirectoryLayer
public DirectoryLayer getDirectoryLayer()
Description copied from interface:DirectoryGet theDirectoryLayerthat was used to create thisDirectory.- Specified by:
getDirectoryLayerin interfaceDirectory- Returns:
- the
DirectoryLayerthat created thisDirectory
-
createOrOpen
public java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
Description copied from interface:DirectoryCreates or opens the subdirectory of thisDirectorylocated atsubpath(creating parent directories, if necessary). If the directory is new, then thelayerbyte string will be recorded as its layer. If the directory already exists, thelayerbyte string will be compared against thelayerset when the directory was created.The returned
CompletableFuturecan be set to the following errors:MismatchedLayerException- if the directory has already been created with a differentlayerbyte string
- Specified by:
createOrOpenin interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectoryotherLayer- abyte[]specifying a layer to set on a new directory or check for on an existing directory- Returns:
- a
CompletableFuturewhich will be set to the created or openedDirectorySubspace
-
open
public java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer)
Description copied from interface:DirectoryOpens the subdirectory of thisDirectorylocated atsubpath. Thelayerbyte string will be compared against thelayerset when the directory was created.The returned
CompletableFuturecan be set to the following errors:MismatchedLayerException- if the directory was created with a differentlayerbyte stringNoSuchDirectoryException- if the directory does not exist
- Specified by:
openin interfaceDirectory- Parameters:
tcx- theReadTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectoryotherLayer- abyte[]specifying the expected layer- Returns:
- a
CompletableFuturewhich will be set to the openedDirectorySubspace
-
create
public java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] otherLayer, byte[] prefix)
Description copied from interface:DirectoryCreates a subdirectory of thisDirectorylocated atsubpath(creating parent directories if necessary). Thelayerbyte string will be recorded as the new directory's layer and checked by future calls toDirectory.open(ReadTransactionContext, List, byte[]). The specifiedprefixwill be used for this directory's contents instead of allocating a prefix automatically.The returned
CompletableFuturecan be set to the following errors:DirectoryAlreadyExistsException- if the given directory already exists
- Specified by:
createin interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectoryotherLayer- abyte[]specifying a layer to set for the directoryprefix- abyte[]specifying the key prefix to use for the directory's contents- Returns:
- a
CompletableFuturewhich will be set to the createdDirectorySubspace
-
list
public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Description copied from interface:DirectoryList the subdirectories of this directory at a givensubpath.The returned
CompletableFuturecan be set to the following errors:NoSuchDirectoryException- if no directory exists atsubpath
- Specified by:
listin interfaceDirectory- Parameters:
tcx- theReadTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectory- Returns:
- a
CompletableFuturewhich 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.
-
move
public java.util.concurrent.CompletableFuture<DirectorySubspace> move(TransactionContext tcx, java.util.List<java.lang.String> oldSubpath, java.util.List<java.lang.String> newSubpath)
Description copied from interface:DirectoryMoves the subdirectory of thisDirectorylocated atoldSubpathtonewSubpath.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
CompletableFuturecan be set to the following errors:NoSuchDirectoryException- if noDirectoryexists atoldSubpathDirectoryAlreadyExistsException- if a directory already exists atnewSubpathDirectoryMoveException- if an invalid move location is specified
- Specified by:
movein interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation inoldSubpath- aList<String>specifying the subpath of the directory to movenewSubpath- aList<String>specifying the subpath to move to- Returns:
- a
CompletableFuturewhich will be set to theDirectorySubspacefor thisDirectoryat its new location.
-
moveTo
public java.util.concurrent.CompletableFuture<DirectorySubspace> moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)
Description copied from interface:DirectoryMoves thisDirectoryto 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
CompletableFuturecan be set to the following errors:NoSuchDirectoryException- if thisDirectorydoesn't existDirectoryAlreadyExistsException- if a directory already exists atnewAbsolutePathDirectoryMoveException- if an invalid move location is specified
- Specified by:
moveToin interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation innewAbsolutePath- aList<String>specifying the new absolute path for thisDirectory- Returns:
- a
CompletableFuturewhich will be set to theDirectorySubspacefor thisDirectoryat its new location.
-
remove
public java.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Description copied from interface:DirectoryRemoves the subdirectory of thisDirectorylocated atsubpathand 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
CompletableFuturecan be set to the following errors:NoSuchDirectoryException- if no directory exists atsubpath
- Specified by:
removein interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectory- Returns:
- a
CompletableFuturewhich will be set once theDirectoryhas been removed
-
removeIfExists
public java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Description copied from interface:DirectoryRemoves the subdirectory of thisDirectorylocated atsubpathand 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.
- Specified by:
removeIfExistsin interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectory- Returns:
- a
CompletableFuturewhich will be set to true once theDirectoryhas been removed, or false if it didn't exist.
-
exists
public java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Description copied from interface:DirectoryChecks if the subdirectory of thisDirectorylocated atsubpathexists.- Specified by:
existsin interfaceDirectory- Parameters:
tcx- theTransactionContextto execute this operation insubpath- aList<String>specifying a subpath of thisDirectory- Returns:
- a
CompletableFuturewhich will be set totrueif the specified subdirectory exists, orfalseif it doesn't
-
-