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


SegmentInfos.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef SEGMENTINFOS_H
8 #define SEGMENTINFOS_H
9 
10 #include "SegmentInfoCollection.h"
11 
12 namespace Lucene {
13 
15 class LPPAPI SegmentInfos : public SegmentInfoCollection {
16 public:
18  virtual ~SegmentInfos();
19 
21 
22 public:
24  static const int32_t FORMAT;
25 
30  static const int32_t FORMAT_LOCKLESS;
31 
33  static const int32_t FORMAT_SINGLE_NORM_FILE;
34 
36  static const int32_t FORMAT_SHARED_DOC_STORE;
37 
39  static const int32_t FORMAT_CHECKSUM;
40 
42  static const int32_t FORMAT_DEL_COUNT;
43 
46  static const int32_t FORMAT_HAS_PROX;
47 
49  static const int32_t FORMAT_USER_DATA;
50 
52  static const int32_t FORMAT_DIAGNOSTICS;
53 
55  static const int32_t CURRENT_FORMAT;
56 
57  int32_t counter; // used to name new segments
58 
59 private:
61  static int32_t defaultGenFileRetryCount;
62  static int32_t defaultGenFileRetryPauseMsec;
63  static int32_t defaultGenLookaheadCount;
64 
67  int64_t version;
68 
69  int64_t generation; // generation of the "segments_N" for the next commit
70 
71  int64_t lastGeneration; // generation of the "segments_N" file we last successfully read
72  // or wrote; this is normally the same as generation except if
73  // there was an exception that had interrupted a commit
74 
75  MapStringString userData; // Opaque map<string, string> that user can specify during IndexWriter::commit
76 
77  static MapStringString singletonUserData;
78 
79  static InfoStreamPtr infoStream;
80  ChecksumIndexOutputPtr pendingSegnOutput;
81 
82 public:
83  SegmentInfoPtr info(int32_t i);
86 
88  void read(const DirectoryPtr& directory, const String& segmentFileName);
89 
91  void read(const DirectoryPtr& directory);
92 
95 
97  int64_t getVersion();
98  int64_t getGeneration();
99  int64_t getLastGeneration();
100 
103  SegmentInfosPtr range(int32_t first, int32_t last);
104 
106  void updateGeneration(const SegmentInfosPtr& other);
107 
108  void rollbackCommit(const DirectoryPtr& dir);
109 
114  void prepareCommit(const DirectoryPtr& dir);
115 
118  HashSet<String> files(const DirectoryPtr& dir, bool includeSegmentsFile);
119 
120  void finishCommit(const DirectoryPtr& dir);
121 
123  void commit(const DirectoryPtr& dir);
124 
125  String segString(const DirectoryPtr& directory);
126  MapStringString getUserData();
127  void setUserData(MapStringString data);
128 
131  void replace(const SegmentInfosPtr& other);
132 
134 
136  static int64_t getCurrentSegmentGeneration(const DirectoryPtr& directory);
138  static String getCurrentSegmentFileName(const DirectoryPtr& directory);
139  static int64_t generationFromSegmentsFileName(const String& fileName);
140 
142  static int64_t readCurrentVersion(const DirectoryPtr& directory);
143 
145  static MapStringString readCurrentUserData(const DirectoryPtr& directory);
146 
148  static void setInfoStream(const InfoStreamPtr& infoStream);
149 
152  static void setDefaultGenFileRetryCount(int32_t count);
153 
155  static int32_t getDefaultGenFileRetryCount();
156 
158  static void setDefaultGenFileRetryPauseMsec(int32_t msec);
159 
162 
165  static void setDefaultGenLookaheadCount(int32_t count);
166 
168  static int32_t getDefaultGenLookahedCount();
169 
172 
173  static void message(const String& message);
174 
175 protected:
176  void write(const DirectoryPtr& directory);
177 
178  friend class FindSegmentsFile;
179 };
180 
181 }
182 
183 #endif
Lucene::SegmentInfos::getCurrentSegmentFileName
static String getCurrentSegmentFileName(HashSet< String > files)
Lucene::SegmentInfos::counter
int32_t counter
Definition: SegmentInfos.h:57
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::SegmentInfos::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a copy of this instance, also copying each SegmentInfo.
Lucene::SegmentInfos::getUserData
MapStringString getUserData()
Lucene::SegmentInfos::FORMAT_DIAGNOSTICS
static const int32_t FORMAT_DIAGNOSTICS
This format adds optional per-segment string diagnostics storage, and switches userData to Map.
Definition: SegmentInfos.h:52
Lucene::SegmentInfos::FORMAT_HAS_PROX
static const int32_t FORMAT_HAS_PROX
This format adds the boolean hasProx to record if any fields in the segment store prox information (i...
Definition: SegmentInfos.h:46
Lucene::SegmentInfos::FORMAT_SINGLE_NORM_FILE
static const int32_t FORMAT_SINGLE_NORM_FILE
This format adds a "hasSingleNormFile" flag into each segment info.
Definition: SegmentInfos.h:33
Lucene::SegmentInfoPtr
boost::shared_ptr< SegmentInfo > SegmentInfoPtr
Definition: LuceneTypes.h:208
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::ChecksumIndexOutputPtr
boost::shared_ptr< ChecksumIndexOutput > ChecksumIndexOutputPtr
Definition: LuceneTypes.h:488
Lucene::SegmentInfos::getVersion
int64_t getVersion()
Version number when this SegmentInfos was generated.
Lucene::SegmentInfos::FORMAT_SHARED_DOC_STORE
static const int32_t FORMAT_SHARED_DOC_STORE
This format allows multiple segments to share a single vectors and stored fields file.
Definition: SegmentInfos.h:36
Lucene::SegmentInfos::FORMAT_DEL_COUNT
static const int32_t FORMAT_DEL_COUNT
This format adds the deletion count for each segment. This way IndexWriter can efficiently report num...
Definition: SegmentInfos.h:42
Lucene::SegmentInfos
A collection of SegmentInfo objects with methods for operating on those segments in relation to the f...
Definition: SegmentInfos.h:15
Lucene::SegmentInfos::files
HashSet< String > files(const DirectoryPtr &dir, bool includeSegmentsFile)
Returns all file names referenced by SegmentInfo instances matching the provided Directory (ie files ...
SegmentInfoCollection.h
Lucene::SegmentInfos::setUserData
void setUserData(MapStringString data)
Lucene::SegmentInfos::commit
void commit(const DirectoryPtr &dir)
Writes & syncs to the Directory dir, taking care to remove the segments file on exception.
Lucene::SegmentInfos::read
void read(const DirectoryPtr &directory)
This version of read uses the retry logic (for lock-less commits) to find the right segments file to ...
Lucene::SegmentInfos::readCurrentVersion
static int64_t readCurrentVersion(const DirectoryPtr &directory)
Current version number from segments file.
Lucene::SegmentInfos::generationFromSegmentsFileName
static int64_t generationFromSegmentsFileName(const String &fileName)
Lucene::SegmentInfos::readCurrentUserData
static MapStringString readCurrentUserData(const DirectoryPtr &directory)
Returns userData from latest segments file.
Lucene::SegmentInfos::range
SegmentInfosPtr range(int32_t first, int32_t last)
Returns a new SegmentInfos containing the SegmentInfo instances in the specified range first (inclusi...
Lucene::SegmentInfos::FORMAT_USER_DATA
static const int32_t FORMAT_USER_DATA
This format adds optional commit userData storage.
Definition: SegmentInfos.h:49
Lucene::SegmentInfos::info
SegmentInfoPtr info(int32_t i)
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::SegmentInfos::getDefaultGenFileRetryCount
static int32_t getDefaultGenFileRetryCount()
Lucene::SegmentInfos::setDefaultGenFileRetryPauseMsec
static void setDefaultGenFileRetryPauseMsec(int32_t msec)
Set how many milliseconds to pause in between attempts to load the segments.gen file.
Lucene::SegmentInfos::message
static void message(const String &message)
Lucene::SegmentInfos::getGeneration
int64_t getGeneration()
Lucene::SegmentInfos::finishCommit
void finishCommit(const DirectoryPtr &dir)
Lucene::SegmentInfos::FORMAT_LOCKLESS
static const int32_t FORMAT_LOCKLESS
This format adds details used for lockless commits. It differs slightly from the previous format in t...
Definition: SegmentInfos.h:30
Lucene::SegmentInfoCollection
A collection of SegmentInfo objects to be used as a base class for SegmentInfos.
Definition: SegmentInfoCollection.h:15
Lucene::SegmentInfos::hasExternalSegments
bool hasExternalSegments(const DirectoryPtr &dir)
Lucene::SegmentInfos::setInfoStream
static void setInfoStream(const InfoStreamPtr &infoStream)
If non-null, information about retries when loading the segments file will be printed to this.
Lucene::SegmentInfos::getCurrentSegmentGeneration
static int64_t getCurrentSegmentGeneration(const DirectoryPtr &directory)
Lucene::HashSet< String >
Lucene::SegmentInfos::setDefaultGenFileRetryCount
static void setDefaultGenFileRetryCount(int32_t count)
Set how many times to try loading the segments.gen file contents to determine current segment generat...
Lucene::SegmentInfos::segString
String segString(const DirectoryPtr &directory)
Lucene::SegmentInfos::prepareCommit
void prepareCommit(const DirectoryPtr &dir)
Call this to start a commit. This writes the new segments file, but writes an invalid checksum at the...
Lucene::SegmentInfos::getCurrentSegmentFileName
static String getCurrentSegmentFileName(const DirectoryPtr &directory)
Lucene::SegmentInfos::getLastGeneration
int64_t getLastGeneration()
Lucene::SegmentInfos::getNextSegmentFileName
String getNextSegmentFileName()
Lucene::SegmentInfos::~SegmentInfos
virtual ~SegmentInfos()
Lucene::SegmentInfos::rollbackCommit
void rollbackCommit(const DirectoryPtr &dir)
Lucene::SegmentInfos::FORMAT
static const int32_t FORMAT
The file format version, a negative number. Works since counter, the old 1st entry,...
Definition: SegmentInfos.h:20
Lucene::SegmentInfos::getCurrentSegmentGeneration
static int64_t getCurrentSegmentGeneration(HashSet< String > files)
Lucene::SegmentInfos::read
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.
Lucene::SegmentInfos::write
void write(const DirectoryPtr &directory)
Lucene::SegmentInfos::setDefaultGenLookaheadCount
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 ...
Lucene::SegmentInfos::CURRENT_FORMAT
static const int32_t CURRENT_FORMAT
This must always point to the most recent file format.
Definition: SegmentInfos.h:55
Lucene::SegmentInfos::SegmentInfos
SegmentInfos()
Lucene::SegmentInfos::FORMAT_CHECKSUM
static const int32_t FORMAT_CHECKSUM
This format adds a checksum at the end of the file to ensure all bytes were successfully written.
Definition: SegmentInfos.h:39
Lucene::SegmentInfosPtr
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition: LuceneTypes.h:210
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::SegmentInfos::getInfoStream
static InfoStreamPtr getInfoStream()
Lucene::InfoStreamPtr
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition: LuceneTypes.h:532
Lucene::SegmentInfos::getDefaultGenFileRetryPauseMsec
static int32_t getDefaultGenFileRetryPauseMsec()
Lucene::SegmentInfos::updateGeneration
void updateGeneration(const SegmentInfosPtr &other)
Carry over generation numbers from another SegmentInfos.
Lucene::SegmentInfos::getCurrentSegmentFileName
String getCurrentSegmentFileName()
Lucene::SegmentInfos::replace
void replace(const SegmentInfosPtr &other)
Replaces all segments in this instance, but keeps generation, version, counter so that future commits...
Lucene::SegmentInfos::getDefaultGenLookahedCount
static int32_t getDefaultGenLookahedCount()

clucene.sourceforge.net