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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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:
17  SegmentInfos();
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);
84  String getCurrentSegmentFileName();
85  String getNextSegmentFileName();
86 
88  void read(const DirectoryPtr& directory, const String& segmentFileName);
89 
91  void read(const DirectoryPtr& directory);
92 
94  virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
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 
133  bool hasExternalSegments(const DirectoryPtr& dir);
134 
135  static int64_t getCurrentSegmentGeneration(HashSet<String> files);
136  static int64_t getCurrentSegmentGeneration(const DirectoryPtr& directory);
137  static String getCurrentSegmentFileName(HashSet<String> files);
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 
161  static int32_t getDefaultGenFileRetryPauseMsec();
162 
165  static void setDefaultGenLookaheadCount(int32_t count);
166 
168  static int32_t getDefaultGenLookahedCount();
169 
171  static InfoStreamPtr getInfoStream();
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
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition: LuceneTypes.h:532
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
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
boost::shared_ptr< ChecksumIndexOutput > ChecksumIndexOutputPtr
Definition: LuceneTypes.h:488
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
int32_t counter
Definition: SegmentInfos.h:57
boost::shared_ptr< SegmentInfo > SegmentInfoPtr
Definition: LuceneTypes.h:208
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
static const int32_t CURRENT_FORMAT
This must always point to the most recent file format.
Definition: SegmentInfos.h:55
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition: LuceneTypes.h:210
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
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
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Definition: AbstractAllTermDocs.h:12
static const int32_t FORMAT_USER_DATA
This format adds optional commit userData storage.
Definition: SegmentInfos.h:49
static const int32_t FORMAT_DIAGNOSTICS
This format adds optional per-segment string diagnostics storage, and switches userData to Map...
Definition: SegmentInfos.h:52
A collection of SegmentInfo objects to be used as a base class for SegmentInfos.
Definition: SegmentInfoCollection.h:15
static const int32_t FORMAT_SINGLE_NORM_FILE
This format adds a "hasSingleNormFile" flag into each segment info.
Definition: SegmentInfos.h:33
A collection of SegmentInfo objects with methods for operating on those segments in relation to the f...
Definition: SegmentInfos.h:15
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

clucene.sourceforge.net