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


Loading...
Searching...
No Matches
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 (const DirectoryPtr &directory, const String &segmentFileName)
 Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process.
 
void read (const DirectoryPtr &directory)
 This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Returns a copy of this instance, also copying each SegmentInfo.
 
int64_t getVersion ()
 Version number when this SegmentInfos was generated.
 
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.
 
void updateGeneration (const SegmentInfosPtr &other)
 Carry over generation numbers from another SegmentInfos.
 
void rollbackCommit (const DirectoryPtr &dir)
 
void prepareCommit (const 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.
 
HashSet< String > files (const 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 finishCommit (const DirectoryPtr &dir)
 
void commit (const DirectoryPtr &dir)
 Writes & syncs to the Directory dir, taking care to remove the segments file on exception.
 
String segString (const DirectoryPtr &directory)
 
MapStringString getUserData ()
 
void setUserData (MapStringString data)
 
void replace (const SegmentInfosPtr &other)
 Replaces all segments in this instance, but keeps generation, version, counter so that future commits remain write once.
 
bool hasExternalSegments (const DirectoryPtr &dir)
 
- Public Member Functions inherited from Lucene::SegmentInfoCollection
 SegmentInfoCollection ()
 
virtual ~SegmentInfoCollection ()
 
boost::shared_ptr< SegmentInfoCollectionshared_from_this ()
 
int32_t size ()
 
bool empty ()
 
void clear ()
 
void add (const SegmentInfoPtr &info)
 
void add (int32_t pos, const SegmentInfoPtr &info)
 
void addAll (const SegmentInfoCollectionPtr &segmentInfos)
 
bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
 
int32_t find (const SegmentInfoPtr &info)
 
bool contains (const 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.
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
virtual String toString ()
 Returns a string representation of the object.
 
- Public Member Functions inherited from Lucene::LuceneSync
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 int64_t getCurrentSegmentGeneration (HashSet< String > files)
 
static int64_t getCurrentSegmentGeneration (const DirectoryPtr &directory)
 
static String getCurrentSegmentFileName (HashSet< String > files)
 
static String getCurrentSegmentFileName (const DirectoryPtr &directory)
 
static int64_t generationFromSegmentsFileName (const String &fileName)
 
static int64_t readCurrentVersion (const DirectoryPtr &directory)
 Current version number from segments file.
 
static MapStringString readCurrentUserData (const DirectoryPtr &directory)
 Returns userData from latest segments file.
 
static void setInfoStream (const InfoStreamPtr &infoStream)
 If non-null, information about retries when loading the segments file will be printed to this.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static const int32_t FORMAT_SINGLE_NORM_FILE
 This format adds a "hasSingleNormFile" flag into each segment info.
 
static const int32_t FORMAT_SHARED_DOC_STORE
 This format allows multiple segments to share a single vectors and stored fields file.
 
static const int32_t FORMAT_CHECKSUM
 This format adds a checksum at the end of the file to ensure all bytes were successfully written.
 
static const int32_t FORMAT_DEL_COUNT
 This format adds the deletion count for each segment. This way IndexWriter can efficiently report numDocs().
 
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)
 
static const int32_t FORMAT_USER_DATA
 This format adds optional commit userData storage.
 
static const int32_t FORMAT_DIAGNOSTICS
 This format adds optional per-segment string diagnostics storage, and switches userData to Map.
 
static const int32_t CURRENT_FORMAT
 This must always point to the most recent file format.
 

Protected Member Functions

void write (const DirectoryPtr &directory)
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Additional Inherited Members

- Protected Attributes inherited from Lucene::SegmentInfoCollection
Collection< SegmentInfoPtrsegmentInfos
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Detailed Description

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

Constructor & Destructor Documentation

◆ SegmentInfos()

Lucene::SegmentInfos::SegmentInfos ( )

◆ ~SegmentInfos()

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

Member Function Documentation

◆ _getClassName()

static String Lucene::SegmentInfos::_getClassName ( )
inlinestatic

◆ clone()

virtual LuceneObjectPtr Lucene::SegmentInfos::clone ( const LuceneObjectPtr other = LuceneObjectPtr())
virtual

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

Reimplemented from Lucene::SegmentInfoCollection.

◆ commit()

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

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

◆ files()

HashSet< String > Lucene::SegmentInfos::files ( const 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.

◆ finishCommit()

void Lucene::SegmentInfos::finishCommit ( const DirectoryPtr dir)

◆ generationFromSegmentsFileName()

static int64_t Lucene::SegmentInfos::generationFromSegmentsFileName ( const String &  fileName)
static

◆ getClassName()

virtual String Lucene::SegmentInfos::getClassName ( )
inlinevirtual

Reimplemented from Lucene::SegmentInfoCollection.

◆ getCurrentSegmentFileName() [1/3]

String Lucene::SegmentInfos::getCurrentSegmentFileName ( )

◆ getCurrentSegmentFileName() [2/3]

static String Lucene::SegmentInfos::getCurrentSegmentFileName ( const DirectoryPtr directory)
static

◆ getCurrentSegmentFileName() [3/3]

static String Lucene::SegmentInfos::getCurrentSegmentFileName ( HashSet< String >  files)
static

◆ getCurrentSegmentGeneration() [1/2]

static int64_t Lucene::SegmentInfos::getCurrentSegmentGeneration ( const DirectoryPtr directory)
static

◆ getCurrentSegmentGeneration() [2/2]

static int64_t Lucene::SegmentInfos::getCurrentSegmentGeneration ( HashSet< String >  files)
static

◆ getDefaultGenFileRetryCount()

static int32_t Lucene::SegmentInfos::getDefaultGenFileRetryCount ( )
static

◆ getDefaultGenFileRetryPauseMsec()

static int32_t Lucene::SegmentInfos::getDefaultGenFileRetryPauseMsec ( )
static

◆ getDefaultGenLookahedCount()

static int32_t Lucene::SegmentInfos::getDefaultGenLookahedCount ( )
static

◆ getGeneration()

int64_t Lucene::SegmentInfos::getGeneration ( )

◆ getInfoStream()

static InfoStreamPtr Lucene::SegmentInfos::getInfoStream ( )
static
See also
setInfoStream

◆ getLastGeneration()

int64_t Lucene::SegmentInfos::getLastGeneration ( )

◆ getNextSegmentFileName()

String Lucene::SegmentInfos::getNextSegmentFileName ( )

◆ getUserData()

MapStringString Lucene::SegmentInfos::getUserData ( )

◆ getVersion()

int64_t Lucene::SegmentInfos::getVersion ( )

Version number when this SegmentInfos was generated.

◆ hasExternalSegments()

bool Lucene::SegmentInfos::hasExternalSegments ( const DirectoryPtr dir)

◆ info()

SegmentInfoPtr Lucene::SegmentInfos::info ( int32_t  i)

◆ message()

static void Lucene::SegmentInfos::message ( const String &  message)
static

◆ prepareCommit()

void Lucene::SegmentInfos::prepareCommit ( const 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.

◆ range()

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.

◆ read() [1/2]

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

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

◆ read() [2/2]

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

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

◆ readCurrentUserData()

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

Returns userData from latest segments file.

◆ readCurrentVersion()

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

Current version number from segments file.

◆ replace()

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

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

◆ rollbackCommit()

void Lucene::SegmentInfos::rollbackCommit ( const DirectoryPtr dir)

◆ segString()

String Lucene::SegmentInfos::segString ( const DirectoryPtr directory)

◆ setDefaultGenFileRetryCount()

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.

◆ setDefaultGenFileRetryPauseMsec()

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

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

◆ setDefaultGenLookaheadCount()

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.

◆ setInfoStream()

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

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

◆ setUserData()

void Lucene::SegmentInfos::setUserData ( MapStringString  data)

◆ shared_from_this()

boost::shared_ptr< SegmentInfos > Lucene::SegmentInfos::shared_from_this ( )
inline

◆ updateGeneration()

void Lucene::SegmentInfos::updateGeneration ( const SegmentInfosPtr other)

Carry over generation numbers from another SegmentInfos.

◆ write()

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

Field Documentation

◆ counter

int32_t Lucene::SegmentInfos::counter

◆ CURRENT_FORMAT

const int32_t Lucene::SegmentInfos::CURRENT_FORMAT
static

This must always point to the most recent file format.

◆ 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.

◆ FORMAT_CHECKSUM

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.

◆ FORMAT_DEL_COUNT

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().

◆ FORMAT_DIAGNOSTICS

const int32_t Lucene::SegmentInfos::FORMAT_DIAGNOSTICS
static

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

◆ FORMAT_HAS_PROX

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)

◆ FORMAT_LOCKLESS

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.

◆ FORMAT_SHARED_DOC_STORE

const int32_t Lucene::SegmentInfos::FORMAT_SHARED_DOC_STORE
static

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

◆ FORMAT_SINGLE_NORM_FILE

const int32_t Lucene::SegmentInfos::FORMAT_SINGLE_NORM_FILE
static

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

◆ FORMAT_USER_DATA

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