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


IndexFileDeleter.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 INDEXFILEDELETER_H
8 #define INDEXFILEDELETER_H
9 
10 #include "IndexCommit.h"
11 
12 namespace Lucene {
13 
35 public:
39  virtual ~IndexFileDeleter();
40 
42 
43 protected:
47 
49  MapStringRefCount refCounts;
50 
55 
58 
61 
66 
69 
71  static bool VERBOSE_REF_COUNTS;
72 
73 public:
75 
76 protected:
77  void message(const String& message);
78 
80  void deleteCommits();
81 
82  void deletePendingFiles();
83 
84  RefCountPtr getRefCount(const String& fileName);
85 
86 public:
87  void setInfoStream(const InfoStreamPtr& infoStream);
88 
90 
94  void refresh(const String& segmentName);
95  void refresh();
96 
97  void close();
98 
110  void checkpoint(const SegmentInfosPtr& segmentInfos, bool isCommit);
111 
112  void incRef(const SegmentInfosPtr& segmentInfos, bool isCommit);
113  void incRef(HashSet<String> files);
114  void incRef(const String& fileName);
115  void decRef(HashSet<String> files);
116  void decRef(const String& fileName);
117  void decRef(const SegmentInfosPtr& segmentInfos);
118 
119  bool exists(const String& fileName);
120 
121  void deleteFiles(HashSet<String> files);
122 
124  void deleteNewFiles(HashSet<String> files);
125 
126  void deleteFile(const String& fileName);
127 };
128 
130 class RefCount : public LuceneObject {
131 public:
132  RefCount(const String& fileName);
133  virtual ~RefCount();
134 
136 
137 public:
138  String fileName; // fileName used only for better assert error messages
139  bool initDone;
140  int32_t count;
141 
142 public:
143  int32_t IncRef();
144  int32_t DecRef();
145 };
146 
149 class CommitPoint : public IndexCommit {
150 public:
152  virtual ~CommitPoint();
153 
155 
156 public:
157  int64_t gen;
160  bool deleted;
163  int64_t version;
164  int64_t generation;
166  MapStringString userData;
167 
168 public:
169  virtual String toString();
170 
172  virtual bool isOptimized();
173 
175  virtual String getSegmentsFileName();
176 
178  virtual HashSet<String> getFileNames();
179 
181  virtual DirectoryPtr getDirectory();
182 
184  virtual int64_t getVersion();
185 
187  virtual int64_t getGeneration();
188 
190  virtual MapStringString getUserData();
191 
193  virtual void deleteCommit();
194 
195  virtual bool isDeleted();
196 
197  virtual int32_t compareTo(const LuceneObjectPtr& other);
198 };
199 
200 }
201 
202 #endif
DirectoryPtr directory
Definition: IndexFileDeleter.h:63
String segmentsFileName
Definition: IndexFileDeleter.h:159
bool startingCommitDeleted
Definition: IndexFileDeleter.h:74
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition: LuceneTypes.h:532
Tracks the reference count for a single index file.
Definition: IndexFileDeleter.h:130
Holds details for each commit point. This class is also passed to the deletion policy. Note: this class has a natural ordering that is inconsistent with equals.
Definition: IndexFileDeleter.h:149
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
virtual int32_t compareTo(const LuceneObjectPtr &other)
Compare two objects.
bool exists(const String &fileName)
int64_t version
Definition: IndexFileDeleter.h:163
bool _isOptimized
Definition: IndexFileDeleter.h:165
void decRef(HashSet< String > files)
static bool VERBOSE_REF_COUNTS
Change to true to see details of reference counts when infoStream != null.
Definition: IndexFileDeleter.h:71
SegmentInfosPtr lastSegmentInfos
Definition: IndexFileDeleter.h:67
RefCountPtr getRefCount(const String &fileName)
Represents a single commit into an index as seen by the IndexDeletionPolicy or IndexReader.
Definition: IndexCommit.h:22
boost::shared_ptr< RefCount > RefCountPtr
Definition: LuceneTypes.h:206
HashSet< String > deletable
Files that we tried to delete but failed (likely because they are open and we are running on Windows)...
Definition: IndexFileDeleter.h:41
IndexFileDeleter(const DirectoryPtr &directory, const IndexDeletionPolicyPtr &policy, const SegmentInfosPtr &segmentInfos, const InfoStreamPtr &infoStream, const DocumentsWriterPtr &docWriter, HashSet< String > synced)
Initialize the deleter: find all previous commits in the Directory, incref the files they reference...
IndexDeletionPolicyPtr policy
Definition: IndexFileDeleter.h:64
MapStringString userData
Definition: IndexFileDeleter.h:166
void deleteFiles(HashSet< String > files)
Collection< CommitPointPtr > commitsToDelete
Commits that the IndexDeletionPolicy have decided to delete.
Definition: IndexFileDeleter.h:60
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition: LuceneTypes.h:210
boost::shared_ptr< DocumentsWriter > DocumentsWriterPtr
Definition: LuceneTypes.h:123
SegmentInfosPtr getLastSegmentInfos()
boost::shared_ptr< IndexDeletionPolicy > IndexDeletionPolicyPtr
Definition: LuceneTypes.h:153
HashSet< String > synced
Definition: IndexFileDeleter.h:68
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Collection< IndexCommitPtr > commits
Holds all commits (segments_N) currently in the index. This will have just 1 commit if you are using ...
Definition: IndexFileDeleter.h:54
Base class for all Lucene classes.
Definition: LuceneObject.h:31
void incRef(const SegmentInfosPtr &segmentInfos, bool isCommit)
void deleteFile(const String &fileName)
int64_t generation
Definition: IndexFileDeleter.h:164
bool deleted
Definition: IndexFileDeleter.h:160
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
virtual String toString()
Returns a string representation of the object.
Definition: AbstractAllTermDocs.h:12
void message(const String &message)
Collection< HashSet< String > > lastFiles
Holds files we had incref&#39;d from the previous non-commit checkpoint.
Definition: IndexFileDeleter.h:57
int32_t count
Definition: IndexFileDeleter.h:140
void setInfoStream(const InfoStreamPtr &infoStream)
DocumentsWriterPtr docWriter
Definition: IndexFileDeleter.h:65
void checkpoint(const SegmentInfosPtr &segmentInfos, bool isCommit)
For definition of "check point" see IndexWriter comments: "Clarification: Check Points (and commits)"...
void deleteNewFiles(HashSet< String > files)
Deletes the specified files, but only if they are new (have not yet been incref&#39;d).
void deleteCommits()
Remove the CommitPoints in the commitsToDelete List by DecRef&#39;ing all files from each SegmentInfos...
Collection< CommitPointPtr > commitsToDelete
Definition: IndexFileDeleter.h:162
MapStringRefCount refCounts
Reference count for all files in the index. Counts how many existing commits reference a file...
Definition: IndexFileDeleter.h:49
InfoStreamPtr infoStream
Definition: IndexFileDeleter.h:62
HashSet< String > files
Definition: IndexFileDeleter.h:158
bool initDone
Definition: IndexFileDeleter.h:139
DirectoryPtr directory
Definition: IndexFileDeleter.h:161
This class keeps track of each SegmentInfos instance that is still "live", either because it correspo...
Definition: IndexFileDeleter.h:34

clucene.sourceforge.net