1 /*------------------------------------------------------------------------------ 2 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 3 * 4 * Distributable under the terms of either the Apache License (Version 2.0) or 5 * the GNU Lesser General Public License, as specified in the COPYING file. 6 ------------------------------------------------------------------------------*/ 7 #ifndef _lucene_index_TermInfosWriter_ 8 #define _lucene_index_TermInfosWriter_ 9 10 #include "CLucene/util/Array.h" 11 12 CL_CLASS_DEF(store,Directory) 13 //#include "FieldInfos.h" 14 //#include "TermInfo.h" 15 //#include "Term.h" 16 17 CL_NS_DEF(index) 18 class FieldInfos; 19 class TermInfo; 20 21 // This stores a monotonically increasing set of <Term, TermInfo> pairs in a 22 // Directory. A TermInfos can be written once, in order. 23 class TermInfosWriter :LUCENE_BASE{ 24 private: 25 FieldInfos* fieldInfos; 26 CL_NS(store)::IndexOutput* output; 27 TermInfo* lastTi; 28 int64_t size; 29 30 int64_t lastIndexPointer; 31 bool isIndex; 32 CL_NS(util)::ValueArray<TCHAR> lastTermText; 33 int32_t lastTermTextLength; 34 int32_t lastFieldNumber; 35 36 CL_NS(util)::ValueArray<TCHAR> termTextBuffer; 37 38 TermInfosWriter* other; 39 40 //inititalize 41 TermInfosWriter(CL_NS(store)::Directory* directory, const char* segment, FieldInfos* fis, int32_t interval, bool isIndex); 42 43 int32_t compareToLastTerm(int32_t fieldNumber, const TCHAR* termText, int32_t length); 44 public: 45 /** Expert: The maximum number of skip levels. Smaller values result in 46 * slightly smaller indexes, but slower skipping in big posting lists. 47 */ 48 int32_t maxSkipLevels; 49 50 /** The file format version, a negative number. */ 51 LUCENE_STATIC_CONSTANT(int32_t,FORMAT=-3); 52 53 //Expert: The fraction of {@link TermDocs} entries stored in skip tables, 54 //used to accellerate {@link TermDocs#skipTo(int)}. Larger values result in 55 //smaller indices, greater acceleration, but fewer accelerable cases, while 56 //smaller values result in bigger indices, less acceleration and more 57 //accelerable cases. More detailed experiments would be useful here. */ 58 LUCENE_STATIC_CONSTANT(int32_t, DEFAULT_TERMDOCS_SKIP_INTERVAL=16); 59 60 61 /** 62 * Expert: The fraction of terms in the "dictionary" which should be stored 63 * in RAM. Smaller values use more memory, but make searching slightly 64 * faster, while larger values use less memory and make searching slightly 65 * slower. Searching is typically not dominated by dictionary lookup, so 66 * tweaking this is rarely useful. 67 */ 68 int32_t indexInterval;// = 128 69 70 /** 71 * Expert: The fraction of {@link TermDocs} entries stored in skip tables, 72 * used to accellerate {@link TermDocs#SkipTo(int32_t)}. Larger values result in 73 * smaller indexes, greater acceleration, but fewer accelerable cases, while 74 * smaller values result in bigger indexes, less acceleration and more 75 * accelerable cases. More detailed experiments would be useful here. 76 */ 77 int32_t skipInterval;// = 16 78 79 TermInfosWriter(CL_NS(store)::Directory* directory, const char* segment, FieldInfos* fis, int32_t interval); 80 81 ~TermInfosWriter(); 82 83 84 void add(Term* term, TermInfo* ti); 85 86 /** Adds a new <<fieldNumber, termText>, TermInfo> pair to the set. 87 Term must be lexicographically greater than all previous Terms added. 88 TermInfo pointers must be positive and greater than all previous.*/ 89 void add(int32_t fieldNumber, const TCHAR* termText, int32_t termTextLength, const TermInfo* ti); 90 91 /** Called to complete TermInfos creation. */ 92 void close(); 93 94 private: 95 /** Helps constructors to initialize instances */ 96 void initialise(CL_NS(store)::Directory* directory, const char* segment, int32_t interval, bool IsIndex); 97 void writeTerm(int32_t fieldNumber, const TCHAR* termText, int32_t termTextLength); 98 }; 99 CL_NS_END 100 #endif 101