queuecreator.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright (c) 2017-2026, Manticore Software LTD (https://manticoresearch.com)
  3. // Copyright (c) 2001-2016, Andrew Aksyonoff
  4. // Copyright (c) 2008-2016, Sphinx Technologies Inc
  5. // All rights reserved
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License. You should have
  9. // received a copy of the GPL license along with this program; if you
  10. // did not, you can find it at http://www.gnu.org/
  11. //
  12. #pragma once
  13. #include "sphinxsort.h"
  14. #include "grouper.h"
  15. /// additional group-by sorter settings
  16. struct CSphGroupSorterSettings
  17. {
  18. CSphAttrLocator m_tLocGroupby; ///< locator for @groupby
  19. CSphAttrLocator m_tLocCount; ///< locator for @count
  20. CSphAttrLocator m_tLocDistinct; ///< locator for @distinct
  21. CSphAttrLocator m_tLocGroupbyStr; ///< locator for @groupbystr
  22. bool m_bDistinct = false;///< whether we need distinct
  23. CSphRefcountedPtr<CSphGrouper> m_pGrouper;///< group key calculator
  24. CSphRefcountedPtr<DistinctFetcher_i> m_pDistinctFetcher;
  25. bool m_bImplicit = false;///< for queries with aggregate functions but without group by clause
  26. SharedPtr_t<ISphFilter> m_pAggrFilterTrait; ///< aggregate filter that got owned by grouper
  27. bool m_bJson = false; ///< whether we're grouping by Json attribute
  28. int m_iMaxMatches = 0;
  29. bool m_bGrouped = false; ///< are we going to push already grouped matches to it?
  30. int m_iDistinctAccuracy = 16; ///< HyperLogLog accuracy. 0 means "don't use HLL"
  31. void FixupLocators ( const ISphSchema * pOldSchema, const ISphSchema * pNewSchema );
  32. void SetupDistinctAccuracy ( int iThresh );
  33. };
  34. struct PrecalculatedSorterResults_t
  35. {
  36. int64_t m_iCountDistinct = -1;
  37. int64_t m_iCountFilter = -1;
  38. int64_t m_iCount = -1;
  39. CSphString m_sAttr;
  40. };
  41. /// creates proper queue for given query
  42. /// may return NULL on error; in this case, error message is placed in sError
  43. /// if the pUpdate is given, creates the updater's queue and perform the index update
  44. /// instead of searching
  45. ISphMatchSorter * sphCreateQueue ( const SphQueueSettings_t & tQueue, const CSphQuery & tQuery, CSphString & sError, SphQueueRes_t & tRes, StrVec_t * pExtra = nullptr, QueryProfile_c * pProfile = nullptr, const char * szParent = nullptr );
  46. void sphCreateMultiQueue ( const SphQueueSettings_t & tQueue, const VecTraits_T<CSphQuery> & dQueries, VecTraits_T<ISphMatchSorter *> & dSorters, VecTraits_T<CSphString> & dErrors, SphQueueRes_t & tRes, StrVec_t * pExtra, QueryProfile_c * pProfile, const char * szParent );
  47. bool HasImplicitGrouping ( const CSphQuery & tQuery );
  48. bool sphHasExpressions ( const CSphQuery & tQuery, const CSphSchema & tSchema ); // check query for expressions
  49. int GetAliasedAttrIndex ( const CSphString & sAttr, const CSphQuery & tQuery, const ISphSchema & tSchema );
  50. bool IsGroupbyMagic ( const CSphString & s );
  51. ESphAttr DetermineNullMaskType ( int iNumAttrs );
  52. const char * GetInternalAttrPrefix();
  53. const char * GetInternalJsonPrefix();
  54. bool IsSortStringInternal ( const CSphString & sColumnName );
  55. bool IsSortJsonInternal ( const CSphString & sColumnName );
  56. CSphString SortJsonInternalSet ( const CSphString & sColumnName );