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.
5 /////////////////////////////////////////////////////////////////////////////
6 
7 #ifndef LOGDOCMERGEPOLICY_H
8 #define LOGDOCMERGEPOLICY_H
9 
10 #include "LogMergePolicy.h"
11 
12 namespace Lucene {
13 
14 /// This is a {@link LogMergePolicy} that measures size of a segment as the number of documents
15 /// (not taking deletions into account).
16 class LPPAPI LogDocMergePolicy : public LogMergePolicy {
17 public:
18     LogDocMergePolicy(const IndexWriterPtr& writer);
19     virtual ~LogDocMergePolicy();
20 
21     LUCENE_CLASS(LogDocMergePolicy);
22 
23 public:
24     /// Default minimum segment size.  @see setMinMergeDocs
25     static const int32_t DEFAULT_MIN_MERGE_DOCS;
26 
27 protected:
28     virtual int64_t size(const SegmentInfoPtr& info);
29 
30 public:
31     /// Sets the minimum size for the lowest level segments. Any segments below this size are considered
32     /// to be on the same level (even if they vary drastically in size) and will be merged whenever there
33     /// are mergeFactor of them.  This effectively truncates the "long tail" of small segments that would
34     /// otherwise be created into a single level.  If you set this too large, it could greatly increase the
35     /// merging cost during indexing (if you flush many small segments).
36     void setMinMergeDocs(int32_t minMergeDocs);
37 
38     /// Get the minimum size for a segment to remain un-merged. @see #setMinMergeDocs
39     int32_t getMinMergeDocs();
40 };
41 
42 }
43 
44 #endif
45