Lucene++ - a full-featured, c++ search engine
API Documentation


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Member Functions
Lucene::SegmentInfos Class Reference

A collection of SegmentInfo objects with methods for operating on those segments in relation to the file system. More...

#include <SegmentInfos.h>

+ Inheritance diagram for Lucene::SegmentInfos:

Public Member Functions

 SegmentInfos ()
 
virtual ~SegmentInfos ()
 
virtual String getClassName ()
 
boost::shared_ptr< SegmentInfosshared_from_this ()
 
SegmentInfoPtr info (int32_t i)
 
String getCurrentSegmentFileName ()
 
String getNextSegmentFileName ()
 
void read (DirectoryPtr directory, const String &segmentFileName)
 Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process. More...
 
void read (DirectoryPtr directory)
 This version of read uses the retry logic (for lock-less commits) to find the right segments file to load. More...
 
virtual LuceneObjectPtr clone (LuceneObjectPtr other=LuceneObjectPtr())
 Returns a copy of this instance, also copying each SegmentInfo. More...
 
int64_t getVersion ()
 Version number when this SegmentInfos was generated. More...
 
int64_t getGeneration ()
 
int64_t getLastGeneration ()
 
SegmentInfosPtr range (int32_t first, int32_t last)
 Returns a new SegmentInfos containing the SegmentInfo instances in the specified range first (inclusive) to last (exclusive), so total number of segments returned is last-first. More...
 
void updateGeneration (SegmentInfosPtr other)
 Carry over generation numbers from another SegmentInfos. More...
 
void rollbackCommit (DirectoryPtr dir)
 
void prepareCommit (DirectoryPtr dir)
 Call this to start a commit. This writes the new segments file, but writes an invalid checksum at the end, so that it is not visible to readers. Once this is called you must call. finishCommit to complete the commit or rollbackCommit to abort it. More...
 
HashSet< String > files (DirectoryPtr dir, bool includeSegmentsFile)
 Returns all file names referenced by SegmentInfo instances matching the provided Directory (ie files associated with any "external" segments are skipped). The returned collection is recomputed on each invocation. More...
 
void finishCommit (DirectoryPtr dir)
 
void commit (DirectoryPtr dir)
 Writes & syncs to the Directory dir, taking care to remove the segments file on exception. More...
 
String segString (DirectoryPtr directory)
 
MapStringString getUserData ()
 
void setUserData (MapStringString data)
 
void replace (SegmentInfosPtr other)
 Replaces all segments in this instance, but keeps generation, version, counter so that future commits remain write once. More...
 
bool hasExternalSegments (DirectoryPtr dir)
 
- Public Member Functions inherited from Lucene::SegmentInfoCollection
 SegmentInfoCollection ()
 
virtual ~SegmentInfoCollection ()
 
boost::shared_ptr
< SegmentInfoCollection
shared_from_this ()
 
int32_t size ()
 
bool empty ()
 
void clear ()
 
void add (SegmentInfoPtr info)
 
void add (int32_t pos, SegmentInfoPtr info)
 
void addAll (SegmentInfoCollectionPtr segmentInfos)
 
bool equals (SegmentInfoCollectionPtr other)
 
int32_t find (SegmentInfoPtr info)
 
bool contains (SegmentInfoPtr info)
 
void remove (int32_t pos)
 
void remove (int32_t start, int32_t end)
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed. More...
 
virtual int32_t hashCode ()
 Return hash code for this object. More...
 
virtual bool equals (LuceneObjectPtr other)
 Return whether two objects are equal. More...
 
virtual int32_t compareTo (LuceneObjectPtr other)
 Compare two objects. More...
 
virtual String toString ()
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock. More...
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal. More...
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout. More...
 
virtual void unlock ()
 Unlock this object. More...
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread. More...
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout. More...
 
virtual void notifyAll ()
 Notify all threads waiting for signal. More...
 

Static Public Member Functions

static String _getClassName ()
 
static int64_t getCurrentSegmentGeneration (HashSet< String > files)
 
static int64_t getCurrentSegmentGeneration (DirectoryPtr directory)
 
static String getCurrentSegmentFileName (HashSet< String > files)
 
static String getCurrentSegmentFileName (DirectoryPtr directory)
 
static int64_t generationFromSegmentsFileName (const String &fileName)
 
static int64_t readCurrentVersion (DirectoryPtr directory)
 Current version number from segments file. More...
 
static MapStringString readCurrentUserData (DirectoryPtr directory)
 Returns userData from latest segments file. More...
 
static void setInfoStream (InfoStreamPtr infoStream)
 If non-null, information about retries when loading the segments file will be printed to this. More...
 
static void setDefaultGenFileRetryCount (int32_t count)
 Set how many times to try loading the segments.gen file contents to determine current segment generation. This file is only referenced when the primary method (listing the directory) fails. More...
 
static int32_t getDefaultGenFileRetryCount ()
 
