Bladeren bron

removed SPH_GROUPBY_EXTENDED


git-svn-id: svn://svn.sphinxsearch.com/sphinx/trunk@1334 406a0c4d-033a-0410-8de8-e80135713968
shodan 17 jaren geleden
bovenliggende
commit
e04578ab62
5 gewijzigde bestanden met toevoegingen van 18 en 75 verwijderingen
  1. 1 3
      api/java/SphinxClient.java
  2. 1 3
      api/sphinxapi.php
  3. 1 2
      api/sphinxapi.py
  4. 1 2
      src/sphinx.h
  5. 14 65
      src/sphinxsort.cpp

+ 1 - 3
api/java/SphinxClient.java

@@ -52,7 +52,6 @@ public class SphinxClient
 	public final static int SPH_GROUPBY_YEAR		= 3;
 	public final static int SPH_GROUPBY_ATTR		= 4;
 	public final static int SPH_GROUPBY_ATTRPAIR	= 5;
-	public final static int SPH_GROUPBY_EXTENDED	= 6;
 
 	/* searchd reply status codes */
 	public final static int SEARCHD_OK				= 0;
@@ -637,8 +636,7 @@ public class SphinxClient
 			func==SPH_GROUPBY_MONTH ||
 			func==SPH_GROUPBY_YEAR ||
 			func==SPH_GROUPBY_ATTR ||
-			func==SPH_GROUPBY_ATTRPAIR ||
-			func==SPH_GROUPBY_EXTENDED, "unknown func value; use one of the available SPH_GROUPBY_xxx constants" );
+			func==SPH_GROUPBY_ATTRPAIR, "unknown func value; use one of the available SPH_GROUPBY_xxx constants" );
 
 		_groupBy = attribute;
 		_groupFunc = func;

+ 1 - 3
api/sphinxapi.php

@@ -80,7 +80,6 @@ define ( "SPH_GROUPBY_MONTH",		2 );
 define ( "SPH_GROUPBY_YEAR",		3 );
 define ( "SPH_GROUPBY_ATTR",		4 );
 define ( "SPH_GROUPBY_ATTRPAIR",	5 );
-define ( "SPH_GROUPBY_EXTENDED",	6 );
 
 
 /// portably pack numeric to 64 unsigned bits, network order
@@ -558,8 +557,7 @@ class SphinxClient
 			|| $func==SPH_GROUPBY_MONTH
 			|| $func==SPH_GROUPBY_YEAR
 			|| $func==SPH_GROUPBY_ATTR
-			|| $func==SPH_GROUPBY_ATTRPAIR
-			|| $func==SPH_GROUPBY_EXTENDED );
+			|| $func==SPH_GROUPBY_ATTRPAIR );
 
 		$this->_groupby = $attribute;
 		$this->_groupfunc = $func;

+ 1 - 2
api/sphinxapi.py

@@ -81,7 +81,6 @@ SPH_GROUPBY_MONTH		= 2
 SPH_GROUPBY_YEAR		= 3
 SPH_GROUPBY_ATTR		= 4
 SPH_GROUPBY_ATTRPAIR	= 5
-SPH_GROUPBY_EXTENDED	= 6
 
 
 class SphinxClient:
