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

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SegmentReader.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 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 SEGMENTREADER_H
8 #define SEGMENTREADER_H
9
10 #include "IndexReader.h"
11 #include "CloseableThreadLocal.h"
12
13 namespace Lucene
14 {
15 class LPPAPI SegmentReader : public IndexReader
16 {
17 public:
18 SegmentReader();
19 virtual ~SegmentReader();
20
21 LUCENE_CLASS(SegmentReader);
22
23 protected:
24 bool readOnly;
25
26 INTERNAL:
27 BitVectorPtr deletedDocs;
28 SegmentReaderRefPtr deletedDocsRef;
29 CoreReadersPtr core;
30 FieldsReaderLocalPtr fieldsReaderLocal;
31 SegmentInfoPtr rollbackSegmentInfo;
32 CloseableThreadLocal<TermVectorsReader> termVectorsLocal;
33 FieldInfosPtr fieldInfos();
34
37 TermVectorsReaderPtr getTermVectorsReader();
38
39 TermVectorsReaderPtr getTermVectorsReaderOrig();
40 FieldsReaderPtr getFieldsReader();
41 MapStringNorm _norms;
42
43 private:
44 SegmentInfoPtr si;
45 int32_t readBufferSize;
46 bool deletedDocsDirty;
47 bool normsDirty;
48 int32_t pendingDeleteCount;
49
50 bool rollbackHasChanges;
51 bool rollbackDeletedDocsDirty;
52 bool rollbackNormsDirty;
53 int32_t rollbackPendingDeleteCount;
54
55 // optionally used for the .nrm file shared by multiple norms
56 IndexInputPtr singleNormStream;
57 SegmentReaderRefPtr singleNormRef;
58
59 public:
60 virtual void initialize();
61
62 using IndexReader::document;
63 using IndexReader::termPositions;
64
65 static SegmentReaderPtr get(bool readOnly, SegmentInfoPtr si, int32_t termInfosIndexDivisor);
66 static SegmentReaderPtr get(bool readOnly, DirectoryPtr dir, SegmentInfoPtr si, int32_t readBufferSize, bool doOpenStores, int32_t termInfosIndexDivisor);
67
68 void openDocStores();
69
70 virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
71 virtual LuceneObjectPtr clone(bool openReadOnly, LuceneObjectPtr other = LuceneObjectPtr());
72 SegmentReaderPtr reopenSegment(SegmentInfoPtr si, bool doClone, bool openReadOnly);
73
74 static bool hasDeletions(SegmentInfoPtr si);
75
77 virtual bool hasDeletions();
78
79 static bool usesCompoundFile(SegmentInfoPtr si);
80 static bool hasSeparateNorms(SegmentInfoPtr si);
81
82 HashSet<String> files();
83
85 virtual TermEnumPtr terms();
86
88 virtual TermEnumPtr terms(TermPtr t);
89
91 virtual DocumentPtr document(int32_t n, FieldSelectorPtr fieldSelector);
92
94 virtual bool isDeleted(int32_t n);
95
97 virtual TermDocsPtr termDocs(TermPtr term);
98
100 virtual TermDocsPtr termDocs();
101
103 virtual TermPositionsPtr termPositions();
104
106 virtual int32_t docFreq(TermPtr t);
107
109 virtual int32_t numDocs();
110
112 virtual int32_t maxDoc();
113
115 virtual HashSet<String> getFieldNames(FieldOption fieldOption);
116
118 virtual bool hasNorms(const String& field);
119
121 virtual ByteArray norms(const String& field);
122
124 virtual void norms(const String& field, ByteArray norms, int32_t offset);
125
126 bool termsIndexLoaded();
127
130 void loadTermsIndex(int32_t termsIndexDivisor);
131
132 bool normsClosed(); // for testing only
133 bool normsClosed(const String& field); // for testing only
134
138 virtual TermFreqVectorPtr getTermFreqVector(int32_t docNumber, const String& field);
139
142 virtual void getTermFreqVector(int32_t docNumber, const String& field, TermVectorMapperPtr mapper);
143
145 virtual void getTermFreqVector(int32_t docNumber, TermVectorMapperPtr mapper);
146
150 virtual Collection<TermFreqVectorPtr> getTermFreqVectors(int32_t docNumber);
151
153 String getSegmentName();
154
156 SegmentInfoPtr getSegmentInfo();
157 void setSegmentInfo(SegmentInfoPtr info);
158
159 void startCommit();
160 void rollbackCommit();
161
163 virtual DirectoryPtr directory();
164
167 virtual LuceneObjectPtr getFieldCacheKey();
168 virtual LuceneObjectPtr getDeletesCacheKey();
169
171 virtual int64_t getUniqueTermCount();
172
173 static SegmentReaderPtr getOnlySegmentReader(DirectoryPtr dir);
174 static SegmentReaderPtr getOnlySegmentReader(IndexReaderPtr reader);
175
176 virtual int32_t getTermInfosIndexDivisor();
177
178 protected:
179 bool checkDeletedCounts();
180 void loadDeletedDocs();
181
185 virtual ByteArray cloneNormBytes(ByteArray bytes);
186
190 virtual BitVectorPtr cloneDeletedDocs(BitVectorPtr bv);
191
193 virtual void doCommit(MapStringString commitUserData);
194
195 virtual void commitChanges(MapStringString commitUserData);
196
198 virtual void doClose();
199
202 virtual void doDelete(int32_t docNum);
203
205 virtual void doUndeleteAll();
206
208 ByteArray getNorms(const String& field);
209
211 virtual void doSetNorm(int32_t doc, const String& field, uint8_t value);
212
213 void openNorms(DirectoryPtr cfsDir, int32_t readBufferSize);
214
215 friend class ReaderPool;
216 friend class IndexWriter;
217 friend class Norm;
218 };
219 }
220
221 #endif

clucene.sourceforge.net