static void setDefaultGenFileRetryPauseMsec (int32_t msec)
 Set how many milliseconds to pause in between attempts to load the segments.gen file. More...
 
static int32_t getDefaultGenFileRetryPauseMsec ()
 
static void setDefaultGenLookaheadCount (int32_t count)
 Set how many times to try incrementing the gen when loading the segments file. This only runs if the primary (listing directory) and secondary (opening segments.gen file) methods fail to find the segments file. More...
 
static int32_t getDefaultGenLookahedCount ()
 
static InfoStreamPtr getInfoStream ()
 
static void message (const String &message)
 
- Static Public Member Functions inherited from Lucene::SegmentInfoCollection
static String _getClassName ()
 

Data Fields

int32_t counter
 

Static Public Attributes

static const int32_t FORMAT
 The file format version, a negative number. Works since counter, the old 1st entry, is always >= 0. More...
 
static const int32_t FORMAT_LOCKLESS
 This format adds details used for lockless commits. It differs slightly from the previous format in that file names are never re-used (write once). Instead, each file is written to the next generation. For example, segments_1, segments_2, etc. This allows us to not use a commit lock. See fileformats for details. More...
 
static const int32_t FORMAT_SINGLE_NORM_FILE
 This format adds a "hasSingleNormFile" flag into each segment info. More...
 
static const int32_t FORMAT_SHARED_DOC_STORE
 This format allows multiple segments to share a single vectors and stored fields file. More...
 
static const int32_t FORMAT_CHECKSUM
 This format adds a checksum at the end of the file to ensure all bytes were successfully written. More...
 
static const int32_t FORMAT_DEL_COUNT
 This format adds the deletion count for each segment. This way IndexWriter can efficiently report numDocs(). More...
 
static const int32_t FORMAT_HAS_PROX
 This format adds the boolean hasProx to record if any fields in the segment store prox information (ie, have omitTermFreqAndPositions == false) More...
 
static const int32_t FORMAT_USER_DATA
 This format adds optional commit userData storage. More...
 
static const int32_t FORMAT_DIAGNOSTICS
 This format adds optional per-segment string diagnostics storage, and switches userData to Map. More...
 
static const int32_t CURRENT_FORMAT
 This must always point to the most recent file format. More...
 

Protected Member Functions

void write (DirectoryPtr directory)
 

Additional Inherited Members

- Protected Attributes inherited from Lucene::SegmentInfoCollection
Collection< SegmentInfoPtrsegmentInfos
 

Detailed Description

A collection of SegmentInfo objects with methods for operating on those segments in relation to the file system.

Constructor & Destructor Documentation

Lucene::SegmentInfos::SegmentInfos ( )
virtual Lucene::SegmentInfos::~SegmentInfos ( )
virtual

Member Function Documentation

static String Lucene::SegmentInfos::_getClassName ( )
inlinestatic
virtual LuceneObjectPtr Lucene::SegmentInfos::clone ( LuceneObjectPtr  other = LuceneObjectPtr())
virtual

Returns a copy of this instance, also copying each SegmentInfo.

Reimplemented from Lucene::SegmentInfoCollection.

void Lucene::SegmentInfos::commit ( DirectoryPtr  dir)

Writes & syncs to the Directory dir, taking care to remove the segments file on exception.

HashSet<String> Lucene::SegmentInfos::files ( DirectoryPtr  dir,
bool  includeSegmentsFile 
)

Returns all file names referenced by SegmentInfo instances matching the provided Directory (ie files associated with any "external" segments are skipped). The returned collection is recomputed on each invocation.

void Lucene::SegmentInfos::finishCommit ( DirectoryPtr  dir)
static int64_t Lucene::SegmentInfos::generationFromSegmentsFileName ( const String &  fileName)
static
virtual String Lucene::SegmentInfos::getClassName ( )
inlinevirtual

Reimplemented from Lucene::SegmentInfoCollection.

String Lucene::SegmentInfos::getCurrentSegmentFileName ( )
static String Lucene::SegmentInfos::getCurrentSegmentFileName ( HashSet< String >  files)
static
static String Lucene::SegmentInfos::getCurrentSegmentFileName ( DirectoryPtr  directory)
static
static int64_t Lucene::SegmentInfos::getCurrentSegmentGeneration ( HashSet< String >  files)
static
static int64_t Lucene::SegmentInfos::getCurrentSegmentGeneration ( DirectoryPtr  directory)
static
static int32_t Lucene::SegmentInfos::getDefaultGenFileRetryCount ( )
static
static int32_t Lucene::SegmentInfos::getDefaultGenFileRetryPauseMsec ( )
static
static int32_t Lucene::SegmentInfos::getDefaultGenLookahedCount ( )
static
int64_t Lucene::SegmentInfos::getGeneration ( )
static InfoStreamPtr Lucene::SegmentInfos::getInfoStream ( )
static
See Also
setInfoStream
int64_t Lucene::SegmentInfos::getLastGeneration ( )
String Lucene::SegmentInfos::getNextSegmentFileName ( )
MapStringString Lucene::SegmentInfos::getUserData ( )
int64_t Lucene::SegmentInfos::getVersion ( )