@@ -366,7 +365,7 @@ class SphinxClient:
 		Set grouping attribute and function.
 		"""
 		assert(isinstance(attribute, str))
-		assert(func in [SPH_GROUPBY_DAY, SPH_GROUPBY_WEEK, SPH_GROUPBY_MONTH, SPH_GROUPBY_YEAR, SPH_GROUPBY_ATTR, SPH_GROUPBY_ATTRPAIR, SPH_GROUPBY_EXTENDED] )
+		assert(func in [SPH_GROUPBY_DAY, SPH_GROUPBY_WEEK, SPH_GROUPBY_MONTH, SPH_GROUPBY_YEAR, SPH_GROUPBY_ATTR, SPH_GROUPBY_ATTRPAIR] )
 		assert(isinstance(groupsort, str))
 
 		self._groupby = attribute

+ 1 - 2
src/sphinx.h

@@ -1424,8 +1424,7 @@ enum ESphGroupBy
 	SPH_GROUPBY_MONTH	= 2,	///< group by month
 	SPH_GROUPBY_YEAR	= 3,	///< group by year
 	SPH_GROUPBY_ATTR	= 4,	///< group by attribute value
-	SPH_GROUPBY_ATTRPAIR= 5,	///< group by sequential attrs pair (rendered redundant by 64bit attrs support; removed)
-	SPH_GROUPBY_EXTENDED= 6		///< group by an expression (pretty limited for now)
+	SPH_GROUPBY_ATTRPAIR= 5		///< group by sequential attrs pair (rendered redundant by 64bit attrs support; removed)
 };
 
 

+ 14 - 65
src/sphinxsort.cpp

@@ -267,21 +267,6 @@ GROUPER_BEGIN_SPLIT ( CSphGrouperYear )
 	return (pSplit->tm_year+1900);
 GROUPER_END
 
-
-/// HACK HACK HACK
-class CSphGrouperAttrdiv : public CSphGrouper
-{
-protected:
-	CSphAttrLocator m_tLocator;
-	int m_iDiv;
-public:
-	CSphGrouperAttrdiv ( const CSphAttrLocator & tLoc, int iDiv ) : m_tLocator ( tLoc ), m_iDiv ( iDiv ) {}
-	virtual void GetLocator ( CSphAttrLocator & tOut ) const { tOut = m_tLocator; }
-	virtual SphGroupKey_t KeyFromMatch ( const CSphMatch & tMatch ) const { return KeyFromValue ( tMatch.GetAttr ( m_tLocator ) ); }
-	virtual SphGroupKey_t KeyFromValue ( SphAttr_t uValue ) const { return uValue/m_iDiv; }
-	virtual DWORD GetResultType () const { return m_tLocator.m_iBitCount>8*(int)sizeof(DWORD) ? SPH_ATTR_BIGINT : SPH_ATTR_INTEGER; }
-};
-
 //////////////////////////////////////////////////////////////////////////
 
 /// simple fixed-size hash
@@ -1578,60 +1563,24 @@ static bool SetupGroupbySettings ( const CSphQuery * pQuery, const CSphSchema &
 	}
 
 	// setup groupby attr
-	int iGroupBy = -1;
-	if ( pQuery->m_eGroupFunc==SPH_GROUPBY_EXTENDED )
+	int iGroupBy = tSchema.GetAttrIndex ( pQuery->m_sGroupBy.cstr() );
+	if ( iGroupBy<0 )
 	{
-		// groupby clause
-		// HACK HACK HACK, implement full blown expr support here
-		CSphString sBuf = pQuery->m_sGroupBy;
-
-		char * p = strchr ( (char*)sBuf.cstr(), '/' );
-		if ( p )
-			*p++ = '\0';
-
-		iGroupBy = tSchema.GetAttrIndex ( sBuf.cstr() );
-		if ( iGroupBy<0 )
-		{
-			sError.SetSprintf ( "group-by attribute '%s' not found", sBuf.cstr() );
-			return false;
-		}
-
-		if ( p )
-		{
-			int iDiv = strtoul ( p, NULL, 10 );
-			if ( !iDiv )
-			{
-				sError.SetSprintf ( "group-by clause: division by zero" );
-				return false;
-			}
-			tSettings.m_pGrouper = new CSphGrouperAttrdiv ( tSchema.GetAttr(iGroupBy).m_tLocator, iDiv );
-		} else
-		{
-			tSettings.m_pGrouper = new CSphGrouperAttr ( tSchema.GetAttr(iGroupBy).m_tLocator );
-		}
+		sError.SetSprintf ( "group-by attribute '%s' not found", pQuery->m_sGroupBy.cstr() );
+		return false;
+	}
 
-	} else
+	CSphAttrLocator tLoc = tSchema.GetAttr(iGroupBy).m_tLocator;
+	switch ( pQuery->m_eGroupFunc )
 	{
-		// plain old name
-		iGroupBy = tSchema.GetAttrIndex ( pQuery->m_sGroupBy.cstr() );
-		if ( iGroupBy<0 )
-		{
-			sError.SetSprintf ( "group-by attribute '%s' not found", pQuery->m_sGroupBy.cstr() );
+		case SPH_GROUPBY_DAY:		tSettings.m_pGrouper = new CSphGrouperDay ( tLoc ); break;
+		case SPH_GROUPBY_WEEK:		tSettings.m_pGrouper = new CSphGrouperWeek ( tLoc ); break;
+		case SPH_GROUPBY_MONTH:		tSettings.m_pGrouper = new CSphGrouperMonth ( tLoc ); break;
+		case SPH_GROUPBY_YEAR:		tSettings.m_pGrouper = new CSphGrouperYear ( tLoc ); break;
+		case SPH_GROUPBY_ATTR:		tSettings.m_pGrouper = new CSphGrouperAttr ( tLoc ); break;
+		default:
+			sError.SetSprintf ( "invalid group-by mode (mode=%d)", pQuery->m_eGroupFunc );
 			return false;
-		}
-
-		CSphAttrLocator tLoc = tSchema.GetAttr(iGroupBy).m_tLocator;
-		switch ( pQuery->m_eGroupFunc )
-		{
-			case SPH_GROUPBY_DAY:		tSettings.m_pGrouper = new CSphGrouperDay ( tLoc ); break;
-			case SPH_GROUPBY_WEEK:		tSettings.m_pGrouper = new CSphGrouperWeek ( tLoc ); break;
-			case SPH_GROUPBY_MONTH:		tSettings.m_pGrouper = new CSphGrouperMonth ( tLoc ); break;
-			case SPH_GROUPBY_YEAR:		tSettings.m_pGrouper = new CSphGrouperYear ( tLoc ); break;
-			case SPH_GROUPBY_ATTR:		tSettings.m_pGrouper = new CSphGrouperAttr ( tLoc ); break;
-			default:
-				sError.SetSprintf ( "invalid group-by mode (mode=%d)", pQuery->m_eGroupFunc );
-				return false;
-		}
 	}
 
 	tSettings.m_bMVA = ( tSchema.GetAttr(iGroupBy).m_eAttrType & SPH_ATTR_MULTI )!=0;