/*------------------------------------------------------------------------------ * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team * * Distributable under the terms of either the Apache License (Version 2.0) or * the GNU Lesser General Public License, as specified in the COPYING file. ------------------------------------------------------------------------------*/ #ifndef _lucene_index_SegmentMerger_ #define _lucene_index_SegmentMerger_ #if defined(_LUCENE_PRAGMA_ONCE) # pragma once #endif #include "CLucene/store/Directory.h" #include "CLucene/store/RAMDirectory.h" #include "CLucene/util/VoidList.h" #include "SegmentMergeInfo.h" #include "SegmentMergeQueue.h" #include "IndexWriter.h" #include "FieldInfos.h" #include "FieldsWriter.h" #include "TermInfosWriter.h" CL_NS_DEF(index) /** * The SegmentMerger class combines two or more Segments, represented by an IndexReader ({@link #add}, * into a single Segment. After adding the appropriate readers, call the merge method to combine the * segments. *
* If the compoundFile flag is set, then the segments will be merged into a compound file.
*
*
* @see #merge
* @see #add
*/
class SegmentMerger:LUCENE_BASE {
bool useCompoundFile;
CL_NS(store)::RAMIndexOutput* skipBuffer;
int32_t lastSkipDoc;
int64_t lastSkipFreqPointer;
int64_t lastSkipProxPointer;
void resetSkip();
void bufferSkip(int32_t doc);
int64_t writeSkip();
//Directory of the segment
CL_NS(store)::Directory* directory;
//name of the new segment
const char* segment;
//Set of IndexReaders
CL_NS(util)::CLVectorsmis
* contains segments that are positioned at the same term. N
* is the number of cells in the array actually occupied.
*
* @param smis array of segments
* @param n number of cells in the array actually occupied
*/
void mergeTermInfo( SegmentMergeInfo** smis);
/** Process postings from multiple segments all positioned on the
* same term. Writes out merged entries into freqOutput and
* the proxOutput streams.
*
* @param smis array of segments
* @param n number of cells in the array actually occupied
* @return number of documents across all segments where this term was found
*/
int32_t appendPostings(SegmentMergeInfo** smis);
//Merges the norms for all fields
void mergeNorms();
void createCompoundFile(const char* filename, CL_NS(util)::AStringArrayWithDeletor& files);
friend class IndexWriter; //allow IndexWriter to use createCompoundFile
};
CL_NS_END
#endif