Added checked index access

This commit is contained in:
Andreas Bille 2001-07-06 10:04:07 +00:00
parent 37b2983737
commit 340a82ed32
3 changed files with 32 additions and 10 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: BtreeDict.cxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* last change: $Author: abi $ $Date: 2001-07-06 11:04:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -357,7 +357,8 @@ void BlockProcessorImpl::process( Block* block ) const
BtreeDict::BtreeDict( const util::IndexAccessor& indexAccessor ) throw( IOException )
: blocks_( 0 ),
: blocksL_( 0 ),
blocks_( 0 ),
blockManager_( new DBEnvImpl( indexAccessor ) ) // may throw IOExcption
{
@ -379,7 +380,7 @@ BtreeDict::BtreeDict( const util::IndexAccessor& indexAccessor ) throw( IOExcept
idx = 4 + aStr.lastIndexOf( "id1=" );
sal_Int32 count = atoi( bff + idx );
blocks_ = new sal_Int32[ count ];
blocks_ = new sal_Int32[ blocksL_ = count ];
delete[] bff;
BlockProcessorImpl blProc( this );
@ -456,6 +457,9 @@ sal_Int32 BtreeDict::fetch( const rtl::OUString& key ) const throw( excep::XmlSe
rtl::OUString BtreeDict::fetch( sal_Int32 conceptID ) const throw( excep::XmlSearchException )
{
if( blocksL_ <= conceptID )
throw excep::XmlSearchException( rtl::OUString() );
return findID( blocks_[conceptID], conceptID );
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: Query.cxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: abi $ $Date: 2001-07-05 18:50:40 $
* last change: $Author: abi $ $Date: 2001-07-06 11:04:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -78,6 +78,13 @@
using namespace xmlsearch::qe;
sal_Int32* QueryHit::getMatches( sal_Int32& matchesL )
{
matchesL = matchesL_;
return matches_;
}
/******************************************************************************/
/* */
/* HitStore */

View file

@ -2,9 +2,9 @@
*
* $RCSfile: XmlIndex.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: abi $ $Date: 2001-07-06 10:03:26 $
* last change: $Author: abi $ $Date: 2001-07-06 11:04:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -427,9 +427,20 @@ QueryHitData* XmlIndex::hitToData( QueryHit* hit )
for( sal_Int32 i = 0; i < termsL; ++i )
{
sal_Int32 aInt = ( i << 1 );
if( matches[ aInt ] > 0 )
terms[i] = fetch( matches[ aInt ] );
if( 0 <= aInt && aInt < matchesL )
{
sal_Int32 match = matches[ aInt ];
if( match > 0 )
try
{
terms[i] = fetch( match );
}
catch( const excep::XmlSearchException& e )
{
}
}
}
sal_Int32 document = hit->getDocument();
QueryHitData *res = new QueryHitData( hit->getPenalty(),
documentName( document ),