Kaydet (Commit) 4ca45e50 authored tarafından Andreas Bille's avatar Andreas Bille

#89246#

Refcounting ConceptData, so not freeing it twice, which causes the GPF.
Fixed some memory leaks. Fixing a memory overwrite in BreeDict.cxx
üst 7187b23c
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: Block.cxx,v $ * $RCSfile: Block.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: abi $ $Date: 2001-05-10 15:25:10 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
* *
* *
************************************************************************/ ************************************************************************/
#ifndef _RTL_MEMORY_H_
#include <rtl/memory.h>
#endif
#ifndef _XMLSEARCH_DB_BLOCK_HXX_ #ifndef _XMLSEARCH_DB_BLOCK_HXX_
#include <db/Block.hxx> #include <db/Block.hxx>
#endif #endif
...@@ -88,6 +91,7 @@ Block::Block( const DBEnv* dbenv ) ...@@ -88,6 +91,7 @@ Block::Block( const DBEnv* dbenv )
dataL_( dbenv->getDataLen() ), dataL_( dbenv->getDataLen() ),
data_( new sal_Int8[ dbenv->getDataLen() ] ) data_( new sal_Int8[ dbenv->getDataLen() ] )
{ {
rtl_zeroMemory( data_,dataL_ );
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: BtreeDict.cxx,v $ * $RCSfile: BtreeDict.cxx,v $
* *
* $Revision: 1.7 $ * $Revision: 1.8 $
* *
* last change: $Author: abi $ $Date: 2001-06-22 14:13:18 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -368,7 +368,7 @@ BtreeDict::BtreeDict( const util::IndexAccessor& indexAccessor ) throw( IOExcept ...@@ -368,7 +368,7 @@ BtreeDict::BtreeDict( const util::IndexAccessor& indexAccessor ) throw( IOExcept
{ {
sal_Int32 len = SCHEMA->length(); sal_Int32 len = SCHEMA->length();
char* bff = new char[ 1 + len ]; char* bff = new char[ 1 + len ];
bff[ 1 + len ] = 0; bff[ len ] = 0;
SCHEMA->readBytes( reinterpret_cast<sal_Int8*>( bff ),len ); SCHEMA->readBytes( reinterpret_cast<sal_Int8*>( bff ),len );
delete SCHEMA; delete SCHEMA;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ConceptData.cxx,v $ * $RCSfile: ConceptData.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -88,26 +88,32 @@ ConceptData::ConceptData( sal_Int32 id, ...@@ -88,26 +88,32 @@ ConceptData::ConceptData( sal_Int32 id,
role_( sal_uInt8( role & 0xF ) ), role_( sal_uInt8( role & 0xF ) ),
penalty_( score ), penalty_( score ),
ctx_( contextTables ), ctx_( contextTables ),
next_( 0 ) next_( 0 ),
m_nRefcount( 0 )
{
}
ConceptData::~ConceptData()
{ {
} }
void ConceptData::runBy( std::vector< Query* >& queries ) void ConceptData::runBy( std::vector< Query* >& queries )
{ {
ConceptData* cd = this; rtl::Reference< ConceptData > cd( this );
do do
{ {
Query* query = queries[ cd->queryNo_ ]; Query* query = queries[ cd->queryNo_ ];
query->updateEstimate( cd->role_,cd->penalty_ ); query->updateEstimate( cd->role_,cd->penalty_ );
} }
while( cd = cd->next_ ); while( (cd = cd->next_).is() );
} }
void ConceptData::addLast( ConceptData* r ) void ConceptData::addLast( ConceptData* r )
{ {
if( next_ ) if( next_.is() )
next_->addLast( r ); next_->addLast( r );
else else
next_ = r; next_ = r;
...@@ -119,15 +125,15 @@ void ConceptData::generateFillers( std::vector< RoleFiller* >& array, sal_Int32 ...@@ -119,15 +125,15 @@ void ConceptData::generateFillers( std::vector< RoleFiller* >& array, sal_Int32
if( array[ queryNo_ ] != RoleFiller::STOP() ) // not 'prohibited' if( array[ queryNo_ ] != RoleFiller::STOP() ) // not 'prohibited'
{ {
sal_Int32 wcl = ctx_->wordContextLin( pos ); sal_Int32 wcl = ctx_->wordContextLin( pos );
RoleFiller* p = new RoleFiller( nColumns_, roleFillers_.push_back( new RoleFiller( nColumns_,
this, this,
role_, role_,
pos, pos,
wcl, wcl,
pos + proximity_ ); pos + proximity_ ) );
p->use( array, queryNo_ ); roleFillers_.back()->use( array, queryNo_ );
} }
// !!! maybe eliminate tail recursion // !!! maybe eliminate tail recursion
if( next_ ) if( next_.is() )
next_->generateFillers( array,pos ); next_->generateFillers( array,pos );
} }
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ContextTables.cxx,v $ * $RCSfile: ContextTables.cxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: abi $ $Date: 2001-06-22 10:12:51 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -58,6 +58,10 @@ ...@@ -58,6 +58,10 @@
* *
* *
************************************************************************/ ************************************************************************/
#ifndef _rtl_MEMORY_H_
#include <rtl/memory.h>
#endif
#ifndef _XMLSEARCH_QE_CONTEXTTABLES_HXX_ #ifndef _XMLSEARCH_QE_CONTEXTTABLES_HXX_
#include <qe/ContextTables.hxx> #include <qe/ContextTables.hxx>
#endif #endif
...@@ -76,6 +80,21 @@ Tables::Tables( ContextTables* p ) ...@@ -76,6 +80,21 @@ Tables::Tables( ContextTables* p )
linkTypesCached_( new sal_Int32[ linkTypesCachedL_ = p->linkTypesL_ ] ), linkTypesCached_( new sal_Int32[ linkTypesCachedL_ = p->linkTypesL_ ] ),
seqNumbersCached_( new sal_Int32[ seqNumbersCachedL_ = p->seqNumbersL_ ] ) seqNumbersCached_( new sal_Int32[ seqNumbersCachedL_ = p->seqNumbersL_ ] )
{ {
rtl_copyMemory( (void*)initialWordsCached_,
(void*)p->initialWords_,
sizeof(sal_Int32) * p->initialWordsL_ );
rtl_copyMemory( (void*)destsCached_,
(void*)p->dests_,
sizeof(sal_Int32) * p->destsL_ );
rtl_copyMemory( (void*)linkTypesCached_,
(void*)p->linkTypes_,
sizeof(sal_Int32) * p->linkTypesL_ );
rtl_copyMemory( (void*)seqNumbersCached_,
(void*)p->seqNumbers_,
sizeof(sal_Int32) * p->seqNumbersL_ );
} }
...@@ -129,7 +148,6 @@ ContextTables::ContextTables( const std::vector< sal_Int32 >& offsets, ...@@ -129,7 +148,6 @@ ContextTables::ContextTables( const std::vector< sal_Int32 >& offsets,
contextData_( contextData ), contextData_( contextData ),
linkNamesL_( linkNamesL ), linkNamesL_( linkNamesL ),
linkNames_( linkNames ), linkNames_( linkNames ),
cache_( offsets.size() ), cache_( offsets.size() ),
initialWordsL_( 0 ), initialWordsL_( 0 ),
initialWords_( 0 ), initialWords_( 0 ),
...@@ -179,6 +197,7 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -179,6 +197,7 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
auxArray_.clear(); auxArray_.clear();
compr.ascDecode( kTable_[0],auxArray_ ); // _initialWords compr.ascDecode( kTable_[0],auxArray_ ); // _initialWords
delete[] initialWords_;
initialWords_ = new sal_Int32[ initialWordsL_ = auxArray_.size() ]; initialWords_ = new sal_Int32[ initialWordsL_ = auxArray_.size() ];
sal_Int32 k; sal_Int32 k;
for( k = 0; k < initialWordsL_; ++k ) //?opt for( k = 0; k < initialWordsL_; ++k ) //?opt
...@@ -190,13 +209,16 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -190,13 +209,16 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
compr.decode( kTable_[1],auxArray_ ); // _dests compr.decode( kTable_[1],auxArray_ ); // _dests
auxArray_.push_back( -1 ); // sentinel, root auxArray_.push_back( -1 ); // sentinel, root
delete[] dests_;
dests_ = new sal_Int32[ destsL_ = auxArray_.size() ]; dests_ = new sal_Int32[ destsL_ = auxArray_.size() ];
for( k = 0; k < destsL_; ++k ) //?opt for( k = 0; k < destsL_; ++k ) //?opt
dests_[k] = auxArray_[k]; dests_[k] = auxArray_[k];
delete[] linkTypes_;
linkTypes_ = new sal_Int32[ linkTypesL_ = destsL_ - nTextNodes_ - 1 ]; linkTypes_ = new sal_Int32[ linkTypesL_ = destsL_ - nTextNodes_ - 1 ];
compr.decode( kTable_[2],linkTypes_ ); compr.decode( kTable_[2],linkTypes_ );
delete[] seqNumbers_;
seqNumbers_ = new sal_Int32[ seqNumbersL_ = destsL_ - 1 ]; seqNumbers_ = new sal_Int32[ seqNumbersL_ = destsL_ - 1 ];
compr.decode( kTable_[ 3 ],seqNumbers_ ); compr.decode( kTable_[ 3 ],seqNumbers_ );
...@@ -204,6 +226,7 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -204,6 +226,7 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
} }
lastDocNo_ = docNo; lastDocNo_ = docNo;
delete[] markers_;
markers_ = new sal_Int32[ markersL_ = destsL_ ]; markers_ = new sal_Int32[ markersL_ = destsL_ ];
} }
initialWordsIndex_ = 0; initialWordsIndex_ = 0;
...@@ -410,6 +433,19 @@ void ContextTables::resetContextSearch() ...@@ -410,6 +433,19 @@ void ContextTables::resetContextSearch()
} }
sal_Int32 ContextTables::wordContextLin(sal_Int32 wordNumber)
{
for (sal_Int32 i = initialWordsIndex_; i < nTextNodes_; ++i )
if (initialWords_[i] > wordNumber)
{ // first such i
// - 1 if wordNumbers can be the same
initialWordsIndex_ = i; // cached to speed up next search
return i - 1;
}
return nTextNodes_ - 1;
}
// void ContextTables::appendSegment( sal_Int32 context,rtl::OUStringBuffer& result ) // void ContextTables::appendSegment( sal_Int32 context,rtl::OUStringBuffer& result )
// { // {
// result.append( context < nTextNodes_ ? // result.append( context < nTextNodes_ ?
...@@ -686,15 +722,9 @@ void ContextTables::resetContextSearch() ...@@ -686,15 +722,9 @@ void ContextTables::resetContextSearch()
*/ */
sal_Int32 ContextTables::wordContextLin(sal_Int32 wordNumber)
{
for (sal_Int32 i = initialWordsIndex_; i < nTextNodes_; ++i )
if (initialWords_[i] > wordNumber)
{ // first such i
// - 1 if wordNumbers can be the same
initialWordsIndex_ = i; // cached to speed up next search
return i - 1;
}
return nTextNodes_ - 1;
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: DocGenerator.cxx,v $ * $RCSfile: DocGenerator.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: abi $ $Date: 2001-06-06 14:48:47 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -87,7 +87,8 @@ RoleFiller::RoleFiller() ...@@ -87,7 +87,8 @@ RoleFiller::RoleFiller()
limit_( 0 ), limit_( 0 ),
parentContext_( 0 ), parentContext_( 0 ),
next_( 0 ), next_( 0 ),
fillers_( 0 ) fillers_( 0 ),
m_nRefcount( 0 )
{ {
} }
...@@ -101,7 +102,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns, ...@@ -101,7 +102,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns,
: next_( 0 ), : next_( 0 ),
conceptData_( first ), conceptData_( first ),
fixedRole_( sal_uInt8( role & 0xF ) ), // primary/constitutive concept/role fixedRole_( sal_uInt8( role & 0xF ) ), // primary/constitutive concept/role
fillers_( nColumns ) fillers_( nColumns ),
m_nRefcount( 0 )
{ {
filled_ = sal_Int16( 1 << fixedRole_ ); filled_ = sal_Int16( 1 << fixedRole_ );
begin_ = pos; // offset in file begin_ = pos; // offset in file
...@@ -119,7 +121,9 @@ RoleFiller::RoleFiller( sal_Int32 nColumns, ...@@ -119,7 +121,9 @@ RoleFiller::RoleFiller( sal_Int32 nColumns,
RoleFiller::~RoleFiller() RoleFiller::~RoleFiller()
{ {
for( sal_uInt32 i = 0; i < fillers_.size(); ++i ) for( sal_uInt32 i = 0; i < fillers_.size(); ++i )
delete fillers_[i]; ;
// if( fillers_[i] != this )
// delete fillers_[i];
} }
...@@ -193,7 +197,7 @@ sal_Int32 RoleFiller::getConcept() ...@@ -193,7 +197,7 @@ sal_Int32 RoleFiller::getConcept()
void RoleFiller::use( std::vector< RoleFiller*>& place,sal_Int32 query ) void RoleFiller::use( std::vector< RoleFiller*>& place,sal_Int32 query )
{ {
RoleFiller* rf; RoleFiller* rf,*tmp;
if( rf = place[ query ] ) if( rf = place[ query ] )
{ {
place[ query ] = this; // put at the head of list place[ query ] = this; // put at the head of list
...@@ -317,7 +321,9 @@ void NextDocGeneratorHeap::step() throw( excep::XmlSearchException ) ...@@ -317,7 +321,9 @@ void NextDocGeneratorHeap::step() throw( excep::XmlSearchException )
heapify(0); heapify(0);
else if ( heapSize_ > 1 ) else if ( heapSize_ > 1 )
{ {
delete heap_[0];
heap_[0] = heap_[--heapSize_]; heap_[0] = heap_[--heapSize_];
heap_[ heapSize_ ] = 0;
heapify(0); heapify(0);
} }
else else
...@@ -363,8 +369,6 @@ ConceptGroupGenerator::ConceptGroupGenerator( sal_Int32 dataL,sal_Int8* data,sal ...@@ -363,8 +369,6 @@ ConceptGroupGenerator::ConceptGroupGenerator( sal_Int32 dataL,sal_Int8* data,sal
bits_( new util::ByteArrayDecompressor( dataL,data,index ) ), bits_( new util::ByteArrayDecompressor( dataL,data,index ) ),
table_( NConceptsInGroup ) table_( NConceptsInGroup )
{ {
for( sal_Int32 i = 0; i < NConceptsInGroup; ++i )
table_[i] = 0;
} }
...@@ -396,7 +400,7 @@ bool ConceptGroupGenerator::next() throw( excep::XmlSearchException ) ...@@ -396,7 +400,7 @@ bool ConceptGroupGenerator::next() throw( excep::XmlSearchException )
while( bits_->readNext( k1_,this ) ) while( bits_->readNext( k1_,this ) )
{ {
sal_Int32 bla = bits_->read( k2_ ); sal_Int32 bla = bits_->read( k2_ );
if( cData_ = table_[ bla ] ) if( ( cData_ = table_[ bla ] ).is() )
return true; return true;
} }
return false; return false;
...@@ -420,10 +424,7 @@ void ConceptGroupGenerator::init( sal_Int32 bytesL,sal_Int8* bytes,sal_Int32 ind ...@@ -420,10 +424,7 @@ void ConceptGroupGenerator::init( sal_Int32 bytesL,sal_Int8* bytes,sal_Int32 ind
bits_ = new util::ByteArrayDecompressor( bytesL,bytes,index ); bits_ = new util::ByteArrayDecompressor( bytesL,bytes,index );
last_ = 0; last_ = 0;
for( sal_Int32 i = 0;i < NConceptsInGroup; i++ ) for( sal_Int32 i = 0;i < NConceptsInGroup; i++ )
{
// delete table_[i];
table_[i] = 0; table_[i] = 0;
}
} }
...@@ -511,6 +512,7 @@ bool GeneratorHeap::next( std::vector< RoleFiller* >& array ) throw( xmlsearch:: ...@@ -511,6 +512,7 @@ bool GeneratorHeap::next( std::vector< RoleFiller* >& array ) throw( xmlsearch::
{ {
delete heap_[0]; delete heap_[0];
heap_[0] = heap_[--heapSize_]; heap_[0] = heap_[--heapSize_];
heap_[heapSize_] = 0;
} }
else else
{ {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: Query.cxx,v $ * $RCSfile: Query.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: abi $ $Date: 2001-05-11 12:39:12 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -153,10 +153,7 @@ QueryHit* HitStore::firstBestQueryHit() ...@@ -153,10 +153,7 @@ QueryHit* HitStore::firstBestQueryHit()
{ {
if( free_ > 0) if( free_ > 0)
{ {
// for( sal_uInt32 i = 0; i < heap_.size(); ++i ) CompareQueryHit bla;
// printf( " number = %x\n",heap_[i] );
CompareQueryHit bla;
heap_.resize( free_ ); heap_.resize( free_ );
std::stable_sort( heap_.begin(),heap_.end(),bla ); std::stable_sort( heap_.begin(),heap_.end(),bla );
index_ = 0; index_ = 0;
...@@ -247,13 +244,15 @@ Query::Query( XmlIndex* env, ...@@ -247,13 +244,15 @@ Query::Query( XmlIndex* env,
ctx_( env ? env->getContextInfo() : 0 ), ctx_( env ? env->getContextInfo() : 0 ),
nColumns_( nColumns ), nColumns_( nColumns ),
nHitsRequested_( nHits ), nHitsRequested_( nHits ),
missingPenalty_( new double[ missingPenaltyL_ = nColumns_ ] ) , missingPenaltyL_( nColumns ),
upperboundTemplate_( new double[ upperboundTemplateL_ = nColumns_ ] ), missingPenalty_( new double[ nColumns ] ),
upperboundTemplateL_( nColumns ),
upperboundTemplate_( new double[ nColumns ] ),
penaltiesL_( missingPenaltiesL ), penaltiesL_( missingPenaltiesL ),
penalties_( missingPenalties ), penalties_( missingPenalties ),
currentStandard_( nColumns * MissingTermPenalty - 0.0001 ), currentStandard_( nColumns * MissingTermPenalty - 0.0001 ),
missingTermsPenalty_( 0.0 ), missingTermsPenalty_( 0.0 ),
store_( currentStandard_,nHits,nColumns ), store_( nColumns * MissingTermPenalty - 0.0001,nHits,nColumns ),
ignoredElementsL_( 0 ), ignoredElementsL_( 0 ),
ignoredElements_( 0 ) ignoredElements_( 0 )
{ {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: QueryProcessor.cxx,v $ * $RCSfile: QueryProcessor.cxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: abi $ $Date: 2001-06-19 13:41:05 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: Search.cxx,v $ * $RCSfile: Search.cxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: abi $ $Date: 2001-06-06 14:48:47 $ * last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -99,10 +99,10 @@ public: ...@@ -99,10 +99,10 @@ public:
{ {
} }
virtual ConceptData* makeConceptData( sal_Int32 query, ConceptData* makeConceptData( sal_Int32 col,
sal_Int32 col, sal_Int32 concept,
sal_Int32 concept, double penalty,
double score ) sal_Int32 queryNo )
{ {
return &conceptDataInstance_; return &conceptDataInstance_;
} }
...@@ -203,7 +203,7 @@ void ConceptData1::generateFillers( std::vector< RoleFiller* >& array, sal_Int32 ...@@ -203,7 +203,7 @@ void ConceptData1::generateFillers( std::vector< RoleFiller* >& array, sal_Int32
} }
} }
if( next_ ) if( next_.is() )
next_->generateFillers( array,pos ); next_->generateFillers( array,pos );
} }
...@@ -232,6 +232,8 @@ public: ...@@ -232,6 +232,8 @@ public:
Query* makeQuery( XmlIndex* env,const rtl::OUString& context,sal_Int32 nColumns,sal_Int32 nHits); Query* makeQuery( XmlIndex* env,const rtl::OUString& context,sal_Int32 nColumns,sal_Int32 nHits);
Query* empty() { return &emptyQueryInstance_; }
private: private:
EmptyQuery emptyQueryInstance_; EmptyQuery emptyQueryInstance_;
...@@ -298,17 +300,17 @@ Search::Search( XmlIndex* env ) ...@@ -298,17 +300,17 @@ Search::Search( XmlIndex* env )
Search::~Search() Search::~Search()
{ {
delete queryFactory_;
sal_uInt32 i; sal_uInt32 i;
Query* stopq = queryFactory_ ? queryFactory_->empty() : 0;
ConceptData* stopc = stopq ? stopq->makeConceptData( 0,0,0.0,0 ) : 0;
for( i = 0; i < queries_.size(); ++i ) for( i = 0; i < queries_.size(); ++i )
delete queries_[i]; if( queries_[i] != stopq )
delete queries_[i];
for( i = 0; i < conceptData_.size(); ++i )
delete conceptData_[i];
delete[] concepts_; delete[] concepts_;
delete queryFactory_;
} }
...@@ -360,7 +362,7 @@ void Search::startSearch() ...@@ -360,7 +362,7 @@ void Search::startSearch()
{ {
for (j = i + 1; j < free2_; j++) for (j = i + 1; j < free2_; j++)
{ {
if( conceptData_[i]->crqEquals( conceptData_[j] ) ) if( conceptData_[i]->crqEquals( conceptData_[j].get() ) )
conceptData_[j] = 0; conceptData_[j] = 0;
else else
i = j; i = j;
...@@ -372,10 +374,10 @@ void Search::startSearch() ...@@ -372,10 +374,10 @@ void Search::startSearch()
{ {
for (j = i + 1; j < free2_; j++ ) for (j = i + 1; j < free2_; j++ )
{ {
if( conceptData_[j] ) if( conceptData_[j].is() )
if( conceptData_[i]->cEquals( conceptData_[j] ) ) if( conceptData_[i]->cEquals( conceptData_[j].get() ) )
{ {
conceptData_[i]->addLast( conceptData_[j] ); conceptData_[i]->addLast( conceptData_[j].get() );
conceptData_[j] = 0; conceptData_[j] = 0;
} }
else else
...@@ -386,11 +388,11 @@ void Search::startSearch() ...@@ -386,11 +388,11 @@ void Search::startSearch()
// densify // densify
for( i = 0; i < free2_ - 1; i++) for( i = 0; i < free2_ - 1; i++)
{ {
if( ! conceptData_[i] ) if( ! conceptData_[i].is() )
{ {
for( j = i + 1; j < free2_; j++) for( j = i + 1; j < free2_; j++)
{ {
if (conceptData_[j] ) if (conceptData_[j].is() )
{ {
conceptData_[i] = conceptData_[j]; conceptData_[i] = conceptData_[j];
conceptData_[j] = 0; conceptData_[j] = 0;
...@@ -402,9 +404,9 @@ void Search::startSearch() ...@@ -402,9 +404,9 @@ void Search::startSearch()
// set up new document generators // set up new document generators
nextDocGenHeap_.reset(); nextDocGenHeap_.reset();
for( i = 0; i < free2_ && conceptData_[i]; i++) for( i = 0; i < free2_ && conceptData_[i].is(); i++)
{ {
NextDocGenerator* gen = new NextDocGenerator( conceptData_[i],env_ ); NextDocGenerator* gen = new NextDocGenerator( conceptData_[i].get(),env_ );
try try
{ {
sal_Int32 doc; sal_Int32 doc;
...@@ -441,7 +443,7 @@ void Search::addTerm( sal_Int32 col,sal_Int32 concept,double score ) ...@@ -441,7 +443,7 @@ void Search::addTerm( sal_Int32 col,sal_Int32 concept,double score )
if( sal_uInt32( free2_ ) == conceptData_.size() ) if( sal_uInt32( free2_ ) == conceptData_.size() )
{ {
conceptData_.push_back( 0 ); conceptData_.push_back( 0 );
conceptVisitor_ = &conceptData_[0]; // conceptVisitor_ = &conceptData_[0];
} }
conceptData_[ free2_++ ] = cd; conceptData_[ free2_++ ] = cd;
} }
...@@ -495,10 +497,12 @@ void Search::searchDocument() ...@@ -495,10 +497,12 @@ void Search::searchDocument()
genHeap_.reset(); genHeap_.reset();
} }
while( nextDocGenHeap_.isNonEmpty() ); while( nextDocGenHeap_.isNonEmpty() );
}
for( sal_Int32 i = 0; i < start.size(); ++i )
if( start[i] != RoleFiller::STOP() )
delete start[i];
}
extern void print_rtl_OUString( const rtl::OUString bla );
sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlsearch::excep::XmlSearchException ) sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlsearch::excep::XmlSearchException )
...@@ -520,7 +524,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse ...@@ -520,7 +524,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse
{ {
docConcepts_.push_back( nextDocGenHeap_.getConcept() ); docConcepts_.push_back( nextDocGenHeap_.getConcept() );
queryMasks_.push_back( nextDocGenHeap_.getQueryMask() ); queryMasks_.push_back( nextDocGenHeap_.getQueryMask() );
ConceptData *conceptData = ( conceptData_[ index++ ] = nextDocGenHeap_.getTerms() ); ConceptData *conceptData = ( conceptData_[ index++ ] = nextDocGenHeap_.getTerms() ).get();
conceptData->runBy( queries_ ); conceptData->runBy( queries_ );
nextDocGenHeap_.step(); nextDocGenHeap_.step();
} }
...@@ -559,7 +563,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse ...@@ -559,7 +563,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse
ConceptGroupGenerator* gen; ConceptGroupGenerator* gen;
// !!! don't gather Fillers for disinterested Queries // !!! don't gather Fillers for disinterested Queries
if( openDocumentIndex( document_ ) ) if( openDocumentIndex( document_ ) )
{// multi group { // multi group
// set up all needed generators // set up all needed generators
sal_Int32 i = 0; sal_Int32 i = 0;
while( ( queryMasks_[i] & voteMask ) == 0 ) while( ( queryMasks_[i] & voteMask ) == 0 )
...@@ -568,10 +572,11 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse ...@@ -568,10 +572,11 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse
sal_Int32 c = docConcepts_[i]; sal_Int32 c = docConcepts_[i];
sal_Int32 group = 0; sal_Int32 group = 0;
// find first group // find first group
while( c > maxConcepts_[ group ] && ++group < limit_ ) while( /*group < maxConcepts_.size() &&*/
c > maxConcepts_[ group ] && ++group < limit_ )
; ;
gen = makeGenerator( group ); gen = makeGenerator( group );
gen->addTerms( indexOf(c), conceptData_[i] ); gen->addTerms( indexOf(c),conceptData_[i].get() );
for( ++i; i < index; i++ ) for( ++i; i < index; i++ )
if( ( queryMasks_[i] & voteMask ) > 0 ) if( ( queryMasks_[i] & voteMask ) > 0 )
...@@ -580,10 +585,12 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse ...@@ -580,10 +585,12 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse
if( c > max_ ) if( c > max_ )
{ // need to find another group { // need to find another group
// assert(group < _limit); // assert(group < _limit);
while( c > maxConcepts_[ group ] && ++group < limit_ ) ; while( /*group < maxConcepts_.size() &&*/
c > maxConcepts_[ group ] && ++group < limit_ )
;
gen = makeGenerator( group ); gen = makeGenerator( group );
} }
gen->addTerms( indexOf(c), conceptData_[i] ); gen->addTerms( indexOf(c),conceptData_[i].get() );
} }
return 0; return 0;
} }
...@@ -591,7 +598,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse ...@@ -591,7 +598,7 @@ sal_Int32 Search::nextDocument( std::vector< RoleFiller* >& start ) throw( xmlse
{ // single group { // single group
for( sal_Int32 i = 0; i < index; i++ ) for( sal_Int32 i = 0; i < index; i++ )
if( queryMasks_[i] & voteMask ) if( queryMasks_[i] & voteMask )
firstGenerator_.addTerms( indexOf( docConcepts_[i] ),conceptData_[i] ); firstGenerator_.addTerms( indexOf( docConcepts_[i] ),conceptData_[i].get() );
return 1; return 1;
} }
} }
...@@ -667,7 +674,7 @@ ConceptGroupGenerator* Search::makeGenerator( sal_Int32 group ) ...@@ -667,7 +674,7 @@ ConceptGroupGenerator* Search::makeGenerator( sal_Int32 group )
// initialize generator // initialize generator
ConceptGroupGenerator* gen = ConceptGroupGenerator* gen =
new ConceptGroupGenerator( dataL_,data_,index,kTable_[ 2*group + 1 ] ); new ConceptGroupGenerator( dataL_,data_,index,kTable_[ 1 + 2*group ] );
// decode concept table // decode concept table
nConcepts_ = gen->decodeConcepts( kTable_[2*group],shift,concepts_ ); nConcepts_ = gen->decodeConcepts( kTable_[2*group],shift,concepts_ );
...@@ -704,17 +711,17 @@ sal_Int32 Search::indexOf(sal_Int32 concept) throw( excep::XmlSearchException ) ...@@ -704,17 +711,17 @@ sal_Int32 Search::indexOf(sal_Int32 concept) throw( excep::XmlSearchException )
sal_Int32 Search::partition( sal_Int32 p,sal_Int32 r ) sal_Int32 Search::partition( sal_Int32 p,sal_Int32 r )
{ {
ConceptData* x = conceptData_[ ((p + r) >> 1) & 0x7FFFFFFF ]; rtl::Reference< ConceptData > x = conceptData_[ ((p + r) >> 1) & 0x7FFFFFFF ];
sal_Int32 i = p - 1, j = r + 1; sal_Int32 i = p - 1, j = r + 1;
while( true ) while( true )
{ {
while( x->compareWith( conceptData_[--j] ) ) while( x->compareWith( conceptData_[--j].get() ) )
; ;
while( conceptData_[++i]->compareWith( x ) ) while( conceptData_[++i]->compareWith( x.get() ) )
; ;
if( i < j ) if( i < j )
{ {
ConceptData* t = conceptData_[i]; rtl::Reference< ConceptData > t = conceptData_[i];
conceptData_[i] = conceptData_[j]; conceptData_[i] = conceptData_[j];
conceptData_[j] = t; conceptData_[j] = t;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment