Permalink
Browse files

fixed #279; added not equal to tags of PQ; added regressions to test 321

  • Loading branch information...
tomatolog committed May 16, 2018
1 parent 4e600be commit 5bcff05d19e495f1a44f190885b25cbb6f217c4a
Showing with 24 additions and 11 deletions.
  1. +3 −1 src/searchd.cpp
  2. +1 −1 src/searchdhttp.cpp
  3. +7 −7 src/sphinxrt.cpp
  4. +1 −1 src/sphinxrt.h
  5. +1 −1 test/test_321/model.bin
  6. +11 −0 test/test_321/test.xml
@@ -12924,12 +12924,14 @@ static bool PercolateShowStatus ( const SqlStmt_t & tStmt, SqlRowBuffer_c & tOut
StringBuilder_c tMissedFilter;
const char * sFilterTags = nullptr;
const CSphFilterSettings * pUID = nullptr;
bool bTagsEq = true;
ARRAY_FOREACH ( i, dFilters )
{
const CSphFilterSettings & tFilter = dFilters[i];
if ( tFilter.m_sAttrName=="tags" && tFilter.m_eType==SPH_FILTER_STRING && tFilter.m_dStrings.GetLength() )
{
sFilterTags = tFilter.m_dStrings[0].cstr();
bTagsEq = !tFilter.m_bExclude;
} else if ( tFilter.m_sAttrName=="uid" && ( tFilter.m_eType==SPH_FILTER_VALUES || tFilter.m_eType==SPH_FILTER_RANGE ) )
{
pUID = &tFilter;
@@ -12950,7 +12952,7 @@ static bool PercolateShowStatus ( const SqlStmt_t & tStmt, SqlRowBuffer_c & tOut
}
CSphVector<PercolateQueryDesc> dQueries;
pIndex->GetQueries ( sFilterTags, pUID, iOffset, iLimit, dQueries );
pIndex->GetQueries ( sFilterTags, bTagsEq, pUID, iOffset, iLimit, dQueries );
pServed->Unlock();
if ( !sCountAlias )
@@ -1810,7 +1810,7 @@ bool HttpHandlerPQ_c::ListQueries ( PercolateIndex_i * pIndex, const CSphString
uint64_t tmStart = sphMicroTimer();
CSphVector<PercolateQueryDesc> dQueries;
pIndex->GetQueries ( sFilterTags, pUID, 0, 0, dQueries );
pIndex->GetQueries ( sFilterTags, true, pUID, 0, 0, dQueries );
PercolateMatchResult_t tRes;
tRes.m_bGetDocs = false;
@@ -10719,7 +10719,7 @@ class PercolateIndex_c : public PercolateIndex_i
ISphRtAccum * CreateAccum ( CSphString & sError ) override;
ISphTokenizer * CloneIndexingTokenizer() const override { return m_pTokenizerIndexing->Clone ( SPH_CLONE_INDEX ); }
void SaveMeta ();
void GetQueries ( const char * sFilterTags, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries ) override;
void GetQueries ( const char * sFilterTags, bool bTagsEq, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries ) override;
bool Truncate ( CSphString & ) override;
// RT index stub
@@ -11230,7 +11230,7 @@ static void PercolateTags ( const char * sTags, CSphVector<uint64_t> & dTags )
dTags.Uniq();
}
static bool TagsMatched ( const uint64_t * pFilter, int iCount, const uint64_t * pQueryTags, int iQueryTagsCount )
static bool TagsMatched ( const uint64_t * pFilter, int iCount, const uint64_t * pQueryTags, int iQueryTagsCount, bool bTagsEq )
{
const uint64_t * pFilterEnd = pFilter + iCount;
const uint64_t * pTagsEnd = pQueryTags + iQueryTagsCount;
@@ -11242,10 +11242,10 @@ static bool TagsMatched ( const uint64_t * pFilter, int iCount, const uint64_t *
else if ( *pFilter<*pQueryTags )
pFilter++;
else if ( *pQueryTags==*pFilter )
return true;
return bTagsEq;
}
return false;
return !bTagsEq;
}
//////////////////////////////////////////////////////////////////////////
@@ -12260,7 +12260,7 @@ int PercolateIndex_c::DeleteQueries ( const char * sTags )
if ( !pQuery->m_dTags.GetLength() )
continue;
if ( TagsMatched ( dTags.Begin(), dTags.GetLength(), pQuery->m_dTags.Begin(), pQuery->m_dTags.GetLength() ) )
if ( TagsMatched ( dTags.Begin(), dTags.GetLength(), pQuery->m_dTags.Begin(), pQuery->m_dTags.GetLength(), true ) )
{
SafeDelete ( m_dStored[i].m_pQuery );
m_dStored.Remove ( i );
@@ -12555,7 +12555,7 @@ void PercolateIndex_c::SaveMeta()
sphWarning ( "failed to rename meta (src=%s, dst=%s, errno=%d, error=%s)", sMetaNew.cstr(), sMeta.cstr(), errno, strerror( errno ) );
}
void PercolateIndex_c::GetQueries ( const char * sFilterTags, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries )
void PercolateIndex_c::GetQueries ( const char * sFilterTags, bool bTagsEq, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries )
{
// FIXME!!! move to filter, add them via join
CSphVector<uint64_t> dTags;
@@ -12583,7 +12583,7 @@ void PercolateIndex_c::GetQueries ( const char * sFilterTags, const CSphFilterSe
if ( !pQuery->m_dTags.GetLength() )
continue;
if ( !TagsMatched ( dTags.Begin(), dTags.GetLength(), pQuery->m_dTags.Begin(), pQuery->m_dTags.GetLength() ) )
if ( !TagsMatched ( dTags.Begin(), dTags.GetLength(), pQuery->m_dTags.Begin(), pQuery->m_dTags.GetLength(), bTagsEq ) )
continue;
}
@@ -153,7 +153,7 @@ class PercolateIndex_i : public ISphRtIndex
virtual int DeleteQueries ( const char * sTags ) = 0;
virtual bool Query ( const char * sQuery, const char * sTags, const CSphVector<CSphFilterSettings> * pFilters, const CSphVector<FilterTreeItem_t> * pFilterTree, bool bReplace, bool bQL, uint64_t & uId, CSphString & sError ) = 0;
virtual void GetQueries ( const char * sFilterTags, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries ) = 0;
virtual void GetQueries ( const char * sFilterTags, bool bTagsEq, const CSphFilterSettings * pUID, int iOffset, int iLimit, CSphVector<PercolateQueryDesc> & dQueries ) = 0;
virtual bool IsSameSettings ( CSphReconfigureSettings & tSettings, CSphReconfigureSetup & tSetup, CSphString & sError ) const = 0;
virtual void Reconfigure ( CSphReconfigureSetup & tSetup ) = 0;
Oops, something went wrong.

0 comments on commit 5bcff05

Please sign in to comment.