فهرست منبع

spaces; formatting

klirichek 6 سال پیش
والد
کامیت
a1da0cdc34
5فایلهای تغییر یافته به همراه45 افزوده شده و 47 حذف شده
  1. 10 12
      src/searchdtask.cpp
  2. 27 28
      src/sphinx.cpp
  3. 5 5
      src/sphinx.h
  4. 2 1
      src/sphinxfilter.cpp
  5. 1 1
      src/sphinxsort.cpp

+ 10 - 12
src/searchdtask.cpp

@@ -301,8 +301,7 @@ struct TaskWorker_t: public ListNode_t
 		for ( int i = 0; i<g_iTasks; ++i )
 		{
 			++iFlavour;
-			if ( iFlavour>=g_iTasks )
-				iFlavour = 0;
+			iFlavour %= g_iTasks;
 
 			// skip queues full of runners (and also non-mt, since they have 0 runners)
 			if ( g_TaskProps[iFlavour].m_iCurrentRunners>=g_Tasks[iFlavour].m_iMaxRunners )
@@ -310,20 +309,19 @@ struct TaskWorker_t: public ListNode_t
 
 			// look into the queue
 			auto& dProp = g_TaskProps[iFlavour];
-			{ // scope for QueueLock
-				ScopedMutex_t tTaskLock ( dProp.m_dQueueLock );
 
-				// this queue is ok, extract the task and return it.
-				if ( dProp.m_dQueue.GetLength ())
-				{
-					pLeaf = ( ListedData_t* ) dProp.m_dQueue.Begin ();
-					dProp.m_dQueue.Remove ( pLeaf );
-					break;
-				}
+			// scope for QueueLock
+			ScopedMutex_t tTaskLock ( dProp.m_dQueueLock );
+
+			// this queue is ok, extract the task and return it.
+			if ( dProp.m_dQueue.GetLength ())
+			{
+				pLeaf = ( ListedData_t* ) dProp.m_dQueue.Begin ();
+				dProp.m_dQueue.Remove ( pLeaf );
+				break;
 			}
 		}
 
-		// no queues to work (any reason - no tasks at all, or no tasks with free worker slots)
 		if ( pLeaf )
 		{
 			// round-robin flavours: next time we'll round from last success job kind.

+ 27 - 28
src/sphinx.cpp

@@ -13562,7 +13562,7 @@ SphWordID_t CSphDictExact::GetWordID ( BYTE * pWord )
 
 void CSphMatchComparatorState::FixupLocators ( const ISphSchema * pOldSchema, const ISphSchema * pNewSchema, bool bRemapKeyparts )
 {
-	for ( int i = 0; i < CSphMatchComparatorState::MAX_ATTRS; i++ )
+	for ( int i = 0; i < CSphMatchComparatorState::MAX_ATTRS; ++i )
 	{
 		if ( m_eKeypart[i]==SPH_KEYPART_DOCID_S || m_eKeypart[i]==SPH_KEYPART_DOCID_D )
 		{
@@ -13817,35 +13817,34 @@ struct ContextExtra : public ISphExtra
 
 	virtual bool ExtraDataImpl ( ExtraData_e eData, void ** ppArg )
 	{
-		if ( eData==EXTRA_GET_QUEUE_WORST || eData==EXTRA_GET_QUEUE_SORTVAL )
+		if ( eData!=EXTRA_GET_QUEUE_WORST && eData!=EXTRA_GET_QUEUE_SORTVAL )
+			return m_pRanker->ExtraData ( eData, ppArg );
+
+		if ( !m_pSorter )
+			return false;
+
+		const CSphMatch * pWorst = m_pSorter->GetWorst();
+		if ( !pWorst )
+			return false;
+
+		if ( eData==EXTRA_GET_QUEUE_WORST )
 		{
-			if ( !m_pSorter )
-				return false;
-			const CSphMatch * pWorst = m_pSorter->GetWorst();
-			if ( !pWorst )
-				return false;
-			if ( eData==EXTRA_GET_QUEUE_WORST )
-			{
-				*ppArg = (void*)pWorst;
-				return true;
-			} else
-			{
-				assert ( eData==EXTRA_GET_QUEUE_SORTVAL );
-				const CSphMatchComparatorState & tCmp = m_pSorter->GetState();
-				if ( tCmp.m_eKeypart[0]==SPH_KEYPART_FLOAT && tCmp.m_tLocator[0].m_bDynamic
-					&& tCmp.m_tLocator[0].m_iBitCount==32 && ( tCmp.m_tLocator[0].m_iBitOffset%32==0 )
-					&& tCmp.m_eKeypart[1]==SPH_KEYPART_ROWID && tCmp.m_dAttrs[1]==-1 )
-				{
-					*(int*)ppArg = tCmp.m_tLocator[0].m_iBitOffset/32;
-					return true;
-				} else
-				{
-					// min_top_sortval() only works with order by float_expr for now
-					return false;
-				}
-			}
+			*ppArg = (void*)pWorst;
+			return true;
+		};
+
+		assert ( eData==EXTRA_GET_QUEUE_SORTVAL );
+		const CSphMatchComparatorState & tCmp = m_pSorter->GetState();
+		if ( tCmp.m_eKeypart[0]==SPH_KEYPART_FLOAT && tCmp.m_tLocator[0].m_bDynamic
+			&& tCmp.m_tLocator[0].m_iBitCount==32 && ( tCmp.m_tLocator[0].m_iBitOffset%32==0 )
+			&& tCmp.m_eKeypart[1]==SPH_KEYPART_ROWID && tCmp.m_dAttrs[1]==-1 )
+		{
+			*(int*)ppArg = tCmp.m_tLocator[0].m_iBitOffset/32;
+			return true;
 		}
-		return m_pRanker->ExtraData ( eData, ppArg );
+
+		// min_top_sortval() only works with order by float_expr for now
+		return false;
 	}
 };
 

+ 5 - 5
src/sphinx.h

@@ -2939,7 +2939,7 @@ struct CSphMatchComparatorState
 	/// check if any of my attrs are bitfields
 	bool UsesBitfields ()
 	{
-		for ( int i=0; i<MAX_ATTRS; i++ )
+		for ( int i=0; i<MAX_ATTRS; ++i )
 			if ( m_eKeypart[i]==SPH_KEYPART_INT && m_tLocator[i].IsBitfield() )
 				return true;
 		return false;
@@ -3003,10 +3003,10 @@ public:
 	virtual bool		IsGroupby () const = 0;
 
 	/// set match comparator state
-	virtual void		SetState ( const CSphMatchComparatorState & tState );
+	void		SetState ( const CSphMatchComparatorState & tState );
 
 	/// get match comparator stat
-	virtual CSphMatchComparatorState &	GetState() { return m_tState; }
+	const CSphMatchComparatorState &	GetState() const { return m_tState; }
 
 	/// set group comparator state
 	virtual void		SetGroupState ( const CSphMatchComparatorState & ) {}
@@ -3018,7 +3018,7 @@ public:
 	virtual void		SetSchema ( ISphSchema * pSchema, bool bRemapCmp );
 
 	/// get incoming schema
-	virtual const ISphSchema * GetSchema () const { return m_pSchema; }
+	const ISphSchema * GetSchema () const { return m_pSchema; }
 
 	/// base push
 	/// returns false if the entry was rejected as duplicate
@@ -3035,7 +3035,7 @@ public:
 	virtual int			GetDataLength () const = 0;
 
 	/// get total count of non-duplicates Push()ed through this queue
-	virtual int64_t		GetTotalCount () const { return m_iTotal; }
+	int64_t		GetTotalCount () const { return m_iTotal; }
 
 	/// process collected entries up to length count
 	virtual void		Finalize ( ISphMatchProcessor & tProcessor, bool bCallProcessInResultSetOrder ) = 0;

+ 2 - 1
src/sphinxfilter.cpp

@@ -1420,7 +1420,8 @@ ISphFilter * sphCreateFilter ( const CSphFilterSettings &tSettings, const Create
 		sError, sWarning, false, tCtx.m_eCollation);
 }
 
-ISphFilter * sphCreateAggrFilter ( const CSphFilterSettings * pSettings, const CSphString & sAttrName, const ISphSchema & tSchema, CSphString & sError )
+ISphFilter * sphCreateAggrFilter ( const CSphFilterSettings * pSettings, const CSphString & sAttrName,
+		const ISphSchema & tSchema, CSphString & sError )
 {
 	assert ( pSettings );
 	CSphString sWarning;

+ 1 - 1
src/sphinxsort.cpp

@@ -112,7 +112,7 @@ private:
 
 public:
 	/// ctor
-	CSphMatchQueueTraits ( int iSize )
+	explicit CSphMatchQueueTraits ( int iSize )
 		: m_iSize ( iSize )
 		, m_iDataLength ( iSize )
 	{