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

Loading...
Searching...
No Matches
LogMergePolicy.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 LOGMERGEPOLICY_H
8#define LOGMERGEPOLICY_H
9
10#include "MergePolicy.h"
11
12 namespace Lucene {
13
24 class LPPAPI LogMergePolicy : public MergePolicy {
25 public:
26 LogMergePolicy(const IndexWriterPtr& writer);
27 virtual ~LogMergePolicy();
28
29 LUCENE_CLASS(LogMergePolicy);
30
31 protected:
32 int32_t mergeFactor;
33
34 double noCFSRatio;
35
36 bool calibrateSizeByDeletes;
37 bool _useCompoundFile;
38 bool _useCompoundDocStore;
39
40 public:
43 static const double LEVEL_LOG_SPAN;
44
46 static const int32_t DEFAULT_MERGE_FACTOR;
47
50 static const int32_t DEFAULT_MAX_MERGE_DOCS;
51
54 static const double DEFAULT_NO_CFS_RATIO;
55
56 int64_t minMergeSize;
57 int64_t maxMergeSize;
58 int32_t maxMergeDocs;
59
60 public:
62 double getNoCFSRatio();
63
66 void setNoCFSRatio(double noCFSRatio);
67
70 int32_t getMergeFactor();
71
77 void setMergeFactor(int32_t mergeFactor);
78
80 virtual bool useCompoundFile(const SegmentInfosPtr& segments, const SegmentInfoPtr& newSegment);
81
83 void setUseCompoundFile(bool useCompoundFile);
84
87 bool getUseCompoundFile();
88
90 virtual bool useCompoundDocStore(const SegmentInfosPtr& segments);
91
94 void setUseCompoundDocStore(bool useCompoundDocStore);
95
98 bool getUseCompoundDocStore();
99
102 void setCalibrateSizeByDeletes(bool calibrateSizeByDeletes);
103
106 bool getCalibrateSizeByDeletes();
107
109 virtual void close();
110
115 virtual MergeSpecificationPtr findMergesForOptimize(const SegmentInfosPtr& segmentInfos, int32_t maxSegmentCount, SetSegmentInfo segmentsToOptimize);
116
119 virtual MergeSpecificationPtr findMergesToExpungeDeletes(const SegmentInfosPtr& segmentInfos);
120
125 virtual MergeSpecificationPtr findMerges(const SegmentInfosPtr& segmentInfos);
126
135 void setMaxMergeDocs(int32_t maxMergeDocs);
136
139 int32_t getMaxMergeDocs();
140
141 protected:
142 bool verbose();
143 void message(const String& message);
144
145 virtual int64_t size(const SegmentInfoPtr& info) = 0;
146
147 int64_t sizeDocs(const SegmentInfoPtr& info);
148 int64_t sizeBytes(const SegmentInfoPtr& info);
149
150 bool isOptimized(const SegmentInfosPtr& infos, int32_t maxNumSegments, SetSegmentInfo segmentsToOptimize);
151
154 bool isOptimized(const SegmentInfoPtr& info);
155
156 OneMergePtr makeOneMerge(const SegmentInfosPtr& infos, const SegmentInfosPtr& infosToMerge);
157};
158
159}
160
161#endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
MergePolicy.h
Lucene::LogMergePolicy
This class implements a MergePolicy that tries to merge segments into levels of exponentially increas...
Definition LogMergePolicy.h:24
Lucene::LogMergePolicy::close
virtual void close()
Release all resources for the policy.
Lucene::LogMergePolicy::getUseCompoundFile
bool getUseCompoundFile()
Returns true if newly flushed and newly merge segments are written in compound file format.
Lucene::LogMergePolicy::useCompoundFile
virtual bool useCompoundFile(const SegmentInfosPtr &segments, const SegmentInfoPtr &newSegment)
Returns true if a newly flushed (not from merge) segment should use the compound file format.
Lucene::LogMergePolicy::isOptimized
bool isOptimized(const SegmentInfoPtr &info)
Returns true if this single info is optimized (has no pending norms or deletes, is in the same dir as...
Lucene::LogMergePolicy::sizeBytes
int64_t sizeBytes(const SegmentInfoPtr &info)
Lucene::LogMergePolicy::mergeFactor
int32_t mergeFactor
Definition LogMergePolicy.h:32
Lucene::LogMergePolicy::_useCompoundDocStore
bool _useCompoundDocStore
Definition LogMergePolicy.h:38
Lucene::LogMergePolicy::findMergesToExpungeDeletes
virtual MergeSpecificationPtr findMergesToExpungeDeletes(const SegmentInfosPtr &segmentInfos)
Finds merges necessary to expunge all deletes from the index. We simply merge adjacent segments that ...
Lucene::LogMergePolicy::makeOneMerge
OneMergePtr makeOneMerge(const SegmentInfosPtr &infos, const SegmentInfosPtr &infosToMerge)
Lucene::LogMergePolicy::~LogMergePolicy
virtual ~LogMergePolicy()
Lucene::LogMergePolicy::DEFAULT_MERGE_FACTOR
static const int32_t DEFAULT_MERGE_FACTOR
Default merge factor, which is how many segments are merged at a time.
Definition LogMergePolicy.h:46
Lucene::LogMergePolicy::LEVEL_LOG_SPAN
static const double LEVEL_LOG_SPAN
Defines the allowed range of log(size) for each level. A level is computed by taking the max segment ...
Definition LogMergePolicy.h:43
Lucene::LogMergePolicy::getUseCompoundDocStore
bool getUseCompoundDocStore()
Returns true if newly flushed and newly merge doc store segment files (term vectors and stored fields...
Lucene::LogMergePolicy::setCalibrateSizeByDeletes
void setCalibrateSizeByDeletes(bool calibrateSizeByDeletes)
Sets whether the segment size should be calibrated by the number of deletes when choosing segments fo...
Lucene::LogMergePolicy::LogMergePolicy
LogMergePolicy(const IndexWriterPtr &writer)
Lucene::LogMergePolicy::maxMergeSize
int64_t maxMergeSize
Definition LogMergePolicy.h:57
Lucene::LogMergePolicy::minMergeSize
int64_t minMergeSize
Definition LogMergePolicy.h:56
Lucene::LogMergePolicy::noCFSRatio
double noCFSRatio
Definition LogMergePolicy.h:34
Lucene::LogMergePolicy::setUseCompoundFile
void setUseCompoundFile(bool useCompoundFile)
Sets whether compound file format should be used for newly flushed and newly merged segments.
Lucene::LogMergePolicy::getMergeFactor
int32_t getMergeFactor()
Returns the number of segments that are merged at once and also controls the total number of segments...
Lucene::LogMergePolicy::isOptimized
bool isOptimized(const SegmentInfosPtr &infos, int32_t maxNumSegments, SetSegmentInfo segmentsToOptimize)
Lucene::LogMergePolicy::useCompoundDocStore
virtual bool useCompoundDocStore(const SegmentInfosPtr &segments)
Returns true if the doc store files should use the compound file format.
Lucene::LogMergePolicy::findMergesForOptimize
virtual MergeSpecificationPtr findMergesForOptimize(const SegmentInfosPtr &segmentInfos, int32_t maxSegmentCount, SetSegmentInfo segmentsToOptimize)
Returns the merges necessary to optimize the index. This merge policy defines "optimized" to mean onl...
Lucene::LogMergePolicy::setUseCompoundDocStore
void setUseCompoundDocStore(bool useCompoundDocStore)
Sets whether compound file format should be used for newly flushed and newly merged doc store segment...
Lucene::LogMergePolicy::_useCompoundFile
bool _useCompoundFile
Definition LogMergePolicy.h:37
Lucene::LogMergePolicy::message
void message(const String &message)
Lucene::LogMergePolicy::maxMergeDocs
int32_t maxMergeDocs
Definition LogMergePolicy.h:58
Lucene::LogMergePolicy::verbose
bool verbose()
Lucene::LogMergePolicy::size
virtual int64_t size(const SegmentInfoPtr &info)=0
Lucene::LogMergePolicy::getNoCFSRatio
double getNoCFSRatio()
Lucene::LogMergePolicy::calibrateSizeByDeletes
bool calibrateSizeByDeletes
Definition LogMergePolicy.h:36
Lucene::LogMergePolicy::setMaxMergeDocs
void setMaxMergeDocs(int32_t maxMergeDocs)
Determines the largest segment (measured by document count) that may be merged with other segments....
Lucene::LogMergePolicy::setNoCFSRatio
void setNoCFSRatio(double noCFSRatio)
If a merged segment will be more than this percentage of the total size of the index,...
Lucene::LogMergePolicy::DEFAULT_MAX_MERGE_DOCS
static const int32_t DEFAULT_MAX_MERGE_DOCS
Default maximum segment size. A segment of this size or larger will never be merged.
Definition LogMergePolicy.h:50
Lucene::LogMergePolicy::getCalibrateSizeByDeletes
bool getCalibrateSizeByDeletes()
Returns true if the segment size should be calibrated by the number of deletes when choosing segments...
Lucene::LogMergePolicy::setMergeFactor
void setMergeFactor(int32_t mergeFactor)
Determines how often segment indices are merged by addDocument(). With smaller values,...
Lucene::LogMergePolicy::findMerges
virtual MergeSpecificationPtr findMerges(const SegmentInfosPtr &segmentInfos)
Checks if any merges are now necessary and returns a MergePolicy.MergeSpecification if so....
Lucene::LogMergePolicy::getMaxMergeDocs
int32_t getMaxMergeDocs()
Returns the largest segment (measured by document count) that may be merged with other segments.
Lucene::LogMergePolicy::DEFAULT_NO_CFS_RATIO
static const double DEFAULT_NO_CFS_RATIO
Default noCFSRatio. If a merge's size is >= 10% of the index, then we disable compound file for it.
Definition LogMergePolicy.h:54
Lucene::LogMergePolicy::sizeDocs
int64_t sizeDocs(const SegmentInfoPtr &info)
Lucene::MergePolicy
A MergePolicy determines the sequence of primitive merge operations to be used for overall merge and ...
Definition MergePolicy.h:32
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::OneMergePtr
boost::shared_ptr< OneMerge > OneMergePtr
Definition LuceneTypes.h:192
Lucene::MergeSpecificationPtr
boost::shared_ptr< MergeSpecification > MergeSpecificationPtr
Definition LuceneTypes.h:176
Lucene::SegmentInfoPtr
boost::shared_ptr< SegmentInfo > SegmentInfoPtr
Definition LuceneTypes.h:208
Lucene::SegmentInfosPtr
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition LuceneTypes.h:210
Lucene::IndexWriterPtr
boost::shared_ptr< IndexWriter > IndexWriterPtr
Definition LuceneTypes.h:160

clucene.sourceforge.net