Lucene++ - a full-featured, c++ search engine
API Documentation
A memory-resident Directory
implementation. Locking implementation is by default the SingleInstanceLockFactory
but can be changed with setLockFactory
. Lock acquisition sequence: RAMDirectory, then RAMFile.
More...
#include <RAMDirectory.h>
Public Member Functions | |
RAMDirectory () | |
Constructs an empty Directory . | |
RAMDirectory (const DirectoryPtr &dir) | |
Creates a new RAMDirectory instance from a different Directory implementation. This can be used to load a disk-based index into memory. | |
RAMDirectory (const DirectoryPtr &dir, bool closeDir) | |
virtual | ~RAMDirectory () |
virtual String | getClassName () |
boost::shared_ptr< RAMDirectory > | shared_from_this () |
virtual void | initialize () |
Called directly after instantiation to create objects that depend on this object being fully constructed. | |
virtual HashSet< String > | listAll () |
Returns an array of strings, one for each file 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 int64_t | fileLength (const String &name) |
Returns the length of a file in the directory. | |
int64_t | sizeInBytes () |
Return total size in bytes of all files in this directory. This is currently quantized to RAMOutputStream::BUFFER_SIZE. | |
virtual void | deleteFile (const String &name) |
Removes an existing file in the directory. | |
virtual IndexOutputPtr | createOutput (const String &name) |
Creates a new, empty file in the directory with the given name. Returns a stream writing this file. | |
virtual IndexInputPtr | openInput (const String &name) |
Returns a stream reading an existing file. | |
virtual void | close () |
Closes the store. | |
![]() | |
Directory () | |
virtual | ~Directory () |
boost::shared_ptr< Directory > | shared_from_this () |
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 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 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 String | getLockID () |
Return a string identifier that uniquely differentiates this Directory instance from other Directory instances. This ID should be the same if two Directory instances are considered "the same index". This is how locking "scopes" to the right index. | |
virtual String | toString () |
Returns a string representation of the object. | |
![]() | |
virtual | ~LuceneObject () |
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 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. | |
Data Fields | |
INTERNAL | : int64_t _sizeInBytes |
MapStringRAMFile | fileMap |
Protected Attributes | |
DirectoryWeakPtr | _dirSource |
bool | copyDirectory |
bool | closeDir |
![]() | |
bool | isOpen |
LockFactoryPtr | lockFactory |
Holds the LockFactory instance (implements locking for this Directory instance). | |
![]() | |
SynchronizePtr | objectLock |
LuceneSignalPtr | objectSignal |
Additional Inherited Members | |
![]() | |
void | ensureOpen () |
![]() | |
LuceneObject () | |
A memory-resident Directory
implementation. Locking implementation is by default the SingleInstanceLockFactory
but can be changed with setLockFactory
. Lock acquisition sequence: RAMDirectory, then RAMFile.
Lucene::RAMDirectory::RAMDirectory | ( | ) |
Constructs an empty Directory
.
Lucene::RAMDirectory::RAMDirectory | ( | const DirectoryPtr & | dir | ) |
Creates a new RAMDirectory instance from a different Directory implementation. This can be used to load a disk-based index into memory.
This should be used only with indices that can fit into memory.
Note that the resulting RAMDirectory instance is fully independent from the original Directory (it is a complete copy). Any subsequent changes to the original Directory will not be visible in the RAMDirectory instance.
dir | a Directory value |
Lucene::RAMDirectory::RAMDirectory | ( | const DirectoryPtr & | dir, |
bool | closeDir | ||
) |
|
virtual |
|
inlinestatic |
|
virtual |
Closes the store.
Implements Lucene::Directory.
|
virtual |
Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
Implements Lucene::Directory.
|
virtual |
Removes an existing file in the directory.
Implements Lucene::Directory.
|
virtual |
Returns true if a file with the given name exists.
Implements Lucene::Directory.
|
virtual |
Returns the length of a file in the directory.
Implements Lucene::Directory.
|
virtual |
Returns the time the named file was last modified.
Implements Lucene::Directory.
|
inlinevirtual |
Reimplemented from Lucene::Directory.
|
virtual |
Called directly after instantiation to create objects that depend on this object being fully constructed.
Reimplemented from Lucene::LuceneObject.
|
virtual |
Returns an array of strings, one for each file in the directory.
Implements Lucene::Directory.
|
virtual |
Returns a stream reading an existing file.
Implements Lucene::Directory.
|
inline |
int64_t Lucene::RAMDirectory::sizeInBytes | ( | ) |
Return total size in bytes of all files in this directory. This is currently quantized to RAMOutputStream::BUFFER_SIZE.
|
virtual |
Set the modified time of an existing file to now.
Implements Lucene::Directory.
INTERNAL Lucene::RAMDirectory::__pad0__ |
|
protected |
|
protected |
|
protected |
MapStringRAMFile Lucene::RAMDirectory::fileMap |