ddc
Public Member Functions | Public Attributes | List of all members
CQCount Class Reference

count query More...

#include <QCount.h>

Inheritance diagram for CQCount:
Inheritance graph
[legend]
Collaboration diagram for CQCount:
Collaboration graph
[legend]

Public Member Functions

 CQCount (CQuery *dtr_=NULL, CQCountKeyExprList *keys_=NULL, size_t sample_=DDCDefaultCountSampleSize, HitSortEnum sort_=NoSort, string lb="", string ub="")
 bison constructor More...
 
virtual ~CQCount (void)
 Default destructor. More...
 
virtual BYTE GetMatchId () const
 get local match-id: keys > dtr More...
 
bool CompileLocal (CQueryCompiler *compiler, bool compileDtr=true, bool compileKeys=true)
 Compile index-dependent query properties. More...
 
virtual bool CheckSatisfiable (CQueryCompiler *compiler)
 Run optional unsatisfiability checks for query before Compile() is called. More...
 
virtual bool Compile (CQueryCompiler *compiler)
 Compile index-dependent query properties. More...
 
virtual void Evaluate ()
 evaluate query: top-level (sanity checks only) More...
 
virtual bool CanCountUniversal ()
 evaluation utility: returns true iff this is a count(*)-query; guts for CConcHolder::IsUniversalCountQuery() More...
 
virtual bool CanCountByFile () const
 evaluation utility: returns true iff this query can count at file-level; wraps m_keys.canCountByFile() More...
 
virtual void CountUniversal (CQueryResult &Result, size_t Limit)
 
virtual void CountLocal (CQueryResult &Result, size_t Limit)
 
virtual void ConvertCountsToHits (CQueryResult &Result, size_t Limit)
 
virtual string toString ()
 DEBUG: return a canonical string form for this query More...
 
virtual string countOptionsToString ()
 
virtual string jsonClass ()
 
virtual string jsonData ()
 
virtual void ClearNode ()
 wrapper for m_dtr->ClearNode() More...
 
virtual void Clear (bool deep=true)
 clear query contents. if deep is true, propagates operation to daughters More...
 
virtual ddcObjectList Children () const
 
virtual void DisownChildren ()
 
- Public Member Functions inherited from CQuery
 CQuery (const string &label=string(""))
 Default constructor. More...
 
virtual ~CQuery (void)
 
virtual bool CompileOptions (CQueryCompiler *compiler=NULL)
 
virtual bool Negated ()
 For sanity checks. Default just returns false. More...
 
virtual bool Negate ()
 Toggle negation flag, returns new value. Default throws an exception. More...
 
virtual BYTE SetMatchId (BYTE matchId)
 Set match-id, returns new value. Default throws an exception. More...
 
virtual bool HasMatchId () const
 Returns true iff this query uses a nontrival match-id operator; default checks (this->GetMatchId() != 0) More...
 
virtual bool RootOK ()
 Is this query an admissible root of a compiled parse tree (default returns !this->Negated()) More...
 
virtual string optionsToString ()
 DEBUG: return canonical option string More...
 
virtual string optionsToJson ()
 return json format option string More...
 
virtual string toJson ()
 
void SetCompiler (CQueryCompiler *compiler)
 
virtual void ClearOptions ()
 deletes m_Options if non-NULL More...
 
virtual void SetOptions (CQueryOptions *opts)
 set global query options ; deletes any pre-existing m_Options More...
 
- Public Member Functions inherited from ddcObject
 ddcObject ()
 Default constructor. More...
 
virtual ~ddcObject ()
 virtual destructor does nothing More...
 
template<typename Visit >
ddcObjectTraverse (Visit &visit)
 
template<typename Visit >
ddcObjectTraverse (Visit &visit) const
 
template<typename Visit >
ddcObjectTraverseR (Visit &visit)
 
template<typename Visit >
ddcObjectTraverseR (Visit &visit) const
 
virtual ddcObjectList Descendants () const
 

Public Attributes

CQuerym_dtr
 underlying query conditions to be counted More...
 
size_t m_sample
 sample size (sub-query limit) More...
 
HitSortEnum m_sort
 sort-order one of: NoSort, (Less|Greater)ByCount(Key|Value) More...
 
string m_lo
 maximum sort-key to return (empty for none) More...
 
string m_hi
 minimum sort-key to return (empty for none) More...
 
