Kaydet (Commit) 9ec753da authored tarafından Andreas Bille's avatar Andreas Bille

Bug fixing

üst f796ed6d
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ConceptData.cxx,v $ * $RCSfile: ConceptData.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
* *
* 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
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#ifndef _XMLSEARCH_QE_QUERY_HXX_ #ifndef _XMLSEARCH_QE_QUERY_HXX_
#include <qe/Query.hxx> #include <qe/Query.hxx>
#endif #endif
#include <stdio.h>
using namespace xmlsearch::qe; using namespace xmlsearch::qe;
...@@ -71,17 +72,45 @@ using namespace xmlsearch::qe; ...@@ -71,17 +72,45 @@ using namespace xmlsearch::qe;
const sal_Int32 ConceptData::ProxPerTerm = 10; const sal_Int32 ConceptData::ProxPerTerm = 10;
ConceptData::ConceptData( sal_Int32 id,
sal_Int32 role,
double score,
sal_Int32 queryNo,
sal_Int32 nColumns,
ContextTables* contextTables )
: queryNo_( sal_uInt8( queryNo & 0xF ) ),
nColumns_( sal_uInt8( nColumns & 0xF ) ),
concept_( id ),
proximity_( nColumns * ProxPerTerm ),
role_( sal_uInt8( role & 0xF ) ),
penalty_( score ),
ctx_( contextTables ),
next_( 0 )
{
}
void ConceptData::runBy( std::vector< Query* >& queries ) void ConceptData::runBy( std::vector< Query* >& queries )
{ {
ConceptData* cd = this; ConceptData* cd = this;
do do
{ {
queries[ cd->queryNo_ ]->updateEstimate( cd->role_,cd->penalty_ ); Query* query = queries[ cd->queryNo_ ];
query->updateEstimate( cd->role_,cd->penalty_ );
} }
while( cd = cd->next_ ); while( cd = cd->next_ );
} }
void ConceptData::addLast( ConceptData* r )
{
if( next_ )
next_->addLast( r );
else
next_ = r;
}
#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_ #ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
#include <qe/DocGenerator.hxx> #include <qe/DocGenerator.hxx>
#endif #endif
...@@ -91,13 +120,14 @@ void ConceptData::generateFillers( std::vector< RoleFiller* >& array, sal_Int32 ...@@ -91,13 +120,14 @@ void ConceptData::generateFillers( std::vector< RoleFiller* >& array, sal_Int32
{ {
if( array[ queryNo_ ] != RoleFiller::STOP() ) // not 'prohibited' if( array[ queryNo_ ] != RoleFiller::STOP() ) // not 'prohibited'
{ {
// cout << "Conc " << sal_Int32( nColumns_ ) << endl; sal_Int32 wcl = ctx_->wordContextLin( pos );
( new RoleFiller( nColumns_, RoleFiller* p = new RoleFiller( nColumns_,
this, this,
role_, role_,
pos, pos,
ctx_->wordContextLin( pos ), wcl,
pos + proximity_ ) )->use( array, queryNo_ ); pos + proximity_ );
p->use( array, queryNo_ );
} }
// !!! maybe eliminate tail recursion // !!! maybe eliminate tail recursion
if( next_ ) if( next_ )
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ContextTables.cxx,v $ * $RCSfile: ContextTables.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
* *
* 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
...@@ -189,12 +189,6 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -189,12 +189,6 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
compr.decode( k0,kTable_ ); compr.decode( k0,kTable_ );
// decompress initialWords into auxiliary array // decompress initialWords into auxiliary array
auxArray_.clear(); auxArray_.clear();
#ifdef ABIDEBUG
// cout << kTable_[0] << endl;
// exit(1);
#endif
compr.ascDecode( kTable_[0],auxArray_ ); // _initialWords compr.ascDecode( kTable_[0],auxArray_ ); // _initialWords
initialWords_ = new sal_Int32[ initialWordsL_ = auxArray_.size() ]; initialWords_ = new sal_Int32[ initialWordsL_ = auxArray_.size() ];
...@@ -212,10 +206,6 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -212,10 +206,6 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
for( k = 0; k < destsL_; ++k ) //?opt for( k = 0; k < destsL_; ++k ) //?opt
dests_[k] = auxArray_[k]; dests_[k] = auxArray_[k];
#ifdef ABIDEBUG
// cout << " linkTypesL_ = " << destsL_ - nTextNodes_ - 1 << endl;
#endif
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_ );
...@@ -223,21 +213,9 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce ...@@ -223,21 +213,9 @@ void ContextTables::setMicroindex( sal_Int32 docNo ) throw( excep::XmlSearchExce
compr.decode( kTable_[ 3 ],seqNumbers_ ); compr.decode( kTable_[ 3 ],seqNumbers_ );
cache_[docNo] = new Tables( this ); cache_[docNo] = new Tables( this );
/*
System.out.println("|_initialWords| = " + _nTextNodes);
System.out.println("|_dests| -1 = " + (_dests.length - 1));
System.out.println("|_seqNumbers| = " + _seqNumbers.length);
System.out.println("|_linkTypes| = " + _linkTypes.length);
*/
} }
lastDocNo_ = docNo; lastDocNo_ = docNo;
#ifdef ABIDEBUG
// cout << "destL_ = " << destsL_ << endl;
#endif
markers_ = new sal_Int32[ markersL_ = destsL_ ]; markers_ = new sal_Int32[ markersL_ = destsL_ ];
} }
initialWordsIndex_ = 0; initialWordsIndex_ = 0;
...@@ -296,10 +274,7 @@ bool ContextTables::notIgnored( sal_Int32 ctx, ...@@ -296,10 +274,7 @@ bool ContextTables::notIgnored( sal_Int32 ctx,
do do
{ {
if( ignoredElements[ linkTypes_[ ctx ] ] ) if( ignoredElements[ linkTypes_[ ctx ] ] )
{
// cout << rtl::OUString::createFromAscii( "hit ignored" ) << endl;
return false; return false;
}
} }
while( ( ctx = dests_[ ctx ] ) > -1 ); // parentContext 'hand inlined' while( ( ctx = dests_[ ctx ] ) > -1 ); // parentContext 'hand inlined'
return true; return true;
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: DocGenerator.cxx,v $ * $RCSfile: DocGenerator.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
* *
* 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
...@@ -78,6 +78,20 @@ const sal_Int32 ConceptGroupGenerator::BitsInLabel = 4; ...@@ -78,6 +78,20 @@ const sal_Int32 ConceptGroupGenerator::BitsInLabel = 4;
RoleFiller RoleFiller::roleFiller_; RoleFiller RoleFiller::roleFiller_;
RoleFiller::RoleFiller()
: conceptData_( 0 ),
fixedRole_( 0 ),
filled_( 0 ),
begin_( 0 ),
end_( 0 ),
limit_( 0 ),
parentContext_( 0 ),
next_( 0 ),
fillers_( 0 )
{
}
RoleFiller::RoleFiller( sal_Int32 nColumns, RoleFiller::RoleFiller( sal_Int32 nColumns,
ConceptData* first, ConceptData* first,
sal_Int32 role, sal_Int32 role,
...@@ -86,7 +100,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns, ...@@ -86,7 +100,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns,
sal_Int32 limit ) sal_Int32 limit )
: next_( 0 ), : next_( 0 ),
conceptData_( first ), conceptData_( first ),
fixedRole_( sal_Int8( role) ) // primary/constitutive concept/role fixedRole_( sal_uInt8( role & 0xF ) ), // primary/constitutive concept/role
fillers_( nColumns )
{ {
// cout << "RoleFiller constructed" << nColumns << ' ' << role << ' ' << pos << endl; // cout << "RoleFiller constructed" << nColumns << ' ' << role << ' ' << pos << endl;
filled_ = sal_Int16( 1 << fixedRole_ ); filled_ = sal_Int16( 1 << fixedRole_ );
...@@ -96,8 +111,7 @@ RoleFiller::RoleFiller( sal_Int32 nColumns, ...@@ -96,8 +111,7 @@ RoleFiller::RoleFiller( sal_Int32 nColumns,
limit_ = limit; limit_ = limit;
parentContext_ = parentContext; parentContext_ = parentContext;
next_ = 0; next_ = 0;
fillers_ = new RoleFiller*[ fillersL_ = nColumns ]; for( sal_uInt32 i = 0; i < fillers_.size(); ++i )
for( int i = 0; i < fillersL_; ++i )
fillers_[i] = 0; fillers_[i] = 0;
fillers_[ role ] = this; fillers_[ role ] = this;
} }
...@@ -105,9 +119,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns, ...@@ -105,9 +119,8 @@ RoleFiller::RoleFiller( sal_Int32 nColumns,
RoleFiller::~RoleFiller() RoleFiller::~RoleFiller()
{ {
for( int i = 0; i < fillersL_; ++i ) for( sal_uInt32 i = 0; i < fillers_.size(); ++i )
delete fillers_[i]; delete fillers_[i];
delete[] fillers_;
} }
...@@ -251,6 +264,66 @@ double RoleFiller::penalty( Query* query,sal_Int32 nColumns ) ...@@ -251,6 +264,66 @@ double RoleFiller::penalty( Query* query,sal_Int32 nColumns )
NextDocGenerator::NextDocGenerator( ConceptData* cd,XmlIndex* env )
: document_( 0 ),
concept_( cd ? cd->getConcept() : -1 ),
queryMask_( cd ? cd->getQueryMask() : -1 ),
terms_( cd ),
iterator_( env->getDocumentIterator( concept_ ) )
{
}
void NextDocGeneratorHeap::reset()
{
for( sal_Int32 i = 0; i < heapSize_; ++i )
{
delete heap_[i]; heap_[i] = 0;
}
free_ = 0;
nonEmpty_ = false;
}
void NextDocGeneratorHeap::addGenerator( NextDocGenerator* gen )
{
if( sal_uInt32( free_ ) == heap_.size() )
{
heap_.push_back( 0 );
}
heap_[free_++] = gen;
}
void NextDocGeneratorHeap::start()
{
if( ( heapSize_ = free_ ) > 0 )
{
for( sal_Int32 i = heapSize_ / 2; i >= 0; --i )
heapify(i);
nonEmpty_ = true;
}
else
nonEmpty_ = false;
}
void NextDocGeneratorHeap::step() throw( excep::XmlSearchException )
{
if( heap_[0]->next() != NonnegativeIntegerGenerator::END )
heapify(0);
else if ( heapSize_ > 1 )
{
heap_[0] = heap_[--heapSize_];
heapify(0);
}
else
nonEmpty_ = false;
}
void NextDocGeneratorHeap::heapify( sal_Int32 i ) void NextDocGeneratorHeap::heapify( sal_Int32 i )
...@@ -276,26 +349,14 @@ void NextDocGeneratorHeap::heapify( sal_Int32 i ) ...@@ -276,26 +349,14 @@ void NextDocGeneratorHeap::heapify( sal_Int32 i )
} }
void NextDocGeneratorHeap::step() throw( excep::XmlSearchException )
{
if( heap_[0]->next() != NonnegativeIntegerGenerator::END )
heapify(0);
else if ( heapSize_ > 1 )
{
heap_[0] = heap_[--heapSize_];
heapify(0);
}
else
nonEmpty_ = false;
}
bool NextDocGeneratorHeap::atDocument( sal_Int32 document ) bool NextDocGeneratorHeap::atDocument( sal_Int32 document )
{ {
return nonEmpty_ && heap_[0]->getDocument() == document; return nonEmpty_ && heap_[0]->getDocument() == document;
} }
ConceptGroupGenerator::ConceptGroupGenerator( sal_Int32 dataL,sal_Int8* data,sal_Int32 index,sal_Int32 k ) ConceptGroupGenerator::ConceptGroupGenerator( sal_Int32 dataL,sal_Int8* data,sal_Int32 index,sal_Int32 k )
: last_( 0 ), : last_( 0 ),
k1_( k ), k1_( k ),
...@@ -362,59 +423,43 @@ void ConceptGroupGenerator::init( sal_Int32 bytesL,sal_Int8* bytes,sal_Int32 ind ...@@ -362,59 +423,43 @@ void ConceptGroupGenerator::init( sal_Int32 bytesL,sal_Int8* bytes,sal_Int32 ind
last_ = 0; last_ = 0;
for( sal_Int32 i = 0;i < NConceptsInGroup; i++ ) for( sal_Int32 i = 0;i < NConceptsInGroup; i++ )
{ {
delete table_[i]; // delete table_[i];
table_[i] = 0; table_[i] = 0;
} }
} }
bool GeneratorHeap::start( std::vector< RoleFiller* >& array ) throw( xmlsearch::excep::XmlSearchException ) void ConceptGroupGenerator::addTerms( sal_Int32 index,ConceptData* terms )
{ {
if( ( heapSize_ = heap_.size() ) > 0 ) table_[ index ] = terms;
{
for( sal_Int32 i = 0; i < heapSize_; ++i )
heap_[i]->next();
buildHeap();
heap_[0]->generateFillers( array );
return true;
}
else
return false;
} }
bool GeneratorHeap::next( std::vector< RoleFiller* >& array ) throw( xmlsearch::excep::XmlSearchException )
void GeneratorHeap::reset()
{ {
if( heapSize_ > 0 ) for( sal_Int32 i = 0; i < heapSize_; ++i )
{ {
if( ! heap_[0]->next() ) // no more delete heap_[i]; heap_[i] = 0;
if( heapSize_ > 1)
heap_[0] = heap_[--heapSize_];
else
{
heapSize_ = 0;
return false;
}
heapify(0);
heap_[0]->generateFillers( array );
return true;
} }
else free_ = 0;
return false;
} }
void GeneratorHeap::addGenerator( ConceptGroupGenerator* cd )
void GeneratorHeap::reset()
{ {
for( sal_uInt32 i = 0; i < heap_.size(); ++i ) if( sal_uInt32( free_ ) == heap_.size() )
delete heap_[i]; {
heap_.clear(); heap_.push_back( 0 );
heapSize_ = 0; }
} else
{
// delete heap_[free_];
}
heap_[free_++] = cd;
}
void GeneratorHeap::buildHeap() void GeneratorHeap::buildHeap()
...@@ -428,8 +473,8 @@ void GeneratorHeap::heapify( sal_Int32 root ) ...@@ -428,8 +473,8 @@ void GeneratorHeap::heapify( sal_Int32 root )
{ {
for( sal_Int32 smallest = 0; ; ) for( sal_Int32 smallest = 0; ; )
{ {
sal_Int32 right = ( root + 1 ) << 1; const sal_Int32 right = ( root + 1 ) << 1;
sal_Int32 left = right - 1; const sal_Int32 left = right - 1;
smallest = ( left < heapSize_ && heap_[left]->position() < heap_[ root ]->position() ) ? left : root; smallest = ( left < heapSize_ && heap_[left]->position() < heap_[ root ]->position() ) ? left : root;
if( right< heapSize_ && heap_[right]->position() < heap_[smallest]->position() ) if( right< heapSize_ && heap_[right]->position() < heap_[smallest]->position() )
smallest = right; smallest = right;
...@@ -445,3 +490,42 @@ void GeneratorHeap::heapify( sal_Int32 root ) ...@@ -445,3 +490,42 @@ void GeneratorHeap::heapify( sal_Int32 root )
} }
} }
bool GeneratorHeap::start( std::vector< RoleFiller* >& array ) throw( xmlsearch::excep::XmlSearchException )
{
if( ( heapSize_ = free_ ) > 0 )
{
for( sal_Int32 i = 0; i < free_; ++i )
heap_[i]->next();
buildHeap();
heap_[0]->generateFillers( array );
return true;
}
else
return false;
}
bool GeneratorHeap::next( std::vector< RoleFiller* >& array ) throw( xmlsearch::excep::XmlSearchException )
{
if( heapSize_ > 0 )
{
if( ! heap_[0]->next() ) // no more
if( heapSize_ > 1)
{
delete heap_[0];
heap_[0] = heap_[--heapSize_];
}
else
{
heapSize_ = 0;
return false;
}
heapify(0);
heap_[0]->generateFillers( array );
return true;
}
else
return false;
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: Query.cxx,v $ * $RCSfile: Query.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
* *
* 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 @@ using namespace xmlsearch::qe; ...@@ -87,7 +87,8 @@ using namespace xmlsearch::qe;
HitStore::HitStore( double initialStandard,sal_Int32 limit,sal_Int32 nColumns ) HitStore::HitStore( double initialStandard,sal_Int32 limit,sal_Int32 nColumns )
: standard_( initialStandard ), : standard_( initialStandard ),
heap_( limit_ = limit ), limit_( limit ),
heap_( limit ),
nColumns_( nColumns ), nColumns_( nColumns ),
free_( 0 ), free_( 0 ),
index_( 0 ) index_( 0 )
...@@ -112,7 +113,6 @@ bool HitStore::goodEnough( double penalty, sal_Int32 begin, sal_Int32 end ) ...@@ -112,7 +113,6 @@ bool HitStore::goodEnough( double penalty, sal_Int32 begin, sal_Int32 end )
} }
QueryHit* HitStore::createQueryHit( double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end ) QueryHit* HitStore::createQueryHit( double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end )
{ {
QueryHit* hit = new QueryHit( nColumns_,penalty,doc,begin,end ); QueryHit* hit = new QueryHit( nColumns_,penalty,doc,begin,end );
...@@ -137,15 +137,63 @@ QueryHit* HitStore::createQueryHit( double penalty,sal_Int32 doc,sal_Int32 begin ...@@ -137,15 +137,63 @@ QueryHit* HitStore::createQueryHit( double penalty,sal_Int32 doc,sal_Int32 begin
} }
struct CompareQueryHit
{
inline int operator()( const QueryHit* l,const QueryHit* r );
};
int CompareQueryHit::operator()( const QueryHit* l,const QueryHit* r )
{
return l->compareTo( r );
}
#include <stl/algorithm> #include <stl/algorithm>
sal_Int32 QueryHit::compareTo( const QueryHit* o ) const
{
if( penalty_ != o->penalty_ )
return penalty_ < o->penalty_ ? -1 : 1;
else if( begin_ != o->begin_ )
return begin_ < o->begin_ ? -1 : 1;
else if( end_ != o->end_ )
return end_ < o->end_ ? -1 : 1;
else
return 0;
}
QueryHit* HitStore::firstBestQueryHit() QueryHit* HitStore::firstBestQueryHit()
{ {
// for( sal_uInt32 i = 0; i < heap_.size(); ++i )
// {
// heap_[i]->setNum( i );
// printf( " element %d = %x\n",i,heap_[i] );
// }
// printf( " and the size %d(%d)\n", free_,heap_.size() );
if( free_ > 0) if( free_ > 0)
{ {
// std::sort( heap_.begin(),heap_.end() ); // std::vector< sal_Int32 > bla(100);
// Arrays.sort( heap_,0,free_ ); // for( i = 0; i < 100; ++i )
// bla[i] = i*(i-99);
// std::sort( bla.begin(),bla.end() );
// CompareQueryHit bla;
// std::sort( heap_.begin(),heap_.end(),bla );
// quicksort( 0,free_ - 1 );
// for( i = 0; i < heap_.size(); ++i )
// {
// heap_[i]->setNum( i );
// printf( " element %d = %x\n",i,heap_[i] );
// }
index_ = 0; index_ = 0;
return nextBestQueryHit(); return nextBestQueryHit();
} }
...@@ -181,6 +229,38 @@ void HitStore::heapify( sal_Int32 i ) ...@@ -181,6 +229,38 @@ void HitStore::heapify( sal_Int32 i )
} }
sal_Int32 HitStore::partition( sal_Int32 p,sal_Int32 r )
{
QueryHit* x = heap_[ ((p + r) >> 1) & 0x7FFFFFFF ];
sal_Int32 i = p - 1, j = r + 1;
while( true )
{
while( x->compareTo( heap_[--j] ) )
;
while( heap_[++i]->compareTo( x ) )
;
if( i < j )
{
QueryHit* t = heap_[i];
heap_[i] = heap_[j];
heap_[j] = t;
}
else
return j;
}
}
void HitStore::quicksort( sal_Int32 p,sal_Int32 r )
{
while( p < r )
{
sal_Int32 q = partition( p,r );
quicksort(p, q);
p = q + 1;
}
}
/******************************************************************************/ /******************************************************************************/
...@@ -214,8 +294,6 @@ Query::Query( XmlIndex* env, ...@@ -214,8 +294,6 @@ Query::Query( XmlIndex* env,
{ {
// for the EmptyQuery case (awaits arch improvement pass) // for the EmptyQuery case (awaits arch improvement pass)
//cout << " upperboundTemplateL_ = " << upperboundTemplateL_ << endl;
if( missingPenalties ) if( missingPenalties )
for( sal_Int32 i = 0;i < nColumns_; ++i ) for( sal_Int32 i = 0;i < nColumns_; ++i )
missingPenalty_[i] = missingPenalties[i]; missingPenalty_[i] = missingPenalties[i];
...@@ -340,6 +418,12 @@ bool Query::vote() ...@@ -340,6 +418,12 @@ bool Query::vote()
} }
void Query::updateEstimate( sal_Int32 role,double penalty )
{
if( penalty < upperboundTemplate_[ role ] )
upperboundTemplate_[ role ] = penalty;
}
/******************************************************************************/ /******************************************************************************/
/* */ /* */
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XmlIndex.cxx,v $ * $RCSfile: XmlIndex.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
* *
* 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
...@@ -325,3 +325,29 @@ void XmlIndex::readMicroindexes( sal_Int32 docNo ) throw( xmlsearch::excep::IOEx ...@@ -325,3 +325,29 @@ void XmlIndex::readMicroindexes( sal_Int32 docNo ) throw( xmlsearch::excep::IOEx
positionsFile_->seek( currentBatchOffset_ ); positionsFile_->seek( currentBatchOffset_ );
positionsFile_->readBytes( positions_,upTo - currentBatchOffset_ ); positionsFile_->readBytes( positions_,upTo - currentBatchOffset_ );
} }
#ifndef _XMLSEARCH_QE_QUERY_HXX_
#include <qe/Query.hxx>
#endif
QueryHitData* XmlIndex::hitToData( QueryHit* hit )
{
sal_Int32 termsL,matchesL;
sal_Int32 *matches = hit->getMatches( matchesL );
rtl::OUString *terms = new rtl::OUString[ termsL = matchesL >>/*>*/ 1 ];
for( sal_Int32 i = 0; i < termsL; ++i )
if( matches[ i << 1 ] > 0 )
terms[i] = fetch( matches[i << 1] );
sal_Int32 document = hit->getDocument();
QueryHitData *res = new QueryHitData( hit->getPenalty(),
documentName( document ),
termsL,terms );
contextTables_->setMicroindex( document );
contextTables_->resetContextSearch();
// contextTables_->hitLocation(terms, matches, result);
return res;
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $RCSfile: makefile.mk,v $
# #
# $Revision: 1.1 $ # $Revision: 1.2 $
# #
# last change: $Author: abi $ $Date: 2001-05-08 12:02:45 $ # last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
# #
# 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
...@@ -70,13 +70,11 @@ ENABLE_EXCEPTIONS=TRUE ...@@ -70,13 +70,11 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings ----------------------------------------------------- # --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk .INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Files -------------------------------------------------------- .IF "$(GUI)"=="WNT"
CFLAGS+=/GR
.IF "$(header)" == "" .ENDIF
SLOFILES=\ SLOFILES=\
$(SLO)$/ConceptData.obj \ $(SLO)$/ConceptData.obj \
...@@ -86,7 +84,6 @@ SLOFILES=\ ...@@ -86,7 +84,6 @@ SLOFILES=\
$(SLO)$/QueryProcessor.obj \ $(SLO)$/QueryProcessor.obj \
$(SLO)$/Search.obj \ $(SLO)$/Search.obj \
$(SLO)$/XmlIndex.obj $(SLO)$/XmlIndex.obj
.ENDIF
# --- Targets ------------------------------------------------------ # --- Targets ------------------------------------------------------
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $RCSfile: makefile.mk,v $
# #
# $Revision: 1.1 $ # $Revision: 1.2 $
# #
# last change: $Author: abi $ $Date: 2001-05-08 12:08:05 $ # last change: $Author: abi $ $Date: 2001-05-10 15:26:22 $
# #
# 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
...@@ -71,48 +71,30 @@ ENABLE_EXCEPTIONS=TRUE ...@@ -71,48 +71,30 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings --- # --- Settings ---
.INCLUDE : svpre.mk
.INCLUDE : settings.mk .INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Files ---
.IF "$(depend)" != "" .IF "$(GUI)"=="WNT"
CFLAGS+=/GR
.ENDIF
# --- Files ---
OBJFILES=\ OBJFILES=\
$(OBJ)$/searchdemo.obj $(OBJ)$/searchdemo.obj
.ENDIF # depend
#SRSFILES= $(SRS)$/ucbdemo.srs
#
# UCBDEMO
#
APP1TARGET= searchdemo APP1TARGET= searchdemo
APP1OBJS=\ APP1OBJS=\
$(OBJ)$/searchdemo.obj $(OBJ)$/searchdemo.obj
#APP1RES= $(RES)$/searchdemo.res
#.IF "$(COMPHELPERLIB)"==""
#.IF "$(GUI)" == "UNX"
#COMPHELPERLIB=-licomphelp2
#.ENDIF # unx
#.IF "$(GUI)"=="WNT"
#COMPHELPERLIB=icomphelp2.lib
#.ENDIF # wnt
#.ENDIF
APP1STDLIBS=\ APP1STDLIBS=\
$(SALLIB) \ $(SALLIB) \
$(VOSLIB) \ $(VOSLIB)
jaqe.lib \
jadb.lib \ APP1LIBS=\
jautil.lib $(SLB)/jaqe.lib \
$(SLB)/jadb.lib \
$(SLB)/jautil.lib
APP1DEF= $(MISC)\$(APP1TARGET).def APP1DEF= $(MISC)\$(APP1TARGET).def
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: searchdemo.cxx,v $ * $RCSfile: searchdemo.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:08:05 $ * last change: $Author: abi $ $Date: 2001-05-10 15:26:22 $
* *
* 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
...@@ -83,19 +83,19 @@ extern RandomAccessStream* theFile(); ...@@ -83,19 +83,19 @@ extern RandomAccessStream* theFile();
// ostream& operator<<( ostream& out,const rtl::OUString& bla ) void print_rtl_OUString( const rtl::OUString bla )
// { {
// out << bla.getLength() << endl; rtl::OString bluber = rtl::OString( bla.getStr(),bla.getLength(),RTL_TEXTENCODING_UTF8 );
// rtl::OString bluber = rtl::OString( bla.getStr(),bla.getLength(),RTL_TEXTENCODING_UTF8 ); char* bluberChr = new char[ 1+bluber.getLength() ];
// char* bluberChr = new char[ 1+bluber.getLength() ]; const sal_Char* jux = bluber.getStr();
// const sal_Char* jux = bluber.getStr();
// for( int i = 0; i < bluber.getLength(); ++i ) for( int i = 0; i < bluber.getLength(); ++i )
// bluberChr[i] = jux[i]; bluberChr[i] = jux[i];
// bluberChr[ bluber.getLength() ] = 0; bluberChr[ bluber.getLength() ] = 0;
// return out << bluberChr; printf( "%s\n",bluberChr );
// } delete[] bluberChr;
}
extern void bla(); extern void bla();
...@@ -109,13 +109,13 @@ int main( int argc,char* argv[] ) ...@@ -109,13 +109,13 @@ int main( int argc,char* argv[] )
try try
{ {
rtl::OUString installDir = rtl::OUString::createFromAscii( "//./home/ab106281/work/index" ); rtl::OUString installDir = rtl::OUString::createFromAscii( "//./e|/index/" );
QueryProcessor queryProcessor( installDir ); QueryProcessor queryProcessor( installDir );
std::vector<rtl::OUString> Query(1); std::vector<rtl::OUString> Query(1);
Query[0] = ( rtl::OUString::createFromAscii( "text*" ) ); Query[0] = ( rtl::OUString::createFromAscii( "text*" ) );
rtl::OUString Scope = rtl::OUString::createFromAscii( "" ); rtl::OUString Scope = rtl::OUString::createFromAscii( "" );
int HitCount = 100; int HitCount = 10;
QueryStatement queryStatement( HitCount,Query,Scope ); QueryStatement queryStatement( HitCount,Query,Scope );
queryResults = queryProcessor.processQuery( queryStatement ); queryResults = queryProcessor.processQuery( queryStatement );
...@@ -127,14 +127,22 @@ int main( int argc,char* argv[] ) ...@@ -127,14 +127,22 @@ int main( int argc,char* argv[] )
PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 ); PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 );
QueryHitIterator* it = queryResults->makeQueryHitIterator(); QueryHitIterator* it = queryResults->makeQueryHitIterator();
sal_Int32 j = 0;
while( it->next() ) while( it->next() )
; // cout << it->getHit( translator )->getDocument() << endl; {
printf( "Ergebnis %2d ",j );
QueryHitData* qhd = it->getHit( translator );
printf( "Penalty = %10.4f ",qhd->getPenalty() );
print_rtl_OUString( qhd->getDocument() );
++j;
}
delete it; delete it;
} }
catch( ... ) catch( ... )
{ {
printf( "catched exception" );
throw;
} }
return 0; return 0;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: IndexAccessor.cxx,v $ * $RCSfile: IndexAccessor.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: abi $ $Date: 2001-05-08 12:05:06 $ * last change: $Author: abi $ $Date: 2001-05-10 15:25:58 $
* *
* 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
...@@ -79,26 +79,7 @@ class RandomAccessStreamImpl ...@@ -79,26 +79,7 @@ class RandomAccessStreamImpl
{ {
public: public:
RandomAccessStreamImpl( const rtl::OUString& aPath,const rtl::OUString& how ) RandomAccessStreamImpl( const rtl::OUString& aPath,const rtl::OUString& how );
: file_( aPath )
{
sal_uInt32 flags = 0;
const sal_Unicode* bla = how.getStr();
for( int i = 0; i < how.getLength(); ++i )
if( bla[i] == sal_Unicode( 'r' ) )
flags |= Read;
else if( bla[i] == sal_Unicode( 'w' ) )
flags |= Write;
else if( bla[i] == sal_Unicode( 'c' ) )
flags |= Create;
if( file_.open( flags ) != osl::FileBase::E_None )
{
file_.close();
}
}
~RandomAccessStreamImpl() ~RandomAccessStreamImpl()
{ {
...@@ -113,7 +94,11 @@ public: ...@@ -113,7 +94,11 @@ public:
virtual sal_Int32 readBytes( sal_Int8* data,sal_Int32 num ) virtual sal_Int32 readBytes( sal_Int8* data,sal_Int32 num )
{ {
sal_uInt64 nbytesread; sal_uInt64 nbytesread;
file_.read( (void*)(data), sal_uInt64(num),nbytesread ); osl::FileBase::RC err = file_.read( (void*)(data), sal_uInt64(num),nbytesread );
if( err != osl::FileBase::E_None )
printf( "Bytes requested = %d, Bytes read = %d\n",num,sal_Int32( nbytesread ) );
return sal_Int32( nbytesread ); return sal_Int32( nbytesread );
} }
...@@ -126,7 +111,7 @@ public: ...@@ -126,7 +111,7 @@ public:
{ {
osl::DirectoryItem aItem; osl::DirectoryItem aItem;
osl::FileStatus aStatus( FileStatusMask_FileSize ); osl::FileStatus aStatus( FileStatusMask_FileSize );
osl::DirectoryItem::get( file_,aItem ); osl::DirectoryItem::get( path_,aItem );
aItem.getFileStatus( aStatus ); aItem.getFileStatus( aStatus );
return sal_Int32( aStatus.getFileSize() ); return sal_Int32( aStatus.getFileSize() );
} }
...@@ -139,13 +124,38 @@ public: ...@@ -139,13 +124,38 @@ public:
private: private:
osl::File file_; rtl::OUString path_;
osl::File file_;
}; };
RandomAccessStreamImpl::RandomAccessStreamImpl( const rtl::OUString& aPath,const rtl::OUString& how )
: path_( aPath ),
file_( aPath )
{
sal_uInt32 flags = 0;
const sal_Unicode* bla = how.getStr();
for( int i = 0; i < how.getLength(); ++i )
{
if( bla[i] == sal_Unicode( 'r' ) )
flags |= Read;
else if( bla[i] == sal_Unicode( 'w' ) )
flags |= Write;
else if( bla[i] == sal_Unicode( 'c' ) )
flags |= Create;
}
if( file_.open( flags ) != osl::FileBase::E_None )
{
printf( "RandomAccessStreamImpl closed" );
file_.close();
}
}
RandomAccessStreamImpl Dic( rtl::OUString::createFromAscii( "//./home/ab106281/work/index/DICTIONARY" ), RandomAccessStreamImpl Dic( rtl::OUString::createFromAscii( "//./e:/index/DICTIONARY" ),
rtl::OUString::createFromAscii( "how" ) ); rtl::OUString::createFromAscii( "r" ) );
RandomAccessStream* theFile() RandomAccessStream* theFile()
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $RCSfile: makefile.mk,v $
# #
# $Revision: 1.1 $ # $Revision: 1.2 $
# #
# last change: $Author: abi $ $Date: 2001-05-08 12:05:06 $ # last change: $Author: abi $ $Date: 2001-05-10 15:25:58 $
# #
# 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
...@@ -70,18 +70,15 @@ ENABLE_EXCEPTIONS=TRUE ...@@ -70,18 +70,15 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings ----------------------------------------------------- # --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk .INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Files -------------------------------------------------------- .IF "$(GUI)"=="WNT"
CFLAGS+=/GR
.IF "$(header)" == "" .ENDIF
SLOFILES=\ SLOFILES=\
$(SLO)$/Decompressor.obj \ $(SLO)$/Decompressor.obj \
$(SLO)$/IndexAccessor.obj $(SLO)$/IndexAccessor.obj
.ENDIF
# --- Targets ------------------------------------------------------ # --- Targets ------------------------------------------------------
......
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