RangeQuery::RangeQuery(Term* lowerTerm, Term* upperTerm, const bool Inclusive){ //Func - Constructor //Pre - (LowerTerm != NULL OR UpperTerm != NULL) AND // if LowerTerm and UpperTerm are valid pointer then the fieldnames must be the same //Post - The instance has been created if (lowerTerm == NULL && upperTerm == NULL) { _CLTHROWA(CL_ERR_IllegalArgument,"At least one term must be non-null"); } if (lowerTerm != NULL && upperTerm != NULL && lowerTerm->field() != upperTerm->field()) { _CLTHROWA(CL_ERR_IllegalArgument,"Both terms must be for the same field"); } // if we have a lowerTerm, start there. otherwise, start at beginning if (lowerTerm != NULL) { this->lowerTerm = _CL_POINTER(lowerTerm); } else { this->lowerTerm = _CLNEW Term(upperTerm, LUCENE_BLANK_STRING); } this->upperTerm = (upperTerm != NULL ? _CL_POINTER(upperTerm) : NULL); this->inclusive = Inclusive; }
/** Creates new WildcardTermEnum */ WildcardTermEnum::WildcardTermEnum(IndexReader* reader, Term* term): FilteredTermEnum(), __term(_CL_POINTER(term)), fieldMatch(false), _endEnum(false) { pre = stringDuplicate(term->text()); const TCHAR* sidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_STRING ); const TCHAR* cidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR ); const TCHAR* tidx = sidx; if (tidx == NULL) tidx = cidx; else if ( cidx && cidx > pre) tidx = min(sidx, cidx); CND_PRECONDITION(tidx != NULL, "tidx==NULL"); int32_t idx = (int32_t)(tidx - pre); preLen = idx; CND_PRECONDITION(preLen<term->textLength(), "preLen >= term->textLength()"); pre[preLen]=0; //trim end Term* t = _CLNEW Term(__term, pre); setEnum( reader->terms(t) ); _CLDECDELETE(t); }
PrefixQuery::PrefixQuery(Term* Prefix){ //Func - Constructor. // Constructs a query for terms starting with prefix //Pre - Prefix != NULL //Post - The instance has been created //Get a pointer to Prefix prefix = _CL_POINTER(Prefix); }
IndexReader::IndexReader(Directory* dir) : stale(false) , hasChanges(false) , closeDirectory(false) , directoryOwner(false) , segmentInfos(NULL) , directory(_CL_POINTER(dir)) , writeLock(NULL) { }
Term* SegmentTermEnum::term() { //Func - Returns the current term. //Pre - pointer is true or false and indicates if the reference counter // of term must be increased or not // next() must have been called once! //Post - pointer = true -> term has been returned with an increased reference counter // pointer = false -> term has been returned return _CL_POINTER(_term); }
IndexReader::IndexReader(Directory* dir, SegmentInfos* infos, bool close) : stale(false) , hasChanges(false) , closeDirectory(close) , directoryOwner(true) , segmentInfos(infos) , directory(_CL_POINTER(dir)) , writeLock(NULL) { }
FSDirectory::FSIndexInput::FSIndexInput(const FSIndexInput& other): BufferedIndexInput(other){ //Func - Constructor // Uses clone for its initialization //Pre - clone is a valide instance of FSIndexInput //Post - The instance has been created and initialized by clone if ( other.handle == NULL ) _CLTHROWA(CL_ERR_NullPointer, "other handle is null"); SCOPED_LOCK_MUTEX(other.handle->THIS_LOCK) handle = _CL_POINTER(other.handle); _pos = other.handle->_fpos; //note where we are currently... }
FuzzyTermEnum::FuzzyTermEnum(IndexReader* reader, Term* term, float_t minSimilarity, size_t _prefixLength): FilteredTermEnum(),d(NULL),dLen(0),_similarity(0),_endEnum(false),searchTerm(_CL_POINTER(term)), text(NULL),textLen(0),prefix(NULL)/* ISH: was STRDUP_TtoT(LUCENE_BLANK_STRING)*/,prefixLength(0), minimumSimilarity(minSimilarity) { CND_PRECONDITION(term != NULL,"term is NULL"); if (minSimilarity >= 1.0f) _CLTHROWA(CL_ERR_IllegalArgument,"minimumSimilarity cannot be greater than or equal to 1"); else if (minSimilarity < 0.0f) _CLTHROWA(CL_ERR_IllegalArgument,"minimumSimilarity cannot be less than 0"); scale_factor = 1.0f / (1.0f - minimumSimilarity); // only now we are safe from a division by zero //TODO: this.field = searchTerm.field(); //The prefix could be longer than the word. //It's kind of silly though. It means we must match the entire word. const size_t fullSearchTermLength = searchTerm->textLength(); const size_t realPrefixLength = _prefixLength > fullSearchTermLength ? fullSearchTermLength : _prefixLength; text = STRDUP_TtoT(searchTerm->text() + realPrefixLength); textLen = fullSearchTermLength - realPrefixLength; prefix = _CL_NEWARRAY(TCHAR,realPrefixLength+1); _tcsncpy(prefix, searchTerm->text(), realPrefixLength); prefix[realPrefixLength]='\0'; prefixLength = realPrefixLength; initializeMaxDistances(); Term* trm = _CLNEW Term(searchTerm->field(), prefix); // _CLNEW Term(term, prefix); -- not intern'd? setEnum(reader->terms(trm)); _CLLDECDELETE(trm); /* LEGACY: //Initialize e to NULL e = NULL; eWidth = 0; eHeight = 0; if(prefixLength > 0 && prefixLength < textLen){ this->prefixLength = prefixLength; prefix = _CL_NEWARRAY(TCHAR,prefixLength+1); _tcsncpy(prefix,text,prefixLength); prefix[prefixLength]='\0'; textLen = prefixLength; text[textLen]='\0'; } */ }
IndexWriter::IndexWriter(Directory* d, Analyzer* a, const bool create, const bool _closeDir): analyzer(a), closeDir(_closeDir), writeLock( NULL ), directory(_CL_POINTER(d)), segmentInfos (_CLNEW SegmentInfos) { //Func - Constructor // Constructs an IndexWriter for the index in path. //Pre - d contains a valid reference to a directory // a holds a valid reference to an analyzer and analyzes the text to be indexed // create indicates if the indexWriter must create a new index located at path or just open it //Post - If create is true, then a new, empty index has been created in path, replacing the index // already there, if any. The directory d is not owned by this Instance //Continue initializing the instance by _IndexWriter _IndexWriter ( create ); }
void FilteredTermEnum::setEnum(TermEnum* actualEnum) { //Func - Sets the actual Enumeration //Pre - actualEnum != NULL //Post - The instance has been created CND_PRECONDITION(actualEnum != NULL,"actualEnum is NULL"); _CLLDELETE(this->actualEnum); this->actualEnum = actualEnum; // Find the first term that matches //Ordered term not to return reference ownership here. Term* term = actualEnum->term(false); if (term != NULL && termCompare(term)){ _CLDECDELETE(currentTerm); currentTerm = _CL_POINTER(term); }else{ next(); } }
bool FilteredTermEnum::next() { //Func - Increments the enumeration to the next element. //Pre - true //Post - Returns True if the enumeration has been moved to the next element otherwise false //The actual enumerator is not initialized! if (actualEnum == NULL){ return false; } //Finalize the currentTerm and reset it to NULL _CLDECDELETE( currentTerm ); //Iterate through the enumeration while (currentTerm == NULL) { if (endEnum()) return false; if (actualEnum->next()) { //Order term not to return reference ownership here. */ Term* term = actualEnum->term(false); //Compare the retrieved term if (termCompare(term)){ //Matched so finalize the current _CLDECDELETE(currentTerm); //Get a reference to the matched term currentTerm = _CL_POINTER(term); return true; } }else return false; } _CLDECDELETE(currentTerm); currentTerm = NULL; return false; }
QCLuceneTermPrivate::QCLuceneTermPrivate(const QCLuceneTermPrivate &other) : QSharedData() { term = _CL_POINTER(other.term); }
QCLuceneAnalyzerPrivate::QCLuceneAnalyzerPrivate(const QCLuceneAnalyzerPrivate &other) : QSharedData() { analyzer = _CL_POINTER(other.analyzer); deleteCLuceneAnalyzer = other.deleteCLuceneAnalyzer; }
QCLuceneQueryParserPrivate::QCLuceneQueryParserPrivate(const QCLuceneQueryParserPrivate &other) : QSharedData() { queryParser = _CL_POINTER(other.queryParser); deleteCLuceneQueryParser = other.deleteCLuceneQueryParser; }
QCLuceneDocumentPrivate::QCLuceneDocumentPrivate(const QCLuceneDocumentPrivate &other) : QSharedData() { document = _CL_POINTER(other.document); }
Term* SegmentTermEnum::term(bool pointer) { if ( pointer ) return _CL_POINTER(_term); else return _term; }
QCLuceneSortPrivate::QCLuceneSortPrivate (const QCLuceneSortPrivate &other) : QSharedData() { sort = _CL_POINTER(other.sort); deleteCLuceneSort = other.deleteCLuceneSort; }
QCLuceneTokenPrivate::QCLuceneTokenPrivate(const QCLuceneTokenPrivate &other) : QSharedData() { token = _CL_POINTER(other.token); deleteCLuceneToken = other.deleteCLuceneToken; }
RangeQuery::RangeQuery(const RangeQuery& clone): Query(clone){ this->inclusive = clone.inclusive; this->upperTerm = (clone.upperTerm != NULL ? _CL_POINTER(clone.upperTerm) : NULL ); this->lowerTerm = (clone.lowerTerm != NULL ? _CL_POINTER(clone.lowerTerm) : NULL ); }
PrefixQuery::PrefixQuery(const PrefixQuery& clone):Query(clone){ prefix = _CL_POINTER(clone.prefix); }
QCLuceneFilterPrivate::QCLuceneFilterPrivate(const QCLuceneFilterPrivate &other) : QSharedData() { filter = _CL_POINTER(other.filter); }
QCLuceneReaderPrivate::QCLuceneReaderPrivate(const QCLuceneReaderPrivate &other) : QSharedData() { reader = _CL_POINTER(other.reader); deleteCLuceneReader = other.deleteCLuceneReader; }
Term* FilteredTermEnum::term(bool pointer) { if ( pointer ) return _CL_POINTER(currentTerm); else return currentTerm; }
QCLuceneHitsPrivate::QCLuceneHitsPrivate(const QCLuceneHitsPrivate &other) : QSharedData() { hits = _CL_POINTER(other.hits); deleteCLuceneHits = other.deleteCLuceneHits; }
/** Returns the lower term of this range query */ Term* RangeQuery::getLowerTerm(bool pointer) const { if ( pointer ) return _CL_POINTER(lowerTerm); else return lowerTerm; }
/** Returns the upper term of this range query */ Term* RangeQuery::getUpperTerm(bool pointer) const { if ( pointer ) return _CL_POINTER(upperTerm); else return upperTerm; }
QCLuceneTokenStreamPrivate::QCLuceneTokenStreamPrivate(const QCLuceneTokenStreamPrivate &other) : QSharedData() { tokenStream = _CL_POINTER(other.tokenStream); deleteCLuceneTokenStream = other.deleteCLuceneTokenStream; }
Term* PrefixQuery::getPrefix(bool pointer){ if ( pointer ) return _CL_POINTER(prefix); else return prefix; }
QCLuceneFieldPrivate::QCLuceneFieldPrivate(const QCLuceneFieldPrivate &other) : QSharedData() { field = _CL_POINTER(other.field); }
QCLuceneSearchablePrivate::QCLuceneSearchablePrivate(const QCLuceneSearchablePrivate &other) : QSharedData() { searchable = _CL_POINTER(other.searchable); }