CQCountKeyExprListm_keys
 list of count-bin metadata key expressions More...
 
CCountMap m_Counts
 temporary for constructing count-query results More...
 
size_t m_CountSample
 temporary for tracking count-query sample size More...
 
- Public Attributes inherited from CQuery
string m_Label
 arbitrary name for this query node (e.g. string from which it was parsed) More...
 
CQueryCompilerm_Compiler
 associated query compiler (only set on Compile()) More...
 
CQueryNodem_Node
 underlying CQueryNode (DDC-v1.x API) More...
 
CQueryOptionsm_Options
 root-level options (root queries only) More...
 
- Public Attributes inherited from ddcObject
void * m_User
 user data associated with this object (for use e.g. by perl wrappers) More...
 

Detailed Description

count query

Constructor & Destructor Documentation

◆ CQCount()

CQCount::CQCount ( CQuery dtr_ = NULL,
CQCountKeyExprList keys_ = NULL,
size_t  sample_ = DDCDefaultCountSampleSize,
HitSortEnum  sort_ = NoSort,
string  lb = "",
string  ub = "" 
)
inline

bison constructor

References DDCDefaultCountSampleSize.

◆ ~CQCount()

CQCount::~CQCount ( void  )
virtual

Default destructor.

Member Function Documentation

◆ GetMatchId()

BYTE CQCount::GetMatchId ( ) const
virtual

get local match-id: keys > dtr

Reimplemented from CQuery.

◆ CompileLocal()

bool CQCount::CompileLocal ( CQueryCompiler compiler,
bool  compileDtr = true,
bool  compileKeys = true 
)

Compile index-dependent query properties.

References errParseError.

◆ CheckSatisfiable()

bool CQCount::CheckSatisfiable ( CQueryCompiler compiler)
virtual

Run optional unsatisfiability checks for query before Compile() is called.

Reimplemented from CQuery.

References CQuery::CheckSatisfiable().

Here is the call graph for this function:

◆ Compile()

bool CQCount::Compile ( CQueryCompiler compiler)
virtual

Compile index-dependent query properties.

Reimplemented from CQuery.

◆ Evaluate()

void CQCount::Evaluate ( )
virtual

evaluate query: top-level (sanity checks only)

Reimplemented from CQuery.

◆ CanCountUniversal()

bool CQCount::CanCountUniversal ( )
virtual

evaluation utility: returns true iff this is a count(*)-query; guts for CConcHolder::IsUniversalCountQuery()

◆ CanCountByFile()

bool CQCount::CanCountByFile ( ) const
virtual

evaluation utility: returns true iff this query can count at file-level; wraps m_keys.canCountByFile()

Referenced by CConcSession::GetAllHits().

Here is the caller graph for this function:

◆ CountUniversal()

void CQCount::CountUniversal ( CQueryResult Result,
size_t  Limit 
)
virtual

evaluation guts: populate m_Counts with universal counts; formerly CConcHolder::GetUniversalCounts()

  • should be called only once per query
  • stores encoded results in Result
  • implicitly calls ConvertCountsToHits()

References ddcVecFile< T >::begin(), ddcVecFile< T >::end(), CQCountKeyExprList::Evaluate(), CBiblIndex::FileMatches(), CHitBorders::GetBreakCollectionByName(), CConcordance::GetCorpusFilesCount(), CHitBorders::GetFileBreaks(), CConcordance::m_BiblIndex, CHitBorders::CBreakCollection::m_BreakOffsets, CQueryOptions::m_bSeparateHits, CHit::m_FileNo, CQueryOptions::m_Filters, CQueryOptions::m_HitTypeStr, CConcordance::m_MaskedFiles, CQuery::m_Options, and ddcVecFile< T >::size().

Referenced by CConcSession::GetAllHits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CountLocal()

void CQCount::CountLocal ( CQueryResult Result,
size_t  Limit 
)
virtual

evaluation guts: extend m_Counts[] with counts for current search period; formerly CConcHolder::GetPeriodCounts()

  • should be called once per subcorpus search period
  • may (re-)sort Result.m_Hits
  • also clears local query-data in Result (expected to correspond to m_dtr query for current period)
  • ConvertCountsToHits() still needs to be called after all search-periods have been counted

