public class FileSwitchDirectory extends BaseDirectory
Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory. The provided Set must not change once passed to this class, and must allow multiple threads to call contains at once.
Directory.IndexInputSlicer| Constructor and Description |
|---|
FileSwitchDirectory(java.util.Set<java.lang.String> primaryExtensions,
Directory primaryDir,
Directory secondaryDir,
boolean doClose) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the store.
|
IndexOutput |
createOutput(java.lang.String name,
IOContext context)
Creates a new, empty file in the directory with the given name.
|
Directory.IndexInputSlicer |
createSlicer(java.lang.String name,
IOContext context)
Creates an
Directory.IndexInputSlicer for the given file name. |
void |
deleteFile(java.lang.String name)
Removes an existing file in the directory.
|
boolean |
fileExists(java.lang.String name)
Returns true iff a file with the given name exists.
|
long |
fileLength(java.lang.String name)
Returns the length of a file in the directory.
|
static java.lang.String |
getExtension(java.lang.String name)
Utility method to return a file's extension.
|
Directory |
getPrimaryDir()
Return the primary directory
|
Directory |
getSecondaryDir()
Return the secondary directory
|
java.lang.String[] |
listAll()
Returns an array of strings, one for each file in the directory.
|
IndexInput |
openInput(java.lang.String name,
IOContext context)
Returns a stream reading an existing file, with the
specified read buffer size.
|
void |
sync(java.util.Collection<java.lang.String> names)
Ensure that any writes to these files are moved to
stable storage.
|
clearLock, getLockFactory, makeLock, setLockFactorypublic Directory getPrimaryDir()
public Directory getSecondaryDir()
public void close()
throws java.io.IOException
Directorypublic java.lang.String[] listAll()
throws java.io.IOException
DirectorylistAll in class DirectoryNoSuchDirectoryException - if the directory is not prepared for any
write operations (such as Directory.createOutput(String, IOContext)).java.io.IOException - in case of other IO errorspublic static java.lang.String getExtension(java.lang.String name)
public boolean fileExists(java.lang.String name)
throws java.io.IOException
DirectoryfileExists in class Directoryjava.io.IOExceptionpublic void deleteFile(java.lang.String name)
throws java.io.IOException
DirectorydeleteFile in class Directoryjava.io.IOExceptionpublic long fileLength(java.lang.String name)
throws java.io.IOException
DirectoryFileNotFoundException if the file does not exist
(not java.nio.file.NoSuchFileException of Java 7).
fileLength in class Directoryname - the name of the file for which to return the length.java.io.IOException - if there was an IO error while retrieving the file's
length.public IndexOutput createOutput(java.lang.String name, IOContext context) throws java.io.IOException
DirectorycreateOutput in class Directoryjava.io.IOExceptionpublic void sync(java.util.Collection<java.lang.String> names)
throws java.io.IOException
Directorypublic IndexInput openInput(java.lang.String name, IOContext context) throws java.io.IOException
DirectoryFSDirectory and CompoundFileDirectory.
FileNotFoundException if the file does not exist
(not java.nio.file.NoSuchFileException of Java 7).public Directory.IndexInputSlicer createSlicer(java.lang.String name, IOContext context) throws java.io.IOException
DirectoryDirectory.IndexInputSlicer for the given file name.
IndexInputSlicer allows other Directory implementations to
efficiently open one or more sliced IndexInput instances from a
single file handle. The underlying file handle is kept open until the
Directory.IndexInputSlicer is closed.
FileNotFoundException if the file does not exist
(not java.nio.file.NoSuchFileException of Java 7).createSlicer in class Directoryjava.io.IOException - if an IOException occursCopyright © 2010 - 2024 Adobe. All Rights Reserved