Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/clucene/src/CLucene/index/SegmentTermDocs.cpp

    r2 r846  
    113113  }
    114114
    115   bool SegmentTermDocs::next() {
     115
     116bool SegmentTermDocs::next()
     117{
    116118    while (true) {
    117       if (count == df)
    118         return false;
    119 
    120       uint32_t docCode = freqStream->readVInt();
    121       _doc += docCode >> 1; //unsigned shift
    122       if ((docCode & 1) != 0)                     // if low bit is set
    123         _freq = 1;                                // _freq is one
    124       else
    125         _freq = freqStream->readVInt();          // else read _freq
    126       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();
    131133    }
    132134    return true;
    133   }
    134 
    135   int32_t SegmentTermDocs::read(int32_t* docs, int32_t* freqs, int32_t length) {
     135}
     136
     137
     138int32_t SegmentTermDocs::read(int32_t* docs, int32_t* freqs, int32_t length)
     139{
    136140    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 set
    143         _freq = 1;                                // _freq is one
    144       else
    145         _freq = freqStream->readVInt();          // else read _freq
    146       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        }
    153157    }
    154158    return i;
    155   }
     159}
    156160
    157161  bool SegmentTermDocs::skipTo(const int32_t target){
  • trunk/src/3rdparty/clucene/src/CLucene/index/Term.cpp

    r2 r846  
    154154        return _tcscmp(_text, other->_text);
    155155
    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;
    157160}
    158161
  • trunk/src/3rdparty/clucene/src/CLucene/queryParser/MultiFieldQueryParser.cpp

    r2 r846  
    2222CL_NS_DEF(queryParser)
    2323
    24 MultiFieldQueryParser::MultiFieldQueryParser(const TCHAR** fields, CL_NS(analysis)::Analyzer* a, BoostMap* boosts):
    25         QueryParser(NULL,a)
     24MultiFieldQueryParser::MultiFieldQueryParser(const TCHAR** fields,
     25    CL_NS(analysis)::Analyzer* analyzer, BoostMap* boosts)
     26    : QueryParser(NULL, analyzer)
    2627{
    2728        this->fields = fields;
    2829    this->boosts = boosts;
    2930}
    30 MultiFieldQueryParser::~MultiFieldQueryParser(){
     31
     32MultiFieldQueryParser::~MultiFieldQueryParser()
     33{
    3134}
    3235
    3336//static
    34 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, Analyzer* analyzer)
     37Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields,
     38    Analyzer* analyzer)
    3539{
    3640    BooleanQuery* bQuery = _CLNEW BooleanQuery();
    3741    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        }
    4250        i++;
    4351    }
     
    4654
    4755//static
    48 Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields, const uint8_t* flags, Analyzer* analyzer)
     56Query* MultiFieldQueryParser::parse(const TCHAR* query, const TCHAR** fields,
     57    const uint8_t* flags, Analyzer* analyzer)
    4958{
    5059    BooleanQuery* bQuery = _CLNEW BooleanQuery();
    5160    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);
    6779        }
    68 
    6980        i++;
    7081    }
  • trunk/src/3rdparty/clucene/src/CLucene/store/FSDirectory.cpp

    r632 r846  
    9494
    9595FSDirectory::FSIndexInput::FSIndexInput(const QString& path, int32_t bufferSize)
    96     : BufferedIndexInput(bufferSize)   
     96    : BufferedIndexInput(bufferSize)
    9797{
    9898    CND_PRECONDITION(!path.isEmpty(), "path is NULL");
     
    158158        _CLTHROWA(CL_ERR_NullPointer, "other handle is null");
    159159
    160     SCOPED_LOCK_MUTEX(other.handle->THIS_LOCK)
     160    SCOPED_LOCK_MUTEX(*other.handle->THIS_LOCK)
    161161
    162162    _pos = other.handle->_fpos;
     
    172172{
    173173    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
    174196    _CLDECDELETE(handle);
     197#endif
    175198}
    176199
     
    189212void FSDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_t len)
    190213{
    191     SCOPED_LOCK_MUTEX(handle->THIS_LOCK)
     214    SCOPED_LOCK_MUTEX(*handle->THIS_LOCK)
    192215
    193216    CND_PRECONDITION(handle != NULL, "shared file handle has closed");
     
    217240    : _fpos(0)
    218241    , _length(0)
    219 
    220 {
     242{
     243#ifdef _LUCENE_THREADMUTEX
     244    THIS_LOCK = new _LUCENE_THREADMUTEX;
     245#endif
    221246}
    222247
  • trunk/src/3rdparty/clucene/src/CLucene/store/FSDirectory.h

    r2 r846  
    148148        void close();
    149149        IndexInput* clone() const;
    150                
     150
    151151        int64_t length()
    152152        { return handle->_length; }
     
    175175           
    176176            QFile fhandle;
    177             DEFINE_MUTEX(THIS_LOCK)
     177            DEFINE_MUTEX(*THIS_LOCK)
    178178        };
    179179        SharedHandle* handle;
  • trunk/src/3rdparty/clucene/src/CLucene/util/bufferedstream.h

    r2 r846  
    2929#include "streambase.h"
    3030#include "inputstreambuffer.h"
     31
    3132#include <cassert>
     33#include <stdio.h>
    3234
    3335namespace jstreams {
     
    4547     * This function must be implemented by the subclasses.
    4648     * It should write a maximum of @p space characters at the buffer
    47      * position pointed to by @p start. If no more data is avaiable due to
     49     * position pointed to by @p start. If no more data is available due to
    4850     * end of file, -1 should be returned. If an error occurs, the status
    4951     * should be set to Error, an error message should be set and the function
Note: See TracChangeset for help on using the changeset viewer.