Version number when this SegmentInfos was generated.

bool Lucene::SegmentInfos::hasExternalSegments ( DirectoryPtr  dir)
SegmentInfoPtr Lucene::SegmentInfos::info ( int32_t  i)
static void Lucene::SegmentInfos::message ( const String &  message)
static
void Lucene::SegmentInfos::prepareCommit ( DirectoryPtr  dir)

Call this to start a commit. This writes the new segments file, but writes an invalid checksum at the end, so that it is not visible to readers. Once this is called you must call. finishCommit to complete the commit or rollbackCommit to abort it.

SegmentInfosPtr Lucene::SegmentInfos::range ( int32_t  first,
int32_t  last 
)

Returns a new SegmentInfos containing the SegmentInfo instances in the specified range first (inclusive) to last (exclusive), so total number of segments returned is last-first.

void Lucene::SegmentInfos::read ( DirectoryPtr  directory,
const String &  segmentFileName 
)

Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process.

void Lucene::SegmentInfos::read ( DirectoryPtr  directory)

This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.

static MapStringString Lucene::SegmentInfos::readCurrentUserData ( DirectoryPtr  directory)
static

Returns userData from latest segments file.

static int64_t Lucene::SegmentInfos::readCurrentVersion ( DirectoryPtr  directory)
static

Current version number from segments file.

void Lucene::SegmentInfos::replace ( SegmentInfosPtr  other)

Replaces all segments in this instance, but keeps generation, version, counter so that future commits remain write once.

void Lucene::SegmentInfos::rollbackCommit ( DirectoryPtr  dir)
String Lucene::SegmentInfos::segString ( DirectoryPtr  directory)
static void Lucene::SegmentInfos::setDefaultGenFileRetryCount ( int32_t  count)
static

Set how many times to try loading the segments.gen file contents to determine current segment generation. This file is only referenced when the primary method (listing the directory) fails.

static void Lucene::SegmentInfos::setDefaultGenFileRetryPauseMsec ( int32_t  msec)
static

Set how many milliseconds to pause in between attempts to load the segments.gen file.

static void Lucene::SegmentInfos::setDefaultGenLookaheadCount ( int32_t  count)
static

Set how many times to try incrementing the gen when loading the segments file. This only runs if the primary (listing directory) and secondary (opening segments.gen file) methods fail to find the segments file.

static void Lucene::SegmentInfos::setInfoStream ( InfoStreamPtr  infoStream)
static

If non-null, information about retries when loading the segments file will be printed to this.

void Lucene::SegmentInfos::setUserData ( MapStringString  data)
boost::shared_ptr< SegmentInfos > Lucene::SegmentInfos::shared_from_this ( )
inline
void Lucene::SegmentInfos::updateGeneration ( SegmentInfosPtr  other)

Carry over generation numbers from another SegmentInfos.

void Lucene::SegmentInfos::write ( DirectoryPtr  directory)
protected

Field Documentation

int32_t Lucene::SegmentInfos::counter
const int32_t Lucene::SegmentInfos::CURRENT_FORMAT
static

This must always point to the most recent file format.

const int32_t Lucene::SegmentInfos::FORMAT
static

The file format version, a negative number. Works since counter, the old 1st entry, is always >= 0.

const int32_t Lucene::SegmentInfos::FORMAT_CHECKSUM
static

This format adds a checksum at the end of the file to ensure all bytes were successfully written.

const int32_t Lucene::SegmentInfos::FORMAT_DEL_COUNT
static

This format adds the deletion count for each segment. This way IndexWriter can efficiently report numDocs().

const int32_t Lucene::SegmentInfos::FORMAT_DIAGNOSTICS
static

This format adds optional per-segment string diagnostics storage, and switches userData to Map.

const int32_t Lucene::SegmentInfos::FORMAT_HAS_PROX
static

This format adds the boolean hasProx to record if any fields in the segment store prox information (ie, have omitTermFreqAndPositions == false)

const int32_t Lucene::SegmentInfos::FORMAT_LOCKLESS
static

This format adds details used for lockless commits. It differs slightly from the previous format in that file names are never re-used (write once). Instead, each file is written to the next generation. For example, segments_1, segments_2, etc. This allows us to not use a commit lock. See fileformats for details.

const int32_t Lucene::SegmentInfos::FORMAT_SHARED_DOC_STORE
static

This format allows multiple segments to share a single vectors and stored fields file.

const int32_t Lucene::SegmentInfos::FORMAT_SINGLE_NORM_FILE
static

This format adds a "hasSingleNormFile" flag into each segment info.

const int32_t Lucene::SegmentInfos::FORMAT_USER_DATA
static

This format adds optional commit userData storage.


The documentation for this class was generated from the following file:

clucene.sourceforge.net