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


Loading...
Searching...
No Matches
SegmentInfo.h
Go to the documentation of this file.
1
2// 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 SEGMENTINFO_H
8#define SEGMENTINFO_H
9
10#include "LuceneObject.h"
11
12namespace Lucene {
13
16class LPPAPI SegmentInfo : public LuceneObject {
17public:
18 SegmentInfo(const String& name, int32_t docCount, const DirectoryPtr& dir);
19
20 SegmentInfo(const String& name, int32_t docCount, const DirectoryPtr& dir, bool isCompoundFile, bool hasSingleNormFile);
21
22 SegmentInfo(const String& name, int32_t docCount, const DirectoryPtr& dir, bool isCompoundFile,
23 bool hasSingleNormFile, int32_t docStoreOffset, const String& docStoreSegment,
24 bool docStoreIsCompoundFile, bool hasProx);
25
30 SegmentInfo(const DirectoryPtr& dir, int32_t format, const IndexInputPtr& input);
31
32 virtual ~SegmentInfo();
33
35
36public:
37 static const int32_t NO; // no norms; no deletes;
38 static const int32_t YES; // have norms; have deletes;
39 static const int32_t CHECK_DIR; // must check dir to see if there are norms/deletions
40 static const int32_t WITHOUT_GEN; // a file name that has no GEN in it.
41
42protected:
43 // true if this is a segments file written before lock-less commits (2.1)
45
46 // current generation of del file; NO if there are no deletes; CHECK_DIR if it's a pre-2.1 segment
47 // (and we must check filesystem); YES or higher if there are deletes at generation N
48 int64_t delGen;
49
50 // current generation of each field's norm file. If this array is null, for lockLess this means no
51 // separate norms. For preLockLess this means we must check filesystem. If this array is not null,
52 // its values mean: NO says this field has no separate norms; CHECK_DIR says it is a preLockLess
53 // segment and filesystem must be checked; >= YES says this field has separate norms with the
54 // specified generation
56
57 // NO if it is not; YES if it is; CHECK_DIR if it's pre-2.1 (ie, must check file system to see if
58 // <name>.cfs and <name>.nrm exist)
60
61 // true if this segment maintains norms in a single file; false otherwise this is currently false for
62 // segments populated by DocumentWriter and true for newly created merged segments (both compound and
63 // non compound).
65
66 // cached list of files that this segment uses in the Directory
68
69 // total byte size of all of our files (computed on demand)
70 int64_t _sizeInBytes;
71
72 // if this segment shares stored fields & vectors, this offset is where in that file this segment's
73 // docs begin
75
76 // name used to derive fields/vectors file we share with other segments
78
79 // whether doc store files are stored in compound file (*.cfx)
81
82 // How many deleted docs in this segment, or -1 if not yet known (if it's an older index)
83 int32_t delCount;
84
85 // True if this segment has any fields with omitTermFreqAndPositions == false
86 bool hasProx;
87
88 MapStringString diagnostics;
89
90public:
91 String name; // unique name in dir
92 int32_t docCount; // number of docs in seg
93 DirectoryPtr dir; // where segment resides
94
95public:
97 void reset(const SegmentInfoPtr& src);
98
99 void setDiagnostics(MapStringString diagnostics);
100 MapStringString getDiagnostics();
101
102 void setNumFields(int32_t numFields);
103
105 int64_t sizeInBytes();
106
110
112
114
117 bool hasSeparateNorms(int32_t fieldNumber);
118
121
124 void advanceNormGen(int32_t fieldIndex);
125
128 String getNormFileName(int32_t number);
129
132 void setUseCompoundFile(bool isCompoundFile);
133
136
137 int32_t getDelCount();
138 void setDelCount(int32_t delCount);
143 void setDocStoreOffset(int32_t offset);
144 void setDocStore(int32_t offset, const String& segment, bool isCompoundFile);
145
147 void write(const IndexOutputPtr& output);
148
149 void setHasProx(bool hasProx);
151
155
157 String segString(const DirectoryPtr& dir);
158
160 virtual bool equals(const LuceneObjectPtr& other);
161
162 virtual int32_t hashCode();
163
164protected:
165 void addIfExists(HashSet<String> files, const String& fileName);
166
169};
170
171}
172
173#endif
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Utility template class to handle hash set collections that can be safely copied and shared.
Definition HashSet.h:17
Base class for all Lucene classes.
Definition LuceneObject.h:31
Information about a segment such as it's name, directory, and files related to the segment.
Definition SegmentInfo.h:16
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Return clone of this object.
virtual int32_t hashCode()
Return hash code for this object.
void setDocStoreOffset(int32_t offset)
void write(const IndexOutputPtr &output)
Save this segment's info.
void advanceNormGen(int32_t fieldIndex)
Increment the generation count for the norms file for this field.
virtual bool equals(const LuceneObjectPtr &other)
We consider another SegmentInfo instance equal if it has the same dir and same name.
String name
Definition SegmentInfo.h:91
bool hasProx
Definition SegmentInfo.h:86
static const int32_t NO
Definition SegmentInfo.h:37
HashSet< String > files()
Return all files referenced by this SegmentInfo. The returns List is a locally cached List so you sho...
static const int32_t WITHOUT_GEN
Definition SegmentInfo.h:40
static const int32_t CHECK_DIR
Definition SegmentInfo.h:39
int32_t getDocStoreOffset()
SegmentInfo(const DirectoryPtr &dir, int32_t format, const IndexInputPtr &input)
Construct a new SegmentInfo instance by reading a previously saved SegmentInfo from input.
bool preLockless
Definition SegmentInfo.h:44
static const int32_t YES
Definition SegmentInfo.h:38
virtual ~SegmentInfo()
void setDocStore(int32_t offset, const String &segment, bool isCompoundFile)
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir)
bool getDocStoreIsCompoundFile()
DirectoryPtr dir
Definition SegmentInfo.h:93
bool hasSeparateNorms()
Returns true if any fields in this segment have separate norms.
void setUseCompoundFile(bool isCompoundFile)
Mark whether this segment is stored as a compound file.
String docStoreSegment
Definition SegmentInfo.h:77
void reset(const SegmentInfoPtr &src)
Copy everything from src SegmentInfo into our instance.
void setDiagnostics(MapStringString diagnostics)
void setNumFields(int32_t numFields)
int64_t sizeInBytes()
Returns total size in bytes of all of files used by this segment.
int32_t docStoreOffset
Definition SegmentInfo.h:74
bool hasSeparateNorms(int32_t fieldNumber)
Returns true if this field for this segment has saved a separate norms file (_<segment>_N....
MapStringString diagnostics
Definition SegmentInfo.h:88
void setHasProx(bool hasProx)
void setDocStoreIsCompoundFile(bool v)
HashSet< String > _files
Definition SegmentInfo.h:67
uint8_t isCompoundFile
Definition SegmentInfo.h:59
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir, bool isCompoundFile, bool hasSingleNormFile, int32_t docStoreOffset, const String &docStoreSegment, bool docStoreIsCompoundFile, bool hasProx)
bool hasSingleNormFile
Definition SegmentInfo.h:64
MapStringString getDiagnostics()
void addIfExists(HashSet< String > files, const String &fileName)
bool getUseCompoundFile()
Returns true if this segment is stored as a compound file; else, false.
int32_t docCount
Definition SegmentInfo.h:92
int64_t delGen
Definition SegmentInfo.h:48
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir, bool isCompoundFile, bool hasSingleNormFile)
void setDelCount(int32_t delCount)
String getNormFileName(int32_t number)
Get the file name for the norms file for this field.
String segString(const DirectoryPtr &dir)
Used for debugging.
String getDocStoreSegment()
void clearFiles()
Called whenever any change is made that affects which files this segment has.
int32_t delCount
Definition SegmentInfo.h:83
bool docStoreIsCompoundFile
Definition SegmentInfo.h:80
int64_t _sizeInBytes
Definition SegmentInfo.h:70
Collection< int64_t > normGen
Definition SegmentInfo.h:55
Definition AbstractAllTermDocs.h:12
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
boost::shared_ptr< SegmentInfo > SegmentInfoPtr
Definition LuceneTypes.h:208
boost::shared_ptr< IndexInput > IndexInputPtr
Definition LuceneTypes.h:493
boost::shared_ptr< Directory > DirectoryPtr
Definition LuceneTypes.h:489
boost::shared_ptr< IndexOutput > IndexOutputPtr
Definition LuceneTypes.h:494

clucene.sourceforge.net