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

SegmentMerger.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 SEGMENTMERGER_H
8 #define SEGMENTMERGER_H
9
10 #include "LuceneObject.h"
11
12 namespace Lucene {
13
20 class LPPAPI SegmentMerger : public LuceneObject {
21 public:
22 SegmentMerger(const DirectoryPtr& dir, const String& name);
23 SegmentMerger(const IndexWriterPtr& writer, const String& name, const OneMergePtr& merge);
24 virtual ~SegmentMerger();
25
26 LUCENE_CLASS(SegmentMerger);
27
28 protected:
29 DirectoryPtr directory;
30 String segment;
31 int32_t termIndexInterval;
32
33 Collection<IndexReaderPtr> readers;
34 FieldInfosPtr fieldInfos;
35
36 int32_t mergedDocs;
37 CheckAbortPtr checkAbort;
38
41 bool mergeDocStores;
42
44 static const int32_t MAX_RAW_MERGE_DOCS;
45
46 Collection<SegmentReaderPtr> matchingSegmentReaders;
47 Collection<int32_t> rawDocLengths;
48 Collection<int32_t> rawDocLengths2;
49
50 SegmentMergeQueuePtr queue;
51 bool omitTermFreqAndPositions;
52
53 ByteArray payloadBuffer;
54 Collection< Collection<int32_t> > docMaps;
55 Collection<int32_t> delCounts;
56
57 public:
59 static const uint8_t NORMS_HEADER[];
60 static const int32_t NORMS_HEADER_LENGTH;
61
62 public:
63 bool hasProx();
64
66 void add(const IndexReaderPtr& reader);
67
70 IndexReaderPtr segmentReader(int32_t i);
71
74 int32_t merge();
75
79 int32_t merge(bool mergeDocStores);
80
82 void closeReaders();
83
84 HashSet<String> getMergedFiles();
85 HashSet<String> createCompoundFile(const String& fileName);
86
88 int32_t mergeFields();
89
90 Collection< Collection<int32_t> > getDocMaps();
91 Collection<int32_t> getDelCounts();
92
93 protected:
94 void addIndexed(const IndexReaderPtr& reader, const FieldInfosPtr& fInfos, HashSet<String> names, bool storeTermVectors,
95 bool storePositionWithTermVector, bool storeOffsetWithTermVector, bool storePayloads,
96 bool omitTFAndPositions);
97
98 void setMatchingSegmentReaders();
99 int32_t copyFieldsWithDeletions(const FieldsWriterPtr& fieldsWriter, const IndexReaderPtr& reader, const FieldsReaderPtr& matchingFieldsReader);
100 int32_t copyFieldsNoDeletions(const FieldsWriterPtr& fieldsWriter, const IndexReaderPtr& reader, const FieldsReaderPtr& matchingFieldsReader);
101
103 void mergeVectors();
104
105 void copyVectorsWithDeletions(const TermVectorsWriterPtr& termVectorsWriter, const TermVectorsReaderPtr& matchingVectorsReader, const IndexReaderPtr& reader);
106 void copyVectorsNoDeletions(const TermVectorsWriterPtr& termVectorsWriter, const TermVectorsReaderPtr& matchingVectorsReader, const IndexReaderPtr& reader);
107
108 void mergeTerms();
109
110 void mergeTermInfos(const FormatPostingsFieldsConsumerPtr& consumer);
111
117 int32_t appendPostings(const FormatPostingsTermsConsumerPtr& termsConsumer, Collection<SegmentMergeInfoPtr> smis, int32_t n);
118
119 void mergeNorms();
120 };
121
122 class CheckAbort : public LuceneObject {
123 public:
124 CheckAbort(const OneMergePtr& merge, const DirectoryPtr& dir);
125 virtual ~CheckAbort();
126
127 LUCENE_CLASS(CheckAbort);
128
129 protected:
130 double workCount;
131 OneMergePtr merge;
132 DirectoryWeakPtr _dir;
133
134 public:
138 virtual void work(double units);
139 };
140
141 class CheckAbortNull : public CheckAbort {
142 public:
143 CheckAbortNull();
144 virtual ~CheckAbortNull();
145
146 LUCENE_CLASS(CheckAbortNull);
147
148 public:
150 virtual void work(double units);
151 };
152
153 }
154
155 #endif
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::CheckAbortNull
Definition: SegmentMerger.h:141
Lucene::CheckAbortNull::~CheckAbortNull
virtual ~CheckAbortNull()
Lucene::CheckAbortNull::work
virtual void work(double units)
do nothing
Lucene::CheckAbortNull::CheckAbortNull
CheckAbortNull()
Lucene::CheckAbort
Definition: SegmentMerger.h:122
Lucene::CheckAbort::_dir
DirectoryWeakPtr _dir
Definition: SegmentMerger.h:132
Lucene::CheckAbort::workCount
double workCount
Definition: SegmentMerger.h:127
Lucene::CheckAbort::merge
OneMergePtr merge
Definition: SegmentMerger.h:131
Lucene::CheckAbort::work
virtual void work(double units)
Records the fact that roughly units amount of work have been done since this method was last called....
Lucene::CheckAbort::~CheckAbort
virtual ~CheckAbort()
Lucene::CheckAbort::CheckAbort
CheckAbort(const OneMergePtr &merge, const DirectoryPtr &dir)
Lucene::Collection< IndexReaderPtr >
Lucene::HashSet< String >
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::SegmentMerger
The SegmentMerger class combines two or more Segments, represented by an IndexReader (add,...
Definition: SegmentMerger.h:20
Lucene::SegmentMerger::mergeFields
int32_t mergeFields()
Lucene::SegmentMerger::copyVectorsWithDeletions
void copyVectorsWithDeletions(const TermVectorsWriterPtr &termVectorsWriter, const TermVectorsReaderPtr &matchingVectorsReader, const IndexReaderPtr &reader)
Lucene::SegmentMerger::closeReaders
void closeReaders()
close all IndexReaders that have been added. Should not be called before merge().
Lucene::SegmentMerger::mergeNorms
void mergeNorms()
Lucene::SegmentMerger::matchingSegmentReaders
Collection< SegmentReaderPtr > matchingSegmentReaders
Definition: SegmentMerger.h:46
Lucene::SegmentMerger::NORMS_HEADER_LENGTH
static const int32_t NORMS_HEADER_LENGTH
Definition: SegmentMerger.h:60
Lucene::SegmentMerger::getMergedFiles
HashSet< String > getMergedFiles()
Lucene::SegmentMerger::directory
DirectoryPtr directory
Definition: SegmentMerger.h:26
Lucene::SegmentMerger::rawDocLengths2
Collection< int32_t > rawDocLengths2
Definition: SegmentMerger.h:48
Lucene::SegmentMerger::mergeDocStores
bool mergeDocStores
Whether we should merge doc stores (stored fields and vectors files). When all segments we are mergin...
Definition: SegmentMerger.h:41
Lucene::SegmentMerger::setMatchingSegmentReaders
void setMatchingSegmentReaders()
Lucene::SegmentMerger::createCompoundFile
HashSet< String > createCompoundFile(const String &fileName)
Lucene::SegmentMerger::add
void add(const IndexReaderPtr &reader)
Add an IndexReader to the collection of readers that are to be merged.
Lucene::SegmentMerger::~SegmentMerger
virtual ~SegmentMerger()
Lucene::SegmentMerger::merge
int32_t merge(bool mergeDocStores)
Merges the readers specified by the add method into the directory passed to the constructor.
Lucene::SegmentMerger::mergeTermInfos
void mergeTermInfos(const FormatPostingsFieldsConsumerPtr &consumer)
Lucene::SegmentMerger::merge
int32_t merge()
Merges the readers specified by the add method into the directory passed to the constructor.
Lucene::SegmentMerger::copyFieldsNoDeletions
int32_t copyFieldsNoDeletions(const FieldsWriterPtr &fieldsWriter, const IndexReaderPtr &reader, const FieldsReaderPtr &matchingFieldsReader)
Lucene::SegmentMerger::hasProx
bool hasProx()
Lucene::SegmentMerger::segmentReader
IndexReaderPtr segmentReader(int32_t i)
Lucene::SegmentMerger::omitTermFreqAndPositions
bool omitTermFreqAndPositions
Definition: SegmentMerger.h:51
Lucene::SegmentMerger::termIndexInterval
int32_t termIndexInterval
Definition: SegmentMerger.h:31
Lucene::SegmentMerger::copyVectorsNoDeletions
void copyVectorsNoDeletions(const TermVectorsWriterPtr &termVectorsWriter, const TermVectorsReaderPtr &matchingVectorsReader, const IndexReaderPtr &reader)
Lucene::SegmentMerger::copyFieldsWithDeletions
int32_t copyFieldsWithDeletions(const FieldsWriterPtr &fieldsWriter, const IndexReaderPtr &reader, const FieldsReaderPtr &matchingFieldsReader)
Lucene::SegmentMerger::MAX_RAW_MERGE_DOCS
static const int32_t MAX_RAW_MERGE_DOCS
Maximum number of contiguous documents to bulk-copy when merging stored fields.
Definition: SegmentMerger.h:44
Lucene::SegmentMerger::SegmentMerger
SegmentMerger(const DirectoryPtr &dir, const String &name)
Lucene::SegmentMerger::checkAbort
CheckAbortPtr checkAbort
Definition: SegmentMerger.h:37
Lucene::SegmentMerger::addIndexed
void addIndexed(const IndexReaderPtr &reader, const FieldInfosPtr &fInfos, HashSet< String > names, bool storeTermVectors, bool storePositionWithTermVector, bool storeOffsetWithTermVector, bool storePayloads, bool omitTFAndPositions)
Lucene::SegmentMerger::rawDocLengths
Collection< int32_t > rawDocLengths
Definition: SegmentMerger.h:47
Lucene::SegmentMerger::getDocMaps
Collection< Collection< int32_t > > getDocMaps()
Lucene::SegmentMerger::SegmentMerger
SegmentMerger(const IndexWriterPtr &writer, const String &name, const OneMergePtr &merge)
Lucene::SegmentMerger::docMaps
Collection< Collection< int32_t > > docMaps
Definition: SegmentMerger.h:54
Lucene::SegmentMerger::queue
SegmentMergeQueuePtr queue
Definition: SegmentMerger.h:50
Lucene::SegmentMerger::appendPostings
int32_t appendPostings(const FormatPostingsTermsConsumerPtr &termsConsumer, Collection< SegmentMergeInfoPtr > smis, int32_t n)
Process postings from multiple segments all positioned on the same term. Writes out merged entries in...
Lucene::SegmentMerger::readers
Collection< IndexReaderPtr > readers
Definition: SegmentMerger.h:33
Lucene::SegmentMerger::payloadBuffer
ByteArray payloadBuffer
Definition: SegmentMerger.h:53
Lucene::SegmentMerger::mergeTerms
void mergeTerms()
Lucene::SegmentMerger::delCounts
Collection< int32_t > delCounts
Definition: SegmentMerger.h:55
Lucene::SegmentMerger::getDelCounts
Collection< int32_t > getDelCounts()
Lucene::SegmentMerger::mergedDocs
int32_t mergedDocs
Definition: SegmentMerger.h:36
Lucene::SegmentMerger::mergeVectors
void mergeVectors()
Merge the TermVectors from each of the segments into the new one.
Lucene::SegmentMerger::segment
String segment
Definition: SegmentMerger.h:30
Lucene::SegmentMerger::fieldInfos
FieldInfosPtr fieldInfos
Definition: SegmentMerger.h:34
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::DirectoryWeakPtr
boost::weak_ptr< Directory > DirectoryWeakPtr
Definition: LuceneTypes.h:489
Lucene::TermVectorsWriterPtr
boost::shared_ptr< TermVectorsWriter > TermVectorsWriterPtr
Definition: LuceneTypes.h:263
Lucene::FieldInfosPtr
boost::shared_ptr< FieldInfos > FieldInfosPtr
Definition: LuceneTypes.h:127
Lucene::FormatPostingsTermsConsumerPtr
boost::shared_ptr< FormatPostingsTermsConsumer > FormatPostingsTermsConsumerPtr
Definition: LuceneTypes.h:145
Lucene::OneMergePtr
boost::shared_ptr< OneMerge > OneMergePtr
Definition: LuceneTypes.h:192
Lucene::FormatPostingsFieldsConsumerPtr
boost::shared_ptr< FormatPostingsFieldsConsumer > FormatPostingsFieldsConsumerPtr
Definition: LuceneTypes.h:141
Lucene::TermVectorsReaderPtr
boost::shared_ptr< TermVectorsReader > TermVectorsReaderPtr
Definition: LuceneTypes.h:256
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition: LuceneTypes.h:489
Lucene::CheckAbortPtr
boost::shared_ptr< CheckAbort > CheckAbortPtr
Definition: LuceneTypes.h:94
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::FieldsReaderPtr
boost::shared_ptr< FieldsReader > FieldsReaderPtr
Definition: LuceneTypes.h:131
Lucene::FieldsWriterPtr
boost::shared_ptr< FieldsWriter > FieldsWriterPtr
Definition: LuceneTypes.h:133
Lucene::SegmentMergeQueuePtr
boost::shared_ptr< SegmentMergeQueue > SegmentMergeQueuePtr
Definition: LuceneTypes.h:213
Lucene::IndexWriterPtr
boost::shared_ptr< IndexWriter > IndexWriterPtr
Definition: LuceneTypes.h:160

clucene.sourceforge.net