References CQCountKeyExprList::CanCountByFile(), CQCountKeyExprList::Evaluate(), IsLessByFileNo::IsLessByFileNo(), CQueryOptions::IsTrivialFilter(), CQueryResult::m_AllHitsCount, CQueryOptions::m_bSeparateHits, CQueryResult::m_DebugInfo, CQueryResult::m_HighlightIds, CQueryResult::m_HighlightOccurs, CQueryResult::m_Hits, CQueryOptions::m_HitTypeStr, CQuery::m_Options, PredefinedFileBreakName, and CQueryResult::SortResultsByHitP().

Referenced by CConcSession::GetAllHits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertCountsToHits()

void CQCount::ConvertCountsToHits ( CQueryResult Result,
size_t  Limit 
)
virtual

encode count()-query results from m_Counts[] to m_Compiler->m_pHolder->m_Hits[], using m_Hits[] element CHit hit.m_SortKey.s to transport count-key and hit.m_Value.m_Count to transport count results in a backwards-compatible manner.

  • formerly CConcHolder::ConvertCountsToHits()

References GreaterByCountKey, GreaterByCountValue, hsoAscendingCountKeys, hsoAscendingCountValues, hsoDescendingCountKeys, hsoDescendingCountValues, LessByCountKey, LessByCountValue, CQueryResult::m_AllHitsCount, CQueryResult::m_bSortByString, CQueryResult::m_DebugInfo, CQueryResult::m_HighlightIds, CQueryResult::m_HighlightOccurs, CQueryResult::m_Hits, CQueryResult::m_SortOrder, and NoSort.

Referenced by CConcSession::GetAllHits().

Here is the caller graph for this function:

◆ toString()

string CQCount::toString ( void  )
virtual

DEBUG: return a canonical string form for this query

Reimplemented from CQuery.

◆ countOptionsToString()

string CQCount::countOptionsToString ( )
virtual

References DDCDefaultCountSampleSize, EngMakeUpper(), Format(), HitSortEnumStrings, NoSort, and sqString().

Here is the call graph for this function:

◆ jsonClass()

virtual string CQCount::jsonClass ( void  )
inlinevirtual

class-name for json strinfication

  • default implementation returns C++ class name

Reimplemented from CQuery.

◆ jsonData()

string CQCount::jsonData ( void  )
virtual

instance data for json stringification

  • default implementation returns "NODATA":1, for strict syntax compliance

Reimplemented from CQuery.

References Format(), HitSortEnumNames, and jsonStr().

Here is the call graph for this function:

◆ ClearNode()

void CQCount::ClearNode ( )
virtual

wrapper for m_dtr->ClearNode()

Reimplemented from CQuery.

References CQuery::ClearNode().

Here is the call graph for this function:

◆ Clear()

void CQCount::Clear ( bool  deep = true)
virtual

clear query contents. if deep is true, propagates operation to daughters

Reimplemented from CQuery.

◆ Children()

ddcObjectList CQCount::Children ( ) const
virtual

get a list of direct non-NULL CQuery direct daughters of this node

  • default just returns an empty list

Reimplemented from CQuery.

References CQuery::Children().

Here is the call graph for this function:

◆ DisownChildren()

void CQCount::DisownChildren ( )
virtual

"disown" any direct child nodes, preventing their destruction if the current object is deleted

  • default implementation does nothing

Reimplemented from CQuery.

References CQuery::DisownChildren().

Here is the call graph for this function:

Member Data Documentation

◆ m_dtr

CQuery* CQCount::m_dtr

underlying query conditions to be counted

Referenced by CConcSession::GetAllHits().

◆ m_sample

size_t CQCount::m_sample

sample size (sub-query limit)

Referenced by CConcSession::GetAllHits().

◆ m_sort

HitSortEnum CQCount::m_sort

sort-order one of: NoSort, (Less|Greater)ByCount(Key|Value)

◆ m_lo

string CQCount::m_lo

maximum sort-key to return (empty for none)

◆ m_hi

string CQCount::m_hi

minimum sort-key to return (empty for none)

◆ m_keys

CQCountKeyExprList* CQCount::m_keys

list of count-bin metadata key expressions

◆ m_Counts

CCountMap CQCount::m_Counts

temporary for constructing count-query results

◆ m_CountSample

size_t CQCount::m_CountSample

temporary for tracking count-query sample size

Referenced by CConcSession::GetAllHits().


The documentation for this class was generated from the following files: