Changeset 846 for trunk/src/3rdparty/clucene
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/3rdparty/clucene/src/CLucene/index/SegmentTermDocs.cpp
r2 r846 113 113 } 114 114 115 bool SegmentTermDocs::next() { 115 116 bool SegmentTermDocs::next() 117 { 116 118 while (true) { 117 if (count == df)118 return false;119 120 uint32_t docCode = freqStream->readVInt();121 _doc += docCode >> 1;//unsigned shift122 if ((docCode & 1) != 0)// if low bit is set123 _freq = 1;// _freq is one124 else125 _freq = freqStream->readVInt();// else read _freq126 count++;127 128 if ( (deletedDocs == NULL) || (deletedDocs->get(_doc) == false ))129 break;130 skippingDoc();119 if (count == df) 120 return false; 121 122 uint32_t docCode = freqStream->readVInt(); 123 _doc += docCode >> 1; //unsigned shift 124 if ((docCode & 1) != 0) // if low bit is set 125 _freq = 1; // _freq is one 126 else 127 _freq = freqStream->readVInt(); // else read _freq 128 count++; 129 130 if (deletedDocs == NULL || (_doc >= 0 && !deletedDocs->get(_doc))) 131 break; 132 skippingDoc(); 131 133 } 132 134 return true; 133 } 134 135 int32_t SegmentTermDocs::read(int32_t* docs, int32_t* freqs, int32_t length) { 135 } 136 137 138 int32_t SegmentTermDocs::read(int32_t* docs, int32_t* freqs, int32_t length) 139 { 136 140 int32_t i = 0; 137 //todo: one optimization would be to get the pointer buffer for ram or mmap dirs 138 //and iterate over them instead of using readByte() intensive functions.139 while (i <length && count < df) {140 uint32_t docCode = freqStream->readVInt();141 _doc += docCode >> 1;142 if ((docCode & 1) != 0)// if low bit is set143 _freq = 1;// _freq is one144 else145 _freq = freqStream->readVInt();// else read _freq146 count++;147 148 if (deletedDocs == NULL || !deletedDocs->get(_doc)) {149 docs[i] = _doc;150 freqs[i] = _freq;151 i++;152 }141 // TODO: one optimization would be to get the pointer buffer for ram or mmap 142 // dirs and iterate over them instead of using readByte() intensive functions. 143 while (i < length && count < df) { 144 uint32_t docCode = freqStream->readVInt(); 145 _doc += docCode >> 1; 146 if ((docCode & 1) != 0) // if low bit is set 147 _freq = 1; // _freq is one 148 else 149 _freq = freqStream->readVInt(); // else read _freq 150 count++; 151 152 if (deletedDocs == NULL || (_doc >= 0 && !deletedDocs->get(_doc))) { 153 docs[i] = _doc; 154 freqs[i] = _freq; 155 i++; 156 } 153 157 } 154 158 return i; 155 159 } 156 160 157 161 bool SegmentTermDocs::skipTo(const int32_t target){ -
trunk/src/3rdparty/clucene/src/CLucene/index/Term.cpp
r2 r846 154 154 return _tcscmp(_text, other->_text); 155 155 156 return _tcscmp(_field, other->_field); 156 int32_t ret = _tcscmp(_field, other->_field); 157 if (ret == 0) 158 ret = _tcscmp(_text, other->_text); 159 return ret; 157 160 } 158 161 -
trunk/src/3rdparty/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp
r2 r846 22 22 CL_NS_DEF(queryParser) 23 23 24 MultiFieldQueryParser::MultiFieldQueryParser(const TCHAR** fields, CL_NS(analysis)::Analyzer* a, BoostMap* boosts): 25 QueryParser(NULL,a) 24 MultiFieldQueryParser::MultiFieldQueryParser(const TCHAR** fields, 25 CL_NS(analysis)::Analyzer* analyzer, BoostMap* boosts) 26 : QueryParser(NULL, analyzer) 26 27 { 27 28 this->fields = fields; 28 29 this->boosts = boosts; 29 30 } 30 MultiFieldQueryParser::~MultiFieldQueryParser(){ 31 32 MultiFieldQueryParser::~MultiFieldQueryParser() 33 { 31 34 } 32 35 33 36 //static 34 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, Analyzer* analyzer) 37 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, 38 Analyzer* analyzer) 35 39 { 36 40 BooleanQuery* bQuery = _CLNEW BooleanQuery(); 37 41 int32_t i = 0; 38 while ( fields[i] != NULL ){ 39 Query* q = QueryParser::parse(query, fields[i], analyzer); 40 bQuery->add(q, true, false, false); 41 42 while (fields[i] != NULL){ 43 Query* q = QueryParser::parse(query, fields[i], analyzer); 44 if (q && (q->getQueryName() != _T("BooleanQuery") 45 || ((BooleanQuery*)q)->getClauseCount() > 0)) { 46 bQuery->add(q , true, false, false); 47 } else { 48 _CLDELETE(q); 49 } 42 50 i++; 43 51 } … … 46 54 47 55 //static 48 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, const uint8_t* flags, Analyzer* analyzer) 56 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, 57 const uint8_t* flags, Analyzer* analyzer) 49 58 { 50 59 BooleanQuery* bQuery = _CLNEW BooleanQuery(); 51 60 int32_t i = 0; 52 while ( fields[i] != NULL ) 53 { 54 Query* q = QueryParser::parse(query, fields[i], analyzer); 55 uint8_t flag = flags[i]; 56 switch (flag) 57 { 58 case MultiFieldQueryParser::REQUIRED_FIELD: 59 bQuery->add(q, true, true, false); 60 break; 61 case MultiFieldQueryParser::PROHIBITED_FIELD: 62 bQuery->add(q, true, false, true); 63 break; 64 default: 65 bQuery->add(q, true, false, false); 66 break; 61 while ( fields[i] != NULL ) { 62 Query* q = QueryParser::parse(query, fields[i], analyzer); 63 if (q && (q->getQueryName() != _T("BooleanQuery") 64 || ((BooleanQuery*)q)->getClauseCount() > 0)) { 65 uint8_t flag = flags[i]; 66 switch (flag) { 67 case MultiFieldQueryParser::REQUIRED_FIELD: 68 bQuery->add(q, true, true, false); 69 break; 70 case MultiFieldQueryParser::PROHIBITED_FIELD: 71 bQuery->add(q, true, false, true); 72 break; 73 default: 74 bQuery->add(q, true, false, false); 75 break; 76 } 77 } else { 78 _CLDELETE(q); 67 79 } 68 69 80 i++; 70 81 } -
trunk/src/3rdparty/clucene/src/CLucene/store/FSDirectory.cpp
r632 r846 94 94 95 95 FSDirectory::FSIndexInput::FSIndexInput(const QString& path, int32_t bufferSize) 96 : BufferedIndexInput(bufferSize) 96 : BufferedIndexInput(bufferSize) 97 97 { 98 98 CND_PRECONDITION(!path.isEmpty(), "path is NULL"); … … 158 158 _CLTHROWA(CL_ERR_NullPointer, "other handle is null"); 159 159 160 SCOPED_LOCK_MUTEX( other.handle->THIS_LOCK)160 SCOPED_LOCK_MUTEX(*other.handle->THIS_LOCK) 161 161 162 162 _pos = other.handle->_fpos; … … 172 172 { 173 173 BufferedIndexInput::close(); 174 #ifdef _LUCENE_THREADMUTEX 175 if (handle != NULL) { 176 // Here we have a bit of a problem... We need to lock the handle to 177 // ensure that we can safely delete the handle... But if we delete the 178 // handle, then the scoped unlock, won't be able to unlock the mutex... 179 180 // take a reference of the lock object... 181 _LUCENE_THREADMUTEX* mutex = handle->THIS_LOCK; 182 //lock the mutex 183 mutex->lock(); 184 185 // determine if we are about to delete the handle... 186 bool doUnlock = (handle->__cl_refcount > 1); 187 // decdelete (deletes if refcount is down to 0) 188 _CLDECDELETE(handle); 189 190 if (doUnlock) 191 mutex->unlock(); 192 else 193 delete mutex; 194 } 195 #else 174 196 _CLDECDELETE(handle); 197 #endif 175 198 } 176 199 … … 189 212 void FSDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_t len) 190 213 { 191 SCOPED_LOCK_MUTEX( handle->THIS_LOCK)214 SCOPED_LOCK_MUTEX(*handle->THIS_LOCK) 192 215 193 216 CND_PRECONDITION(handle != NULL, "shared file handle has closed"); … … 217 240 : _fpos(0) 218 241 , _length(0) 219 220 { 242 { 243 #ifdef _LUCENE_THREADMUTEX 244 THIS_LOCK = new _LUCENE_THREADMUTEX; 245 #endif 221 246 } 222 247 -
trunk/src/3rdparty/clucene/src/CLucene/store/FSDirectory.h
r2 r846 148 148 void close(); 149 149 IndexInput* clone() const; 150 150 151 151 int64_t length() 152 152 { return handle->_length; } … … 175 175 176 176 QFile fhandle; 177 DEFINE_MUTEX( THIS_LOCK)177 DEFINE_MUTEX(*THIS_LOCK) 178 178 }; 179 179 SharedHandle* handle; -
trunk/src/3rdparty/clucene/src/CLucene/util/bufferedstream.h
r2 r846 29 29 #include "streambase.h" 30 30 #include "inputstreambuffer.h" 31 31 32 #include <cassert> 33 #include <stdio.h> 32 34 33 35 namespace jstreams { … … 45 47 * This function must be implemented by the subclasses. 46 48 * It should write a maximum of @p space characters at the buffer 47 * position pointed to by @p start. If no more data is avai able due to49 * position pointed to by @p start. If no more data is available due to 48 50 * end of file, -1 should be returned. If an error occurs, the status 49 51 * should be set to Error, an error message should be set and the function
Note:
See TracChangeset
for help on using the changeset viewer.