Permalink
Browse files

Fix #431 via refactor CSphDict for refcount flavour

  • Loading branch information...
klirichek committed Sep 3, 2018
1 parent fd841a4 commit fad572fb543606b33e688eb82a485b86011545fd
@@ -210,7 +210,7 @@ class RTN : public RT, public ::testing::WithParamInterface<DWORD>
TEST_P ( RTN, WeightBoundary )
{
using namespace testing;
auto pDict = sphCreateDictionaryCRC ( tDictSettings, NULL, pTok, "weight", sError );
CSphDictRefPtr_c pDict { sphCreateDictionaryCRC ( tDictSettings, NULL, pTok, "weight", sError ) };
tCol.m_sName = "channel_id";
tCol.m_eAttrType = SPH_ATTR_INTEGER;
@@ -289,7 +289,6 @@ TEST_P ( RTN, WeightBoundary )
SafeDelete ( pSorter );
SafeDelete ( tQuery.m_pQueryParser );
SafeDelete ( pIndex );
SafeDelete ( pDict );
SafeDelete ( pSrc );
}
@@ -111,7 +111,7 @@ TEST_F( Tokenizer, exceptions_more )
++iCur;
}
ISphTokenizer * pQtok = m_pTokenizer->Clone ( SPH_CLONE_QUERY_LIGHTWEIGHT );
ISphTokenizerRefPtr_c pQtok { m_pTokenizer->Clone ( SPH_CLONE_QUERY_LIGHTWEIGHT ) };
pQtok->SetBuffer ( ( BYTE * ) "life:)", 7 );
ASSERT_STREQ ( ( char * ) pQtok->GetToken (), "life:)" );
@@ -656,7 +656,6 @@ class QueryParser : public Tokenizer
protected:
void TearDown () override
{
SafeDelete (pDict);
Tokenizer::TearDown ();
}
@@ -685,7 +684,7 @@ class QueryParser : public Tokenizer
ASSERT_TRUE ( pDict );
}
CSphDict* pDict;
CSphDictRefPtr_c pDict;
CSphSchema tSchema;
CSphIndexSettings tTmpSettings;
};
@@ -192,6 +192,8 @@ inline bool operator < ( const Word_t & a, const Word_t & b)
class CSphStopwordBuilderDict : public CSphDict
{
protected:
~CSphStopwordBuilderDict() override {}
public:
CSphStopwordBuilderDict () {}
void Save ( const char * sOutput, int iTop, bool bFreqs );
@@ -947,7 +949,7 @@ bool DoIndex ( const CSphConfigSection & hIndex, const char * sIndexName,
if ( !pTokenizer->EnableZoneIndexing ( sError ) )
sphDie ( "index '%s': %s", sIndexName, sError.cstr() );
CSphDict * pDict = NULL;
CSphDictRefPtr_c pDict;
// setup tokenization filters
if ( !g_sBuildStops )
@@ -1100,7 +1102,6 @@ bool DoIndex ( const CSphConfigSection & hIndex, const char * sIndexName,
if ( bSpawnFailed )
{
fprintf ( stdout, "ERROR: index '%s': failed to configure some of the sources, will not index.\n", sIndexName );
SafeDelete ( pDict );
return false;
}
@@ -1129,10 +1130,10 @@ bool DoIndex ( const CSphConfigSection & hIndex, const char * sIndexName,
fflush ( stdout );
}
CSphStopwordBuilderDict tDict;
CSphRefcountedPtr<CSphStopwordBuilderDict> tDict { new CSphStopwordBuilderDict };
ARRAY_FOREACH ( i, dSources )
{
dSources[i]->SetDict ( &tDict );
dSources[i]->SetDict ( tDict );
if ( !dSources[i]->Connect ( sError ) || !dSources[i]->IterateStart ( sError ) )
{
if ( !sError.IsEmpty() )
@@ -1153,7 +1154,7 @@ bool DoIndex ( const CSphConfigSection & hIndex, const char * sIndexName,
if ( !sError.IsEmpty() )
fprintf ( stdout, "ERROR: index '%s': %s\n", sIndexName, sError.cstr() );
}
tDict.Save ( g_sBuildStops, g_iTopStops, g_bBuildFreqs );
tDict->Save ( g_sBuildStops, g_iTopStops, g_bBuildFreqs );
SafeDelete ( pFieldFilter );
@@ -66,7 +66,8 @@ void ApplyMorphology ( CSphIndex * pIndex )
dOutBuffer.Reserve ( dInBuffer.GetLength() );
ISphTokenizerRefPtr_c pTokenizer { pIndex->GetTokenizer()->Clone ( SPH_CLONE_INDEX ) };
CSphDict * pDict = pIndex->GetDictionary();
CSphDictRefPtr_c pDict { pIndex->GetDictionary() };
SafeAddRef ( pDict );
BYTE * sBufferToDump = &dInBuffer[0];
if ( pTokenizer )
{
@@ -18088,8 +18088,8 @@ bool RotateIndexGreedy ( const ServedIndex_c * pIndex, ServedDesc_t &tWlockedInd
}
// try to use new index
ISphTokenizerRefPtr_c pTokenizer { tWlockedIndex.m_pIndex->LeakTokenizer () }; // FIXME! disable support of that old indexes and remove this bullshit
CSphScopedPtr<CSphDict> pDictionary ( tWlockedIndex.m_pIndex->LeakDictionary () );
ISphTokenizerRefPtr_c pTokenizer { tWlockedIndex.m_pIndex->LeakTokenizer () }; // FIXME! disable support of that old indexes and remove this bullshit
CSphDictRefPtr_c pDictionary { tWlockedIndex.m_pIndex->LeakDictionary () };
// bool bRolledBack = false;
bool bPreallocSuccess = tWlockedIndex.m_pIndex->Prealloc ( g_bStripPath );
@@ -18121,7 +18121,7 @@ bool RotateIndexGreedy ( const ServedIndex_c * pIndex, ServedDesc_t &tWlockedInd
tWlockedIndex.m_pIndex->SetTokenizer ( pTokenizer );
if ( !tWlockedIndex.m_pIndex->GetDictionary () )
tWlockedIndex.m_pIndex->SetDictionary ( pDictionary.LeakPtr () );
tWlockedIndex.m_pIndex->SetDictionary ( pDictionary );
// if ( bRolledBack )
// return bPreallocSuccess;
Oops, something went wrong.

0 comments on commit fad572f

Please sign in to comment.