Lucene++ - a full-featured, c++ search engine
API Documentation
File-based Directory
implementation that uses mmap for reading, and SimpleFSIndexOutput
for writing.
More...
#include <MMapDirectory.h>
Public Member Functions | |
MMapDirectory (const String &path, const LockFactoryPtr &lockFactory=LockFactoryPtr()) | |
Create a new MMapDirectory for the named location. | |
virtual | ~MMapDirectory () |
virtual String | getClassName () |
boost::shared_ptr< MMapDirectory > | shared_from_this () |
virtual IndexInputPtr | openInput (const String &name, int32_t bufferSize) |
Creates an IndexInput for the file with the given name. | |
virtual IndexOutputPtr | createOutput (const String &name) |
Creates an IndexOutput for the file with the given name. | |
virtual IndexInputPtr | openInput (const String &name) |
Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. | |
virtual IndexInputPtr | openInput (const String &name, int32_t bufferSize) |
Returns 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 are FSDirectory and CompoundFileReader . | |
![]() | |
virtual | ~FSDirectory () |
boost::shared_ptr< FSDirectory > | shared_from_this () |
void | createDir () |
Create file system directory. | |
String | getFile () |
Return file system directory. | |
void | setReadChunkSize (int32_t chunkSize) |
Sets the maximum number of bytes read at once from the underlying file during IndexInput#readBytes . The default value is DEFAULT_READ_CHUNK_SIZE . Changes to this value will not impact any already-opened IndexInput s. You should call this before attempting to open an index on the directory. This value should be as large as possible to reduce any possible performance impact. | |
int32_t | getReadChunkSize () |
The maximum number of bytes to read at once from the underlying file during IndexInput#readBytes . | |
virtual HashSet< String > | listAll () |
Lists all files (not subdirectories) in the directory. | |
virtual bool | fileExists (const String &name) |
Returns true if a file with the given name exists. | |
virtual uint64_t | fileModified (const String &name) |
Returns the time the named file was last modified. | |
virtual void | touchFile (const String &name) |
Set the modified time of an existing file to now. | |
virtual void | deleteFile (const String &name) |
Removes an existing file in the directory. | |
virtual int64_t | fileLength (const String &name) |
Returns the length in bytes of a file in the directory. | |
virtual void | sync (const String &name) |
Ensure that any writes to this file 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. | |
virtual String | getLockID () |
Return a string identifier that uniquely differentiates this Directory instance from other Directory instances. | |
virtual void | close () |
Closes the store to future operations. | |
virtual String | toString () |
For debug output. | |
![]() | |
Directory () | |
virtual | ~Directory () |
boost::shared_ptr< Directory > | shared_from_this () |
virtual LockPtr | makeLock (const String &name) |
Construct a Lock . | |
void | clearLock (const String &name) |
Attempt 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. | |
void | setLockFactory (const LockFactoryPtr &lockFactory) |
Set 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). | |
LockFactoryPtr | getLockFactory () |
Get 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. | |
![]() | |
virtual | ~LuceneObject () |
virtual void | initialize () |
Called directly after instantiation to create objects that depend on this object being fully constructed. | |
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr()) |
Return clone of this object. | |
virtual int32_t | hashCode () |
Return hash code for this object. | |
virtual bool | equals (const LuceneObjectPtr &other) |
Return whether two objects are equal. | |
virtual int32_t | compareTo (const LuceneObjectPtr &other) |
Compare two objects. | |
![]() | |
virtual | ~LuceneSync () |
virtual SynchronizePtr | getSync () |
Return this object synchronize lock. | |
virtual LuceneSignalPtr | getSignal () |
Return this object signal. | |
virtual void | lock (int32_t timeout=0) |
Lock this object using an optional timeout. | |
virtual void | unlock () |
Unlock this object. | |
virtual bool | holdsLock () |
Returns true if this object is currently locked by current thread. | |
virtual void | wait (int32_t timeout=0) |
Wait for signal using an optional timeout. | |
virtual void | notifyAll () |
Notify all threads waiting for signal. | |
Static Public Member Functions | |
static String | _getClassName () |
![]() | |
static String | _getClassName () |
static FSDirectoryPtr | open (const String &path) |
Creates an FSDirectory instance. | |
static FSDirectoryPtr | open (const String &path, const LockFactoryPtr &lockFactory) |
Just like open(File) , but allows you to also specify a custom LockFactory . | |
static HashSet< String > | listAll (const String &dir) |
Lists all files (not subdirectories) in the directory. | |
static uint64_t | fileModified (const String &directory, const String &name) |
Returns the time the named file was last modified. | |
![]() | |
static String | _getClassName () |
static void | copy (const DirectoryPtr &src, const DirectoryPtr &dest, bool closeDirSrc) |
Copy contents of a directory src to a directory dest. If a file in src already exists in dest then the one in dest will be blindly overwritten. NOTE: the source directory cannot change while this method is running. Otherwise the results are undefined. | |
Additional Inherited Members | |
![]() | |
static const int32_t | DEFAULT_READ_CHUNK_SIZE |
Default read chunk size. This is a conditional default based on operating system. | |
![]() | |
FSDirectory (const String &path, const LockFactoryPtr &lockFactory) | |
Create a new FSDirectory for the named location (ctor for subclasses). | |
void | initOutput (const String &name) |
Initializes the directory to create a new file with the given name. This method should be used in createOutput . | |
![]() | |
void | ensureOpen () |
![]() | |
LuceneObject () | |
![]() | |
bool | checked |
String | directory |
The underlying filesystem directory. | |
int32_t | chunkSize |
![]() | |
bool | isOpen |
LockFactoryPtr | lockFactory |
Holds the LockFactory instance (implements locking for this Directory instance). | |
![]() | |
SynchronizePtr | objectLock |
LuceneSignalPtr | objectSignal |
File-based Directory
implementation that uses mmap for reading, and SimpleFSIndexOutput
for writing.
NOTE: memory mapping uses up a portion of the virtual memory address space in your process equal to the size of the file being mapped. Before using this class, be sure your have plenty of virtual address space.
NOTE: Accessing this class either directly or indirectly from a thread while it's interrupted can close the underlying channel immediately if at the same time the thread is blocked on IO. The channel will remain closed and subsequent access to MMapDirectory
will throw an exception.
Lucene::MMapDirectory::MMapDirectory | ( | const String & | path, |
const LockFactoryPtr & | lockFactory = LockFactoryPtr() |
||
) |
Create a new MMapDirectory for the named location.
path | the path of the directory. |
lockFactory | the lock factory to use, or null for the default (NativeFSLockFactory ) |
|
virtual |
|
inlinestatic |
|
virtual |
Creates an IndexOutput for the file with the given name.
Implements Lucene::Directory.
|
inlinevirtual |
Reimplemented from Lucene::FSDirectory.
|
virtual |
Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size.
Reimplemented from Lucene::FSDirectory.
|
virtual |
Returns 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 are FSDirectory
and CompoundFileReader
.
Reimplemented from Lucene::FSDirectory.
|
virtual |
Creates an IndexInput for the file with the given name.
Reimplemented from Lucene::FSDirectory.
|
inline |