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

Loading...
Searching...
No Matches
IndexFileDeleter.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 INDEXFILEDELETER_H
8#define INDEXFILEDELETER_H
9
10#include "IndexCommit.h"
11
12 namespace Lucene {
13
34 class LPPAPI IndexFileDeleter : public LuceneObject {
35 public:
38 IndexFileDeleter(const DirectoryPtr& directory, const IndexDeletionPolicyPtr& policy, const SegmentInfosPtr& segmentInfos, const InfoStreamPtr& infoStream, const DocumentsWriterPtr& docWriter, HashSet<String> synced);
39 virtual ~IndexFileDeleter();
40
41 LUCENE_CLASS(IndexFileDeleter);
42
43 protected:
46 HashSet<String> deletable;
47
49 MapStringRefCount refCounts;
50
54 Collection<IndexCommitPtr> commits;
55
57 Collection< HashSet<String> > lastFiles;
58
60 Collection<CommitPointPtr> commitsToDelete;
61
62 InfoStreamPtr infoStream;
63 DirectoryPtr directory;
64 IndexDeletionPolicyPtr policy;
65 DocumentsWriterPtr docWriter;
66
67 SegmentInfosPtr lastSegmentInfos;
68 HashSet<String> synced;
69
71 static bool VERBOSE_REF_COUNTS;
72
73 public:
74 bool startingCommitDeleted;
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
89 SegmentInfosPtr getLastSegmentInfos();
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
135 LUCENE_CLASS(RefCount);
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:
151 CommitPoint(Collection<CommitPointPtr> commitsToDelete, const DirectoryPtr& directory, const SegmentInfosPtr& segmentInfos);
152 virtual ~CommitPoint();
153
154 LUCENE_CLASS(CommitPoint);
155
156 public:
157 int64_t gen;
158 HashSet<String> files;
159 String segmentsFileName;
160 bool deleted;
161 DirectoryPtr directory;
162 Collection<CommitPointPtr> commitsToDelete;
163 int64_t version;
164 int64_t generation;
165 bool _isOptimized;
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
IndexCommit.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::CommitPoint
Holds details for each commit point. This class is also passed to the deletion policy....
Definition IndexFileDeleter.h:149
Lucene::CommitPoint::commitsToDelete
Collection< CommitPointPtr > commitsToDelete
Definition IndexFileDeleter.h:162
Lucene::CommitPoint::_isOptimized
bool _isOptimized
Definition IndexFileDeleter.h:165
Lucene::CommitPoint::deleted
bool deleted
Definition IndexFileDeleter.h:160
Lucene::CommitPoint::files
HashSet< String > files
Definition IndexFileDeleter.h:158
Lucene::CommitPoint::generation
int64_t generation
Definition IndexFileDeleter.h:164
Lucene::CommitPoint::isOptimized
virtual bool isOptimized()
Returns true if this commit is an optimized index.
Lucene::CommitPoint::directory
DirectoryPtr directory
Definition IndexFileDeleter.h:161
Lucene::CommitPoint::version
int64_t version
Definition IndexFileDeleter.h:163
Lucene::CommitPoint::CommitPoint
CommitPoint(Collection< CommitPointPtr > commitsToDelete, const DirectoryPtr &directory, const SegmentInfosPtr &segmentInfos)
Lucene::CommitPoint::getVersion
virtual int64_t getVersion()
Returns the version for this IndexCommit.
Lucene::CommitPoint::segmentsFileName
String segmentsFileName
Definition IndexFileDeleter.h:159
Lucene::CommitPoint::toString
virtual String toString()
Returns a string representation of the object.
Lucene::CommitPoint::isDeleted
virtual bool isDeleted()
Lucene::CommitPoint::userData
MapStringString userData
Definition IndexFileDeleter.h:166
Lucene::CommitPoint::deleteCommit
virtual void deleteCommit()
Called only be the deletion policy, to remove this commit point from the index.
Lucene::CommitPoint::getUserData
virtual MapStringString getUserData()
Returns userData, previously passed to IndexWriter#commit(Map) for this commit.
Lucene::CommitPoint::getDirectory
virtual DirectoryPtr getDirectory()
Returns the Directory for the index.
Lucene::CommitPoint::getFileNames
virtual HashSet< String > getFileNames()
Returns all index files referenced by this commit point.
Lucene::CommitPoint::gen
int64_t gen
Definition IndexFileDeleter.h:157
Lucene::CommitPoint::getSegmentsFileName
virtual String getSegmentsFileName()
Get the segments file (segments_N) associated with this commit point.
Lucene::CommitPoint::getGeneration
virtual int64_t getGeneration()
Returns the generation (the _N in segments_N) for this IndexCommit.
Lucene::CommitPoint::~CommitPoint
virtual ~CommitPoint()
Lucene::CommitPoint::compareTo
virtual int32_t compareTo(const LuceneObjectPtr &other)
Compare two objects.
Lucene::HashSet
Utility template class to handle hash set collections that can be safely copied and shared.
Definition HashSet.h:17
Lucene::IndexCommit
Represents a single commit into an index as seen by the IndexDeletionPolicy or IndexReader.
Definition IndexCommit.h:22
Lucene::IndexFileDeleter
This class keeps track of each SegmentInfos instance that is still "live", either because it correspo...
Definition IndexFileDeleter.h:34
Lucene::IndexFileDeleter::refresh
void refresh(const String &segmentName)
Writer calls this when it has hit an error and had to roll back, to tell us that there may now be unr...
Lucene::IndexFileDeleter::getRefCount
RefCountPtr getRefCount(const String &fileName)
Lucene::IndexFileDeleter::incRef
void incRef(const String &fileName)
Lucene::IndexFileDeleter::deletePendingFiles
void deletePendingFiles()
Lucene::IndexFileDeleter::~IndexFileDeleter
virtual ~IndexFileDeleter()
Lucene::IndexFileDeleter::IndexFileDeleter
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,...
Lucene::IndexFileDeleter::exists
bool exists(const String &fileName)
Lucene::IndexFileDeleter::lastFiles
Collection< HashSet< String > > lastFiles
Holds files we had incref'd from the previous non-commit checkpoint.
Definition IndexFileDeleter.h:57
Lucene::IndexFileDeleter::directory
DirectoryPtr directory
Definition IndexFileDeleter.h:63
Lucene::IndexFileDeleter::message
void message(const String &message)
Lucene::IndexFileDeleter::getLastSegmentInfos
SegmentInfosPtr getLastSegmentInfos()
Lucene::IndexFileDeleter::synced
HashSet< String > synced
Definition IndexFileDeleter.h:68
Lucene::IndexFileDeleter::incRef
void incRef(HashSet< String > files)
Lucene::IndexFileDeleter::setInfoStream
void setInfoStream(const InfoStreamPtr &infoStream)
Lucene::IndexFileDeleter::policy
IndexDeletionPolicyPtr policy
Definition IndexFileDeleter.h:64
Lucene::IndexFileDeleter::commits
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
Lucene::IndexFileDeleter::deleteFile
void deleteFile(const String &fileName)
Lucene::IndexFileDeleter::close
void close()
Lucene::IndexFileDeleter::commitsToDelete
Collection< CommitPointPtr > commitsToDelete
Commits that the IndexDeletionPolicy have decided to delete.
Definition IndexFileDeleter.h:60
Lucene::IndexFileDeleter::deletable
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:46
Lucene::IndexFileDeleter::decRef
void decRef(const String &fileName)
Lucene::IndexFileDeleter::deleteNewFiles
void deleteNewFiles(HashSet< String > files)
Deletes the specified files, but only if they are new (have not yet been incref'd).
Lucene::IndexFileDeleter::decRef
void decRef(HashSet< String > files)
Lucene::IndexFileDeleter::deleteFiles
void deleteFiles(HashSet< String > files)
Lucene::IndexFileDeleter::infoStream
InfoStreamPtr infoStream
Definition IndexFileDeleter.h:62
Lucene::IndexFileDeleter::deleteCommits
void deleteCommits()
Remove the CommitPoints in the commitsToDelete List by DecRef'ing all files from each SegmentInfos.
Lucene::IndexFileDeleter::VERBOSE_REF_COUNTS
static bool VERBOSE_REF_COUNTS
Change to true to see details of reference counts when infoStream != null.
Definition IndexFileDeleter.h:71
Lucene::IndexFileDeleter::incRef
void incRef(const SegmentInfosPtr &segmentInfos, bool isCommit)
Lucene::IndexFileDeleter::decRef
void decRef(const SegmentInfosPtr &segmentInfos)
Lucene::IndexFileDeleter::checkpoint
void checkpoint(const SegmentInfosPtr &segmentInfos, bool isCommit)
For definition of "check point" see IndexWriter comments: "Clarification: Check Points (and commits)"...
Lucene::IndexFileDeleter::refresh
void refresh()
Lucene::IndexFileDeleter::lastSegmentInfos
SegmentInfosPtr lastSegmentInfos
Definition IndexFileDeleter.h:67
Lucene::IndexFileDeleter::startingCommitDeleted
bool startingCommitDeleted
Definition IndexFileDeleter.h:74
Lucene::IndexFileDeleter::docWriter
DocumentsWriterPtr docWriter
Definition IndexFileDeleter.h:65
Lucene::IndexFileDeleter::refCounts
MapStringRefCount refCounts
Reference count for all files in the index. Counts how many existing commits reference a file.
Definition IndexFileDeleter.h:49
Lucene::LuceneObject
Base class for all Lucene classes.
Definition LuceneObject.h:31
Lucene::RefCount
Tracks the reference count for a single index file.
Definition IndexFileDeleter.h:130
Lucene::RefCount::count
int32_t count
Definition IndexFileDeleter.h:140
Lucene::RefCount::initDone
bool initDone
Definition IndexFileDeleter.h:139
Lucene::RefCount::fileName
String fileName
Definition IndexFileDeleter.h:138
Lucene::RefCount::RefCount
RefCount(const String &fileName)
Lucene::RefCount::IncRef
int32_t IncRef()
Lucene::RefCount::~RefCount
virtual ~RefCount()
Lucene::RefCount::DecRef
int32_t DecRef()
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::InfoStreamPtr
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition LuceneTypes.h:532
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::DocumentsWriterPtr
boost::shared_ptr< DocumentsWriter > DocumentsWriterPtr
Definition LuceneTypes.h:123
Lucene::RefCountPtr
boost::shared_ptr< RefCount > RefCountPtr
Definition LuceneTypes.h:206
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition LuceneTypes.h:489
Lucene::IndexDeletionPolicyPtr
boost::shared_ptr< IndexDeletionPolicy > IndexDeletionPolicyPtr
Definition LuceneTypes.h:153
Lucene::SegmentInfosPtr
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition LuceneTypes.h:210

clucene.sourceforge.net