Package org.apache.lucene.store
Class FilterDirectory
java.lang.Object
org.apache.lucene.store.Directory
org.apache.lucene.store.FilterDirectory
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
RateLimitedDirectoryWrapper,TrackingDirectoryWrapper
Directory implementation that delegates calls to another directory.
This class can be used to add limitations on top of an existing
Directory implementation such as
rate limiting or to add additional
sanity checks for tests. However, if you plan to write your own
Directory implementation, you should consider extending directly
Directory or BaseDirectory rather than try to reuse
functionality of existing Directorys by extending this class.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.store.Directory
Directory.IndexInputSlicer -
Method Summary
Modifier and TypeMethodDescriptionvoidAttempt to clear (forcefully unlock and remove) the specified lock.voidclose()Closes the store.createOutput(String name, IOContext context) Creates a new, empty file in the directory with the given name.voiddeleteFile(String name) Removes an existing file in the directory.booleanfileExists(String name) Returns true iff a file with the given name exists.longfileLength(String name) Returns the length of a file in the directory.final DirectoryReturn the wrappedDirectory.Get the LockFactory that this Directory instance is using for its locking implementation.Return a string identifier that uniquely differentiates this Directory instance from other Directory instances.String[]listAll()Returns an array of strings, one for each file in the directory.Construct aLock.Returns a stream reading an existing file, with the specified read buffer size.voidsetLockFactory(LockFactory lockFactory) Set the LockFactory that this Directory instance should use for its locking implementation.voidsync(Collection<String> names) Ensure that any writes to these files are moved to stable storage.toString()Methods inherited from class org.apache.lucene.store.Directory
copy, createSlicer
-
Method Details
-
getDelegate
Return the wrappedDirectory. -
listAll
Description copied from class:DirectoryReturns an array of strings, one for each file in the directory.- Specified by:
listAllin classDirectory- Throws:
IOException- in case of other IO errors
-
fileExists
Description copied from class:DirectoryReturns true iff a file with the given name exists.- Specified by:
fileExistsin classDirectory- Throws:
IOException
-
deleteFile
Description copied from class:DirectoryRemoves an existing file in the directory.- Specified by:
deleteFilein classDirectory- Throws:
IOException
-
fileLength
Description copied from class:DirectoryReturns the length of a file in the directory. This method follows the following contract:- Must throw
FileNotFoundExceptionif the file does not exist (notjava.nio.file.NoSuchFileExceptionof Java 7). - Returns a value ≥0 if the file exists, which specifies its length.
- Specified by:
fileLengthin classDirectory- Parameters:
name- the name of the file for which to return the length.- Throws:
IOException- if there was an IO error while retrieving the file's length.
- Must throw
-
createOutput
Description copied from class:DirectoryCreates a new, empty file in the directory with the given name. Returns a stream writing this file.- Specified by:
createOutputin classDirectory- Throws:
IOException
-
sync
Description copied from class:DirectoryEnsure that any writes to these files are moved to stable storage. Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.
NOTE: Clients may call this method for same files over and over again, so some impls might optimize for that. For other impls the operation can be a noop, for various reasons.- Specified by:
syncin classDirectory- Throws:
IOException
-
openInput
Description copied from class:DirectoryReturns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. Currently the only Directory implementations that respect this parameter areFSDirectoryandCompoundFileDirectory.- Must throw
FileNotFoundExceptionif the file does not exist (notjava.nio.file.NoSuchFileExceptionof Java 7).- Specified by:
openInputin classDirectory- Throws:
IOException
- Must throw
-
makeLock
Description copied from class:DirectoryConstruct aLock. -
clearLock
Description copied from class:DirectoryAttempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.- Specified by:
clearLockin classDirectory- Parameters:
name- name of the lock to be cleared.- Throws:
IOException
-
close
Description copied from class:DirectoryCloses the store.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classDirectory- Throws:
IOException
-
setLockFactory
Description copied from class:DirectorySet the LockFactory that this Directory instance should use for its locking implementation. Each * instance of LockFactory should only be used for one directory (ie, do not share a single instance across multiple Directories).- Specified by:
setLockFactoryin classDirectory- Parameters:
lockFactory- instance ofLockFactory.- Throws:
IOException
-
getLockID
Description copied from class:DirectoryReturn a string identifier that uniquely differentiates this Directory instance from other Directory instances. This ID should be the same if two Directory instances (even in different JVMs and/or on different machines) are considered "the same index". This is how locking "scopes" to the right index. -
getLockFactory
Description copied from class:DirectoryGet the LockFactory that this Directory instance is using for its locking implementation. Note that this may be null for Directory implementations that provide their own locking implementation.- Specified by:
getLockFactoryin classDirectory
-
toString
-