Permalink
Browse files

cleanup/refactor

Just cosmetic changes on explicit/inline c-trs,
override/final usage and couple of comments on suspicious places.
  • Loading branch information...
klirichek committed Aug 12, 2018
1 parent beb45cc commit 0193946105ac08913362b7d7acf0c90f9b38dc85
Showing with 44 additions and 83 deletions.
  1. +12 −26 src/searchd.cpp
  2. +1 −1 src/searchdha.cpp
  3. +1 −1 src/searchdha.h
  4. +14 −4 src/sphinx.cpp
  5. +4 −7 src/sphinx.h
  6. +1 −1 src/sphinxexpr.cpp
  7. +2 −2 src/sphinxint.h
  8. +8 −40 src/sphinxrt.cpp
  9. +1 −1 src/sphinxsort.cpp
@@ -6237,7 +6237,7 @@ struct Expr_Snippet_c : public ISphStringExpr
SafeRelease ( m_pArgs );
}
int StringEval ( const CSphMatch & tMatch, const BYTE ** ppStr ) const override
int StringEval ( const CSphMatch & tMatch, const BYTE ** ppStr ) const final
{
CSphScopedProfile ( m_pProfiler, SPH_QSTATE_SNIPPET );
@@ -15718,19 +15718,11 @@ void sphHandleMysqlDelete ( StmtErrorReporter_i & tOut, const QueryParserFactory
struct SessionVars_t
{
bool m_bAutoCommit;
bool m_bInTransaction;
ESphCollation m_eCollation;
bool m_bProfile;
bool m_bVIP;
SessionVars_t ()
: m_bAutoCommit ( true )
, m_bInTransaction ( false )
, m_eCollation ( g_eCollation )
, m_bProfile ( false )
, m_bVIP ( false )
{}
bool m_bAutoCommit = true;
bool m_bInTransaction = false;
ESphCollation m_eCollation { g_eCollation };
bool m_bProfile = false;
bool m_bVIP = false;
};
// fwd
@@ -20825,15 +20817,15 @@ struct ISphNetAction : ISphNoncopyable
struct NetStateCommon_t
{
int m_iClientSock;
int m_iConnID;
int m_iClientSock = -1;
int m_iConnID = 0;
char m_sClientName[SPH_ADDRPORT_SIZE];
bool m_bKeepSocket;
bool m_bVIP;
bool m_bKeepSocket = false;
bool m_bVIP = false;
CSphVector<BYTE> m_dBuf;
int m_iLeft;
int m_iPos;
int m_iLeft = 0;
int m_iPos = 0;
NetStateCommon_t ();
virtual ~NetStateCommon_t ();
@@ -22407,12 +22399,6 @@ void NetSendData_t::CloseSocket()
NetStateCommon_t::NetStateCommon_t ()
: m_iClientSock ( -1 )
, m_iConnID ( 0 )
, m_bKeepSocket ( false )
, m_bVIP ( false )
, m_iLeft ( 0 )
, m_iPos ( 0 )
{
m_sClientName[0] = '\0';
}
@@ -2137,7 +2137,7 @@ void AgentConn_t::SoftTimeoutCallback ()
{
if ( !DoQuery () )
StartRemoteLoopTry ();
FirePoller ();
FirePoller (); // fixme? M.b. no more necessary, since processing queue will restart on fired timeout.
sphLogDebugA ( "%d finished retry timeout ref=%d", m_iStoreTag, ( int ) GetRefcount () );
}
@@ -234,7 +234,7 @@ using HostStatSnapshot_t = uint64_t[eMaxAgentStat + ehMaxStat];
/// per-host dashboard
struct HostDashboard_t : public ISphRefcountedMT
{
HostDesc_t m_tHost; // only host info, no indices. Used for ping.
HostDesc_t m_tHost; // only host info, no indices. Used for ping.
bool m_bNeedPing = false; // we'll ping only HA agents, not everyone
PersistentConnectionsPool_c * m_pPersPool = nullptr; // persistence pool also lives here, one per dashboard
@@ -8751,17 +8751,17 @@ class DiskMatchesToNewSchema_c : public MatchesToNewSchema_c
const DWORD * m_pMVAPool;
bool m_bArenaProhibit;
virtual const DWORD * GetMVAPool ( const CSphMatch * /*pMatch*/ ) override
const DWORD * GetMVAPool ( const CSphMatch * /*pMatch*/ ) final
{
return m_pMVAPool;
}
virtual const BYTE * GetStringPool ( const CSphMatch * /*pMatch*/ ) override
const BYTE * GetStringPool ( const CSphMatch * /*pMatch*/ ) final
{
return m_pStringPool;
}
virtual bool GetArenaProhibitFlag ( const CSphMatch * /*pMatch*/ ) override
bool GetArenaProhibitFlag ( const CSphMatch * /*pMatch*/ ) final
{
return m_bArenaProhibit;
}
@@ -14889,6 +14889,12 @@ struct SphFinalMatchCalc_t : ISphMatchProcessor, ISphNoncopyable
void Process ( CSphMatch * pMatch ) final
{
// fixme! tag is signed int,
// for distr. tags from remotes set with | 0x80000000,
// i e in terms of signed int they're <0!
// Is it intention, or bug?
// If intention, lt us use uniformely either <0, either &0x80000000
// conditions to avoid messing. If bug, shit already happened!
if ( pMatch->m_iTag>=0 )
return;
@@ -15062,6 +15068,10 @@ bool CSphIndex_VLN::MultiScan ( const CSphQuery * pQuery, CSphQueryResult * pRes
CSphMatch tMatch;
tMatch.Reset ( tMaxSorterSchema.GetDynamicSize() );
tMatch.m_iWeight = tArgs.m_iIndexWeight;
// fixme! tag also used over bitmask | 0x80000000,
// which marks that match comes from remote.
// using -1 might be also interpreted as 0xFFFFFFFF in such context!
// Does it intended?
tMatch.m_iTag = tCtx.m_dCalcFinal.GetLength() ? -1 : tArgs.m_iTag;
if ( pResult->m_pProfile )
@@ -15071,7 +15081,7 @@ bool CSphIndex_VLN::MultiScan ( const CSphQuery * pQuery, CSphQueryResult * pRes
// run full scan with block and row filtering for everything else
if ( pQuery->m_dFilters.GetLength()==1
&& pQuery->m_dFilters[0].m_eType==SPH_FILTER_VALUES
&& pQuery->m_dFilters[0].m_bExclude==false
&& !pQuery->m_dFilters[0].m_bExclude
&& pQuery->m_dFilters[0].m_sAttrName=="@id"
&& tArgs.m_dKillList.GetLength()==0
&& pQuery->m_dFilterTree.GetLength()==0 )
@@ -3007,18 +3007,15 @@ struct CSphMatchComparatorState
ESphAttr m_tSubType[MAX_ATTRS]; ///< sort-by expression type
int m_dAttrs[MAX_ATTRS]; ///< sort-by attr index
DWORD m_uAttrDesc; ///< sort order mask (if i-th bit is set, i-th attr order is DESC)
DWORD m_iNow; ///< timestamp (for timesegments sorting mode)
SphStringCmp_fn m_fnStrCmp; ///< string comparator
DWORD m_uAttrDesc = 0; ///< sort order mask (if i-th bit is set, i-th attr order is DESC)
DWORD m_iNow = 0; ///< timestamp (for timesegments sorting mode)
SphStringCmp_fn m_fnStrCmp = nullptr; ///< string comparator
/// create default empty state
CSphMatchComparatorState ()
: m_uAttrDesc ( 0 )
, m_iNow ( 0 )
, m_fnStrCmp ( nullptr )
{
for ( int i=0; i<MAX_ATTRS; i++ )
for ( int i=0; i<MAX_ATTRS; ++i )
{
m_eKeypart[i] = SPH_KEYPART_ID;
m_tSubExpr[i] = nullptr;
@@ -1525,7 +1525,7 @@ struct Expr_JsonFieldAggr_c : public Expr_JsonFieldConv_c
return JsonAggr<int64_t> ( eJson, pVal, m_eFunc, nullptr );
}
bool IsDataPtrAttr() const override { return true; }
bool IsDataPtrAttr() const final { return true; }
uint64_t GetHash ( const ISphSchema & tSorterSchema, uint64_t uPrevHash, bool & bDisable ) final
{
@@ -2327,9 +2327,9 @@ class MatchesToNewSchema_c : public ISphMatchProcessor
{
public:
MatchesToNewSchema_c ( const ISphSchema * pOldSchema, const ISphSchema * pNewSchema );
virtual void Process ( CSphMatch * pMatch ) override;
void Process ( CSphMatch * pMatch ) final;
protected:
private:
const ISphSchema * m_pOldSchema;
const ISphSchema * m_pNewSchema;
CSphVector<CSphAttrLocator> m_dNewAttrs;
@@ -6618,49 +6618,17 @@ static CSphDict * SetupStarDict ( CSphScopedPtr<CSphDict> & tContainer, CSphDict
return tContainer.Ptr();
}
struct CSphAttrTypedLocator : public CSphAttrLocator
{
ESphAttr m_eAttrType;
CSphAttrTypedLocator()
: m_eAttrType ( SPH_ATTR_NONE )
{}
inline void Set ( const CSphAttrLocator& tLoc, ESphAttr eAttrType )
{
m_bDynamic = tLoc.m_bDynamic;
m_iBitCount = tLoc.m_iBitCount;
m_iBitOffset = tLoc.m_iBitOffset;
m_eAttrType = eAttrType;
}
};
struct SphFinalMatchCounter_t : ISphMatchProcessor
{
int m_iCount;
int m_iSegments;
explicit SphFinalMatchCounter_t ( int iSegments )
: m_iCount ( 0 )
, m_iSegments ( iSegments )
{ }
virtual void Process ( CSphMatch * pMatch )
{
int iMatchSegment = pMatch->m_iTag-1;
if ( iMatchSegment>=0 && iMatchSegment<m_iSegments && pMatch->m_pStatic )
m_iCount++;
}
};
struct SphRtFinalMatchCalc_t : ISphMatchProcessor, ISphNoncopyable
struct SphRtFinalMatchCalc_t : ISphMatchProcessor, ISphNoncopyable // fixme! that is actually class, not struct.
{
private:
const CSphQueryContext & m_tCtx;
int m_iSeg;
int m_iSegments;
// count per segments matches
// to skip iteration of matches at sorter and pool setup for segment without matches at sorter
CSphBitvec m_dSegments;
public:
SphRtFinalMatchCalc_t ( int iSegments, const CSphQueryContext & tCtx )
: m_tCtx ( tCtx )
, m_iSeg ( 0 )
@@ -6690,7 +6658,7 @@ struct SphRtFinalMatchCalc_t : ISphMatchProcessor, ISphNoncopyable
return ( m_iSeg==0 || m_dSegments.BitCount()>0 );
}
virtual void Process ( CSphMatch * pMatch )
void Process ( CSphMatch * pMatch ) final
{
int iMatchSegment = pMatch->m_iTag-1;
if ( iMatchSegment==m_iSeg && pMatch->m_pStatic )
@@ -6714,13 +6682,13 @@ class RTMatchesToNewSchema_c : public MatchesToNewSchema_c
, m_tMvaArenaFlag ( tMvaArenaFlag )
{}
protected:
private:
const SphChunkGuard_t & m_tGuard;
const CSphVector<const DWORD *> & m_dDiskMVA;
const CSphVector<const BYTE *> & m_dDiskStrings;
const CSphBitvec & m_tMvaArenaFlag;
virtual const DWORD * GetMVAPool ( const CSphMatch * pMatch ) override
const DWORD * GetMVAPool ( const CSphMatch * pMatch ) final
{
int nRamChunks = m_tGuard.m_dRamChunks.GetLength();
int iChunkId = pMatch->m_iTag-1;
@@ -6730,7 +6698,7 @@ class RTMatchesToNewSchema_c : public MatchesToNewSchema_c
return m_dDiskMVA[iChunkId-nRamChunks];
}
virtual const BYTE * GetStringPool ( const CSphMatch * pMatch ) override
const BYTE * GetStringPool ( const CSphMatch * pMatch ) final
{
int nRamChunks = m_tGuard.m_dRamChunks.GetLength();
int iChunkId = pMatch->m_iTag-1;
@@ -6740,7 +6708,7 @@ class RTMatchesToNewSchema_c : public MatchesToNewSchema_c
return m_dDiskStrings[iChunkId-nRamChunks];
}
virtual bool GetArenaProhibitFlag ( const CSphMatch * pMatch ) override
bool GetArenaProhibitFlag ( const CSphMatch * pMatch ) final
{
int nRamChunks = m_tGuard.m_dRamChunks.GetLength();
int iChunkId = pMatch->m_iTag-1;
@@ -4477,7 +4477,7 @@ struct ExprSortJson2StringPtr_c : public ISphExpr
, m_pExpr ( pExpr )
{}
bool IsDataPtrAttr () const override { return true; }
bool IsDataPtrAttr () const final { return true; }
float Eval ( const CSphMatch & ) const override { assert ( 0 ); return 0.0f; }

0 comments on commit 0193946

Please sign in to comment.