public class FSDirectory extends Directory
Directory as a directory of files.
Locking implementation is by default the SimpleFSLockFactory, but
can be changed either by passing in a LockFactory instance to
getDirectory, or specifying the LockFactory class by setting
org.apache.lucene.store.FSDirectoryLockFactoryClass Java system
property, or by calling Directory.setLockFactory(org.apache.lucene.store.LockFactory) after creating
the Directory.
Directories are cached, so that, for a given canonical
path, the same FSDirectory instance will always be
returned by getDirectory. This permits
synchronization on directories.
Directory| Modifier and Type | Class and Description |
|---|---|
protected static class |
FSDirectory.FSIndexInput |
protected static class |
FSDirectory.FSIndexOutput |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
LOCK_DIR
Deprecated.
As of 2.1,
LOCK_DIR is unused
because the write.lock is now stored by default in the
index directory. If you really want to store locks
elsewhere you can create your own SimpleFSLockFactory (or NativeFSLockFactory,
etc.) passing in your preferred lock directory. Then,
pass this LockFactory instance to one of
the getDirectory methods that take a
lockFactory (for example, getDirectory(String, LockFactory)). |
lockFactory| Modifier | Constructor and Description |
|---|---|
protected |
FSDirectory() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the store to future operations.
|
IndexOutput |
createOutput(java.lang.String name)
Creates a new, empty file in the directory with the given 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 in bytes of a file in the directory.
|
static long |
fileModified(java.io.File directory,
java.lang.String name)
Returns the time the named file was last modified.
|
long |
fileModified(java.lang.String name)
Returns the time the named file was last modified.
|
static FSDirectory |
getDirectory(java.io.File file)
Returns the directory instance for the named location.
|
static FSDirectory |
getDirectory(java.io.File file,
boolean create)
Deprecated.
Use IndexWriter's create flag, instead, to
create a new index.
|
static FSDirectory |
getDirectory(java.io.File file,
LockFactory lockFactory)
Returns the directory instance for the named location.
|
static FSDirectory |
getDirectory(java.lang.String path)
Returns the directory instance for the named location.
|
static FSDirectory |
getDirectory(java.lang.String path,
boolean create)
Deprecated.
Use IndexWriter's create flag, instead, to
create a new index.
|
static FSDirectory |
getDirectory(java.lang.String path,
LockFactory lockFactory)
Returns the directory instance for the named location.
|
static boolean |
getDisableLocks()
Returns whether Lucene's use of lock files is disabled.
|
java.io.File |
getFile() |
java.lang.String |
getLockID()
Return a string identifier that uniquely differentiates
this Directory instance from other Directory instances.
|
java.lang.String[] |
list()
Returns an array of strings, one for each Lucene index file in the directory.
|
IndexInput |
openInput(java.lang.String name)
Returns a stream reading an existing file.
|
IndexInput |
openInput(java.lang.String name,
int bufferSize)
Returns a stream reading an existing file, with the
specified read buffer size.
|
void |
renameFile(java.lang.String from,
java.lang.String to)
Deprecated.
|
static void |
setDisableLocks(boolean doDisableLocks)
Set whether Lucene's use of lock files is disabled.
|
void |
sync(java.lang.String name)
Ensure that any writes to this file are moved to
stable storage.
|
java.lang.String |
toString()
For debug output.
|
void |
touchFile(java.lang.String name)
Set the modified time of an existing file to now.
|
clearLock, copy, ensureOpen, getLockFactory, makeLock, setLockFactorypublic static final java.lang.String LOCK_DIR
LOCK_DIR is unused
because the write.lock is now stored by default in the
index directory. If you really want to store locks
elsewhere you can create your own SimpleFSLockFactory (or NativeFSLockFactory,
etc.) passing in your preferred lock directory. Then,
pass this LockFactory instance to one of
the getDirectory methods that take a
lockFactory (for example, getDirectory(String, LockFactory)).org.apache.lucene.lockDir
or java.io.tmpdir system property.public static void setDisableLocks(boolean doDisableLocks)
public static boolean getDisableLocks()
public static FSDirectory getDirectory(java.lang.String path) throws java.io.IOException
path - the path to the directory.java.io.IOExceptionpublic static FSDirectory getDirectory(java.lang.String path, LockFactory lockFactory) throws java.io.IOException
path - the path to the directory.lockFactory - instance of LockFactory providing the
locking implementation.java.io.IOExceptionpublic static FSDirectory getDirectory(java.io.File file) throws java.io.IOException
file - the path to the directory.java.io.IOExceptionpublic static FSDirectory getDirectory(java.io.File file, LockFactory lockFactory) throws java.io.IOException
file - the path to the directory.lockFactory - instance of LockFactory providing the
locking implementation.java.io.IOExceptionpublic static FSDirectory getDirectory(java.lang.String path, boolean create) throws java.io.IOException
path - the path to the directory.create - if true, create, or erase any existing contents.java.io.IOExceptionpublic static FSDirectory getDirectory(java.io.File file, boolean create) throws java.io.IOException
file - the path to the directory.create - if true, create, or erase any existing contents.java.io.IOExceptionpublic java.lang.String[] list()
public boolean fileExists(java.lang.String name)
fileExists in class Directorypublic long fileModified(java.lang.String name)
fileModified in class Directorypublic static long fileModified(java.io.File directory,
java.lang.String name)
public void touchFile(java.lang.String name)
public long fileLength(java.lang.String name)
fileLength in class Directorypublic void deleteFile(java.lang.String name)
throws java.io.IOException
deleteFile in class Directoryjava.io.IOExceptionpublic void renameFile(java.lang.String from,
java.lang.String to)
throws java.io.IOException
renameFile in class Directoryjava.io.IOExceptionpublic IndexOutput createOutput(java.lang.String name) throws java.io.IOException
createOutput in class Directoryjava.io.IOExceptionpublic void sync(java.lang.String name)
throws java.io.IOException
Directorypublic IndexInput openInput(java.lang.String name) throws java.io.IOException
Directorypublic IndexInput openInput(java.lang.String name, int bufferSize) throws java.io.IOException
DirectoryFSDirectory and CompoundFileReader.public java.lang.String getLockID()
Directorypublic void close()
public java.io.File getFile()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.