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


SegmentInfo.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 SEGMENTINFO_H
8 #define SEGMENTINFO_H
9 
10 #include "LuceneObject.h"
11 
12 namespace Lucene {
13 
16 class LPPAPI SegmentInfo : public LuceneObject {
17 public:
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 
36 public:
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 
42 protected:
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)
59  uint8_t isCompoundFile;
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
74  int32_t docStoreOffset;
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 
90 public:
91  String name; // unique name in dir
92  int32_t docCount; // number of docs in seg
93  DirectoryPtr dir; // where segment resides
94 
95 public:
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 
107  bool hasDeletions();
109  void clearDelGen();
110 
112 
113  String getDelFileName();
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);
139  int32_t getDocStoreOffset();
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);
150  bool getHasProx();
151 
155 
157  String segString(const DirectoryPtr& dir);
158 
160  virtual bool equals(const LuceneObjectPtr& other);
161 
162  virtual int32_t hashCode();
163 
164 protected:
165  void addIfExists(HashSet<String> files, const String& fileName);
166 
168  void clearFiles();
169 };
170 
171 }
172 
173 #endif
Lucene::SegmentInfo::setNumFields
void setNumFields(int32_t numFields)
Lucene::SegmentInfo::addIfExists
void addIfExists(HashSet< String > files, const String &fileName)
Lucene::SegmentInfo::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Return clone of this object.
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::SegmentInfo::getDiagnostics
MapStringString getDiagnostics()
Lucene::SegmentInfo::isCompoundFile
uint8_t isCompoundFile
Definition: SegmentInfo.h:59
Lucene::SegmentInfo::YES
static const int32_t YES
Definition: SegmentInfo.h:38
Lucene::SegmentInfo::dir
DirectoryPtr dir
Definition: SegmentInfo.h:93
Lucene::SegmentInfo::clearDelGen
void clearDelGen()
Lucene::Collection< int64_t >
Lucene::SegmentInfo::~SegmentInfo
virtual ~SegmentInfo()
Lucene::SegmentInfoPtr
boost::shared_ptr< SegmentInfo > SegmentInfoPtr
Definition: LuceneTypes.h:208
Lucene::SegmentInfo::SegmentInfo
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir, bool isCompoundFile, bool hasSingleNormFile, int32_t docStoreOffset, const String &docStoreSegment, bool docStoreIsCompoundFile, bool hasProx)
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::SegmentInfo::docStoreSegment
String docStoreSegment
Definition: SegmentInfo.h:77
Lucene::SegmentInfo::docStoreIsCompoundFile
bool docStoreIsCompoundFile
Definition: SegmentInfo.h:80
Lucene::SegmentInfo::SegmentInfo
SegmentInfo(const DirectoryPtr &dir, int32_t format, const IndexInputPtr &input)
Construct a new SegmentInfo instance by reading a previously saved SegmentInfo from input.
Lucene::SegmentInfo::equals
virtual bool equals(const LuceneObjectPtr &other)
We consider another SegmentInfo instance equal if it has the same dir and same name.
Lucene::SegmentInfo::hasDeletions
bool hasDeletions()
Lucene::SegmentInfo::getDelFileName
String getDelFileName()
Lucene::SegmentInfo::segString
String segString(const DirectoryPtr &dir)
Used for debugging.
Lucene::SegmentInfo::setUseCompoundFile
void setUseCompoundFile(bool isCompoundFile)
Mark whether this segment is stored as a compound file.
Lucene::SegmentInfo::name
String name
Definition: SegmentInfo.h:91
Lucene::SegmentInfo::normGen
Collection< int64_t > normGen
Definition: SegmentInfo.h:55
Lucene::SegmentInfo::_sizeInBytes
int64_t _sizeInBytes
Definition: SegmentInfo.h:70
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::SegmentInfo::advanceDelGen
void advanceDelGen()
Lucene::SegmentInfo::getUseCompoundFile
bool getUseCompoundFile()
Returns true if this segment is stored as a compound file; else, false.
Lucene::SegmentInfo::diagnostics
MapStringString diagnostics
Definition: SegmentInfo.h:88
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::SegmentInfo::hasProx
bool hasProx
Definition: SegmentInfo.h:86
Lucene::SegmentInfo::getDocStoreIsCompoundFile
bool getDocStoreIsCompoundFile()
Lucene::SegmentInfo::advanceNormGen
void advanceNormGen(int32_t fieldIndex)
Increment the generation count for the norms file for this field.
Lucene::SegmentInfo::WITHOUT_GEN
static const int32_t WITHOUT_GEN
Definition: SegmentInfo.h:40
Lucene::SegmentInfo::setDiagnostics
void setDiagnostics(MapStringString diagnostics)
Lucene::SegmentInfo::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::SegmentInfo::SegmentInfo
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir)
Lucene::SegmentInfo::delGen
int64_t delGen
Definition: SegmentInfo.h:48
Lucene::IndexInputPtr
boost::shared_ptr< IndexInput > IndexInputPtr
Definition: LuceneTypes.h:493
Lucene::SegmentInfo::docCount
int32_t docCount
Definition: SegmentInfo.h:92
Lucene::SegmentInfo::hasSingleNormFile
bool hasSingleNormFile
Definition: SegmentInfo.h:64
Lucene::SegmentInfo::_files
HashSet< String > _files
Definition: SegmentInfo.h:67
Lucene::SegmentInfo::write
void write(const IndexOutputPtr &output)
Save this segment's info.
Lucene::HashSet< String >
Lucene::SegmentInfo::CHECK_DIR
static const int32_t CHECK_DIR
Definition: SegmentInfo.h:39
Lucene::SegmentInfo::setDocStoreOffset
void setDocStoreOffset(int32_t offset)
Lucene::SegmentInfo::files
HashSet< String > files()
Return all files referenced by this SegmentInfo. The returns List is a locally cached List so you sho...
Lucene::SegmentInfo::setDocStoreIsCompoundFile
void setDocStoreIsCompoundFile(bool v)
Lucene::SegmentInfo::sizeInBytes
int64_t sizeInBytes()
Returns total size in bytes of all of files used by this segment.
Lucene::SegmentInfo::setHasProx
void setHasProx(bool hasProx)
Lucene::SegmentInfo::SegmentInfo
SegmentInfo(const String &name, int32_t docCount, const DirectoryPtr &dir, bool isCompoundFile, bool hasSingleNormFile)
Lucene::SegmentInfo::getDocStoreSegment
String getDocStoreSegment()
Lucene::SegmentInfo::getNormFileName
String getNormFileName(int32_t number)
Get the file name for the norms file for this field.
Lucene::SegmentInfo::setDocStore
void setDocStore(int32_t offset, const String &segment, bool isCompoundFile)
Lucene::SegmentInfo::hasSeparateNorms
bool hasSeparateNorms()
Returns true if any fields in this segment have separate norms.
Lucene::SegmentInfo::getDelCount
int32_t getDelCount()
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::SegmentInfo::preLockless
bool preLockless
Definition: SegmentInfo.h:44
Lucene::SegmentInfo::docStoreOffset
int32_t docStoreOffset
Definition: SegmentInfo.h:74
Lucene::SegmentInfo::hasSeparateNorms
bool hasSeparateNorms(int32_t fieldNumber)
Returns true if this field for this segment has saved a separate norms file (_<segment>_N....
Lucene::SegmentInfo::getDocStoreOffset
int32_t getDocStoreOffset()
Lucene::SegmentInfo::getHasProx
bool getHasProx()
Lucene::SegmentInfo::delCount
int32_t delCount
Definition: SegmentInfo.h:83
Lucene::SegmentInfo::clearFiles
void clearFiles()
Called whenever any change is made that affects which files this segment has.
Lucene::SegmentInfo
Information about a segment such as it's name, directory, and files related to the segment.
Definition: SegmentInfo.h:16
Lucene::SegmentInfo::setDelCount
void setDelCount(int32_t delCount)
Lucene::SegmentInfo::reset
void reset(const SegmentInfoPtr &src)
Copy everything from src SegmentInfo into our instance.
Lucene::IndexOutputPtr
boost::shared_ptr< IndexOutput > IndexOutputPtr
Definition: LuceneTypes.h:494
Lucene::SegmentInfo::NO
static const int32_t NO
Definition: SegmentInfo.h:34
LuceneObject.h

clucene.sourceforge.net