Skip to content

Commit

Permalink
cleanup/refactor
Browse files Browse the repository at this point in the history
Just cosmetic changes on explicit/inline c-trs,
override/final usage and couple of comments on suspicious places.
  • Loading branch information
klirichek committed Aug 14, 2018
1 parent beb45cc commit 0193946
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 83 deletions.
38 changes: 12 additions & 26 deletions src/searchd.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -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';
}
Expand Down
2 changes: 1 addition & 1 deletion src/searchdha.cpp
Expand Up @@ -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 () );
}

Expand Down
2 changes: 1 addition & 1 deletion src/searchdha.h
Expand Up @@ -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

Expand Down
18 changes: 14 additions & 4 deletions src/sphinx.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
11 changes: 4 additions & 7 deletions src/sphinx.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sphinxexpr.cpp
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/sphinxint.h
Expand Up @@ -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;
Expand Down
48 changes: 8 additions & 40 deletions src/sphinxrt.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sphinxsort.cpp
Expand Up @@ -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; }

Expand Down

0 comments on commit 0193946

Please sign in to comment.