CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_Config_ 00008 #define _lucene_Config_ 00009 00010 00012 // this settings should be set up in the compiler, 00013 // but are put here for reference as to what could be defined 00015 // 00016 //define this if you want debugging code to be enabled 00017 //#define _DEBUG 00018 // 00019 //define this if you want condition debugging to be enabled 00020 #if defined(_DEBUG) && !defined(_CL__CND_DEBUG) 00021 #define _CL__CND_DEBUG 00022 #endif 00023 // 00024 //define this to print out lots of information about merges, etc 00025 //requires __CL__CND_DEBUG to be defined 00026 //#define _CL_DEBUG_INFO stdout 00027 // 00028 //to disable namespaces define this 00029 //#define DISABLE_NAMESPACE 00030 // 00031 //If you have put the google sparse map code in your include path 00032 //somewhere, then define this to use it. 00033 //#define _CL_HAVE_GOOGLE_DENSE_HASH_MAP 00034 // 00036 00038 // These options can be set depending on the particular needs of 00039 // Your application 00041 // 00042 //define this to force the build into ascii mode 00043 //#define _ASCII 00044 // 00045 //define this to force the build into ucs2 mode 00046 //#define _UCS2 00047 // 00048 //if a wide character is being converted to a ascii character and it 00049 //cannot fit, this character is used instead. Required. 00050 #define LUCENE_OOR_CHAR(c) ((char)(((unsigned short)c)&0xFF)) 00051 // 00052 //define if you would like to force clucene to use the internal 00053 //character functions. 00054 //Tests may display unpredictable behaviour if this is not defined. 00055 #define LUCENE_USE_INTERNAL_CHAR_FUNCTIONS 00056 // 00057 //define this to enable mmap support in the fsdirectory IndexInput 00058 //todo: only available for windows so far...need to add MMapInput.cpp to project 00059 //EXPERIMENTAL 00060 //#define LUCENE_FS_MMAP 00061 // 00062 //LOCK_DIR implementation: 00063 //define this to set an exact directory for the lock dir (not recommended) 00064 //all other methods of getting the temporary directory will be ignored 00065 //#define LUCENE_LOCK_DIR "/tmp" 00066 // 00067 //define this to try and load the lock dir from this specified environment variable 00068 #define LUCENE_LOCK_DIR_ENV_1 "TEMP" 00069 //define this if you want to have look up this environment variable if the first one fails 00070 #define LUCENE_LOCK_DIR_ENV_2 "TMP" 00071 //define this if you want to have a fallback directory, if not defined then 00072 //the lockdirectory will be the index directory 00073 #define LUCENE_LOCK_DIR_ENV_FALLBACK "/tmp" 00074 // 00076 00077 00078 00080 // The following are search query options 00081 // THe NO_* options can make CLucene faster and/or smaller 00082 // special queries sometime require longer search times or may 00083 // not be required 00085 // 00086 //Define this to remove fuzzy query and sloppy scoring 00087 //#define NO_FUZZY_QUERY 00088 // 00089 //Define to remove wildcard t*m or te?m to match term 00090 //#define NO_WILDCARD_QUERY 00091 // 00092 //Define to remove prefix term query - ter* to match term or terms 00093 //#define NO_PREFIX_QUERY 00094 // 00095 //Define to remove range (exlusive and inclusive) 00096 //#define NO_RANGE_QUERY 00097 // 00098 //This must always be defined. They can be adjusted if required. But 00099 //general Wildcard string would be '*' and Wildcard Char would be '?' 00100 //Both are Required. 00101 #define LUCENE_WILDCARDTERMENUM_WILDCARD_STRING '*' 00102 #define LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR '?' 00103 // 00105 00107 // memory handling configurations 00109 // 00110 //If this is defined, lucene's configurations are changed 00111 //to use less memory, but may run slower. 00112 //todo: i dont think this actualy changes speed much, just memory 00113 #define LUCENE_OPTIMIZE_FOR_MEMORY 00114 // 00115 //define this if you want the pointer tracking to be enabled 00116 //this is a useful tool for memory leak tracking 00117 //The LuceneBase can slow down the code a *lot* 00118 #if defined(_DEBUG) 00119 #if !defined(LUCENE_DISABLE_MEMTRACKING) && !defined(LUCENE_ENABLE_MEMLEAKTRACKING) 00120 #define LUCENE_ENABLE_MEMLEAKTRACKING 00121 #endif 00122 #endif 00123 // 00124 //enable use of rich file/line tracking. use CL_FILELINE to pass 00125 //to functions like stringDuplicate (or use CL_STRDUP* functions instead) and 00126 //CLStringIntern::x. 00127 #if defined(LUCENE_ENABLE_MEMLEAKTRACKING) 00128 #define LUCENE_ENABLE_FILELINEINFO 00129 #endif 00130 // 00131 //enable creation of clucene.log file. Logs every 00132 //call to new operator. Must have LUCENE_ENABLE_MEMLEAKTRACKING enabled. 00133 //writes log in this format. 00134 //action,file name,file line,allocation size 00135 //logging can be disabled by setting _lucene_disable_debuglogging to true 00136 #if defined(LUCENE_ENABLE_MEMLEAKTRACKING) && defined(_DEBUG) 00137 //#define LUCENE_ENABLE_CONSTRUCTOR_LOG 00138 #endif 00139 // 00140 // 00141 //enable this if you want to enable reference counting. This is 00142 //not necessary or useful in most cases except when implementing wrappers 00143 //which have reference counting. If the wrapper wraps a StringReader, 00144 //for example, it should expect that the wrapped StringReader should not 00145 //be deleted. However, when the stringreader is added into a Field, 00146 //the Field usually takes over the stringReader and deletes it on completion. 00147 //If reference counting is enabled, the wrapper can add a reference to any class 00148 //and when _CLDECDELETE is called, the reference is decremented and only deleted 00149 //if the refcount is zero. 00150 //#define LUCENE_ENABLE_REFCOUNT 00151 00152 00154 // These options allow you to remove certain implementations 00155 // out of clucene so that they can be implemented in the client 00156 // application 00158 // 00159 //define this to your own setting if you would like to implement your own 00160 //threading locking code. it should have the same sort of functions as 00161 //mutex_default. If not defined, clucene will try and use posix,win32 critical 00162 //sections, or a timer based mutex hack. 00163 //#define _LUCENE_THREADMUTEX CL_NS(util)::mutex_default 00164 // 00165 //define this if you want to implement the _Cnd_OutDebug routine yourself 00166 //you can then easily customise in your own application how to handle debug messages 00167 //#define _CND_DEBUG_DONTIMPLEMENT_OUTDEBUG 00168 // 00169 //define this if you want to implement your own namespace macros 00170 //#define _LUCENE_DONTIMPLEMENT_NS_MACROS 00171 // 00172 //define this if you do not want clucene to include any standard libraries. 00173 //this could be useful if you want to use alternate libraries 00174 //#define LUCENE_DISABLE_INCLUDES 00175 // 00177 00178 00180 // These options will be changed depending on your compiler/platform 00181 // but can also be changed here if required 00183 // 00184 //define this if multi-threading support is not required 00185 //if not defined, multi-thread locking will 00186 //occur (and its related processing overhead) 00187 //note: it is recommended to disable multithreading if you do not need it 00188 //there is a lot of overhead that can be avoided. 00189 //#define _CL_DISABLE_MULTITHREADING 00190 // 00191 //if you want to define your own default file encoding. specify it 00192 //here - normally defined in the platform specific headers 00193 //#define PLATFORM_DEFAULT_READER_ENCODING CL_NS(util)::FileReader::ENCODING_ASCII 00194 // 00195 //disable hash implementations (if available) 00196 //#define LUCENE_DISABLE_HASHING 00198 00199 00200 00202 // These options should not be changed. But you can experiment with 00203 // them to optimize performance 00205 // 00206 //some defaults, wouldn't usually need to be changed 00207 //Buffer size for input/output streams. Required. 00208 #define LUCENE_STREAM_BUFFER_SIZE 1024 00209 // 00210 // DSR:2004.08.19: 00211 // Formerly, StringBuffer used 1024 as the default size of its internal buffer. 00212 // However, StringBuffer is used primarily for token- and term-oriented 00213 // processing, e.g. in StandardTokenizer. I've calculated that the average 00214 // token (as produced by StandardTokenizer) in all .txt files distributed in 00215 // the Project Gutenberg CD Image (August 2003 release) has only 6 characters. 00216 // Although most languages are likely to have a longer average word length than 00217 // English due to the popularity of "non-atomized" conjugation and declension 00218 // mechanisms, 1024 is still vastly excessive. 00219 // I made two changes intended to deliver better overall performance: 00220 // a) Switched to a default StringBuffer character capacity of 32. Though 32 00221 // is longer than the average token, the high cost of realloc makes a 00222 // slightly liberal default size optimal. I chose the default size of 32 00223 // after fairly extensive experimentation on the Gutenberg e-texts. The 00224 // results are summarized in the following table: 00225 // ------------------------------------------------------------------------ 00226 // LUCENE_DEFAULT_TOKEN_BUFFER_SIZE value | % faster than default size 1024 00227 // ------------------------------------------------------------------------ 00228 // 8 : 4% 00229 // 16 : 7% 00230 // 32 : 6% 00231 // 64 : 3% 00232 // A default size of 32 is actually slightly slower than 16, but I was 00233 // experimenting on English text; I expect that 32 will maintain decent 00234 // performance in languages such as German, and in technical documents 00235 // with long tokens. 00236 // 00237 // b) To offset the switch to a smaller default buffer size, I implemented a 00238 // more aggressive growth strategy. A StringBuffer now [at least] doubles 00239 // the size of its internal buffer every time it needs to grow, rather 00240 // than [at least] increasing by LUCENE_DEFAULT_TOKEN_BUFFER_SIZE no 00241 // matter how many times it has already grown. 00242 //Required. 00243 #define LUCENE_DEFAULT_TOKEN_BUFFER_SIZE 32 00244 //todo: should implement a similar strategy in analysis/token 00245 // 00246 //Expert: The fraction of {@link TermDocs} entries stored in skip tables, 00247 //used to accellerate {@link TermDocs#skipTo(int)}. Larger values result in 00248 //smaller indices, greater acceleration, but fewer accelerable cases, while 00249 //smaller values result in bigger indices, less acceleration and more 00250 //accelerable cases. More detailed experiments would be useful here. */ 00251 #define LUCENE_DEFAULT_TERMDOCS_SKIP_INTERVAL 16 00252 // 00253 //Size of TermScore cache. Required. 00254 #define LUCENE_SCORE_CACHE_SIZE 32 00255 // 00256 //analysis options 00257 //maximum length that the CharTokenizer uses. Required. 00258 //By adjusting this value, you can greatly improve the performance of searching 00259 //and especially indexing. Default is 255, but smaller numbers will decrease 00260 //the amount of memory used as well as increasing the speed. 00261 #define LUCENE_MAX_WORD_LEN 255 00262 //Maximum length of a token word. 00263 //Should be the same or more than LUCENE_MAX_WORD_LEN 00264 //if not defined, then no token limit, but may be slower 00265 //if defined will be faster (up to 15% in some cases), but will use more memory 00266 #ifndef LUCENE_OPTIMIZE_FOR_MEMORY 00267 #define LUCENE_TOKEN_WORD_LENGTH LUCENE_MAX_WORD_LEN 00268 #endif 00269 // 00270 //maximum field length. some optimisation can be done if a maximum field 00271 //length is given... The smaller the better 00272 #define LUCENE_MAX_FIELD_LEN 100 00273 // 00274 //The initial value set to BooleanQuery::maxClauseCount. Default is 1024 00275 #define LUCENE_BOOLEANQUERY_MAXCLAUSECOUNT 1024 00276 // 00277 //bvk: 12.3.2005 00278 //============================================================================== 00279 //Previously the way the tokenizer has worked has been changed to optionally 00280 //use a a fixed word length. I have implemented this in the Term class as well. 00281 //It seems that by predefining the text length instead of using new TCHAR[x] 00282 //in the constructor greatly improves the performance by 20-30% for certain 00283 //operations. 00284 //Maximum length of a term text. 00285 //Should be the same or more than LUCENE_MAX_WORD_LEN 00286 //if not defined, then no term text limit, but may be slower 00287 //if defined will be faster (up to 30% in some cases), but will use more memory 00288 #ifndef LUCENE_OPTIMIZE_FOR_MEMORY 00289 #define LUCENE_TERM_TEXT_LENGTH LUCENE_MAX_WORD_LEN 00290 #endif 00291 // 00292 //Size of the CharTokenizer buffersize. Required. 00293 #define LUCENE_IO_BUFFER_SIZE 1024 00294 // 00295 //the minimum amount the segment term enum should grow by. Must be at least 1 00296 #define LUCENE_SEGMENTTERMENUM_GROWSIZE 8 00297 // 00299 00300 #endif 00301