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

CQueryNode is an abstract class for any node in a query parse tree. A parse tree is built by YACC during CQueryCompiler::ParseQuery. This class contains all members which are common to atomic and operation nodes. More...

#include <QueryNode.h>

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

Public Member Functions

 CQueryNode (bool bUseNodeIndices=false, bool bUseMatchIds=false, const CConcHolder *holder=NULL)
 Constructor. More...
 
virtual ~CQueryNode ()
 Destructor. More...
 
virtual void Evaluate (bool bSeparateHits=false)
 
virtual void EvaluateWithoutHits ()
 initial-stage query evaluation EvaluateWithoutHits is the first stage of the evaluation of one query. The main task it to build CQueryNode::m_Occurrences, which is written by chunks, sorted by the first item of a chunk. More...
 
void SetNegation (bool Value)
 set m_bNegated More...
 
bool GetNegation () const
 get m_bNegated More...
 
void AddOccurrence (const CQueryNode &FromNode, int FromOcc)
 insers a single occurrence FromNode.m_Occurrences[occ] More...
 
void AddOccurrences (const CQueryNode &FromNode, int start, int end)
 inserts occurrences [FromNode.m_Occurrences.begin()+start, FromNode.m_Occurrences.begin()+end) into m_Occurrences[] (and m_OccurrenceNodeIndices if appropriate) More...
 
void AddOccurrences2 (const CQueryNode &FromNode1, int start1, int end1, const CQueryNode &FromNode2, int start2, int end2)
 appends occurrences from both FromNode1 and FromNode2, maintaining sort-order and respecting both m_bUseNodeIndices and m_bUseMatchIds More...
 
void AddOccurrences3 (const CQueryNode &FromNode1, int start1, int end1, const CQueryNode &FromNode2, int start2, int end2, const CQueryNode &FromNode3, int start3, int end3)
 appends occurrences from FromNode1, FromNode2, and FromNode3 maintaining sort-order and respecting both m_bUseNodeIndices and m_bUseMatchIds More...
 
void ClearAndReserveOccurrences (int size)
 
void SwapOccurrences (CQueryNode &Node, bool swapChunkLengths=false)
 swaps m_Occurrences[], m_OccurrenceNodeIndices[], and m_OccurrenceMatchIds[] between caller object and Node More...
 
void ConvertOccurrencesToHits (bool bSeparateHits)
 convert occurrences to hits using m_pHolder->GetBreaks() More...
 
void ConvertOccurrencesToHitsForPatterns (bool bSeparateHits)
 convert occurrences to hits for pattern query construction (like "mother likes father") More...
 
void EnsureChunkOffsets ()
 ensure m_ChunkOffsets[] is populated More...
 
void SetHolder (const CConcHolder *pHolder)
 set m_pHolder dependent properties m_bUseNodeIndices, m_bUseMatchIds More...
 
virtual bool IsUniversalWildcard () const
 return true iff this is a universal wildcard query (*); default returns false More...
 
virtual size_t GetNodeFrequencyByNodeIndex (size_t NodeIndex) const
 get occurrence count by query-node index; used by rank-sort operator. default implementation in CQueryNode just chokes. More...
 
DWORD HitOccurrencesBegin (DWORD HitNo) const
 get the index of the first occurrence in m_Occurrences[] for hit number HitNo More...
 
DWORD HitOccurrencesEnd (DWORD HitNo) const
 get the index of the first occurrence in m_Occurrences[] after hit number HitNo More...
 
DWORD GetFirstOccurrenceInHit (DWORD HitNo, BYTE MatchId) const
 
DWORD GetLastOccurrenceInHit (DWORD HitNo, BYTE MatchId) const
 
DWORD GetMiddleOccurrenceInHit (DWORD HitNo, BYTE MatchId) const
 
DWORD BreakStride () const
 get average size of gap between breaks in m_Hits[]; returned value is always >= 1 More...
 

Public Attributes

bool m_bAtomic
 true if this node is a description of one token or a sequence of adjacent tokens More...
 
bool m_bNegated
 is the node negated? More...
 
string m_Source
 the string from which this node was created More...
 
vector< CTokenNom_Occurrences
 all occurrences of this node in the current subcorpus, which should be highlighted More...
 
bool m_bUseNodeIndices
 should DDC uses m_OccurrenceNodeIndices (m_OccurrenceNodeIndices is necessary only for #less_by_rank) More...
 
vector< BYTEm_OccurrenceNodeIndices
 query node indices for each occurrence (the origin for each occurrence) More...
 
bool m_bUseMatchIds
 should DDC use m_OccurrenceMatchIds to track match-ids? More...
 
vector< BYTEm_OccurrenceMatchIds
 match-ids for each occurrence in m_Occurrences (only if m_bUseMatchIds is true) More...
 
vector< CHitm_Hits
 all hits of this node in the current subcorpora More...
 
const CConcHolderm_pHolder
 a reference to the parent holder (moo: should be unused until evaluation time, but isn't!) More...
 
vector< DWORDm_ChunkLengths
 
vector< DWORDm_ChunkOffsets
 
vector< int > m_CacheIds
 ??? More...
 

Detailed Description

CQueryNode is an abstract class for any node in a query parse tree. A parse tree is built by YACC during CQueryCompiler::ParseQuery. This class contains all members which are common to atomic and operation nodes.

moo: this class looks like it should be an abstract representation of query without any direct dependence on an actual index instance (e.g. ConcHolder or ConcIndexator) until evaluation time, but that doesn't appear to be the case. Attempting to re-build a more modular abstract query representation in Query.(cpp|h).

Constructor & Destructor Documentation

◆ CQueryNode()

CQueryNode::CQueryNode ( bool  bUseNodeIndices = false,
bool  bUseMatchIds = false,
const CConcHolder holder = NULL 
)
inline

Constructor.

References Evaluate(), EvaluateWithoutHits(), GetNegation(), SetNegation(), and ~CQueryNode().

Here is the call graph for this function:

◆ ~CQueryNode()

CQueryNode::~CQueryNode ( )
virtual

Destructor.

References ClearVector(), m_OccurrenceMatchIds, m_OccurrenceNodeIndices, and m_Occurrences.

Referenced by CQueryNode().

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

Member Function Documentation

◆ Evaluate()

void CQueryNode::Evaluate ( bool  bSeparateHits = false)
virtual

evaluate query node with respect to m_pHolder , populating m_Hits[] attributes m_BreakNo, m_HighlightOcurrencesEnd . If bSeparateHits is false (default), hits in m_Hits[] will by aggregated by m_BreakNo (i.e. at most one instance of any m_BreakNo value in m_Hits[])

Reimplemented in CQueryWithNode, CQueryNearNode, CQuerySequenceNode, CQueryTokenNode, CQueryOrOperation, and CQueryAndOperation.

References errParseError.

Referenced by CQueryNode(), CQuery::Evaluate(), CQueryAndOperation::~CQueryAndOperation(), CQueryOrOperation::~CQueryOrOperation(), and CQueryWithNode::~CQueryWithNode().

Here is the caller graph for this function:

◆ EvaluateWithoutHits()

void CQueryNode::EvaluateWithoutHits ( )
virtual

initial-stage query evaluation EvaluateWithoutHits is the first stage of the evaluation of one query. The main task it to build CQueryNode::m_Occurrences, which is written by chunks, sorted by the first item of a chunk.

Reimplemented in CQueryWithorNode, CQueryWithoutNode, CQueryWithNode, CQuerySequenceNode, and CQueryTokenNode.

Referenced by CQueryNode(), CQueryWithNode::Evaluate(), CQueryNearNode::FindOccurrences2(), CQueryNearNode::FindOccurrences3(), CConcSession::GetOccurrences(), CQueryWithNode::~CQueryWithNode(), CQueryWithorNode::~CQueryWithorNode(), and CQueryWithoutNode::~CQueryWithoutNode().

Here is the caller graph for this function:

◆ SetNegation()

void CQueryNode::SetNegation ( bool  Value)

set m_bNegated

References m_bNegated.

Referenced by CQNegatable::Compile(), CQueryNode(), CQueryAndOperation::Evaluate(), and CQueryOrOperation::Evaluate().

Here is the caller graph for this function:

◆ GetNegation()

bool CQueryNode::GetNegation ( ) const

get m_bNegated

References m_bNegated.

Referenced by CQueryNode().

Here is the caller graph for this function:

◆ AddOccurrence()

void CQueryNode::AddOccurrence ( const CQueryNode FromNode,
int  FromOcc 
)
inline

◆ AddOccurrences()

void CQueryNode::AddOccurrences ( const CQueryNode FromNode,
int  start,
int  end 
)

◆ AddOccurrences2()

void CQueryNode::AddOccurrences2 ( const CQueryNode FromNode1,
int  start1,
int  end1,
const CQueryNode FromNode2,
int  start2,
int  end2 
)

appends occurrences from both FromNode1 and FromNode2, maintaining sort-order and respecting both m_bUseNodeIndices and m_bUseMatchIds

References AddOccurrences(), m_bUseMatchIds, m_bUseNodeIndices, m_OccurrenceMatchIds, m_OccurrenceNodeIndices, and m_Occurrences.

Referenced by AddOccurrence(), CQueryNearNode::FindOccurrences2(), CQueryBinaryOperationNode::hits_and_positions_intersection(), and CQueryBinaryOperationNode::hits_and_positions_union().

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

◆ AddOccurrences3()

void CQueryNode::AddOccurrences3 ( const CQueryNode FromNode1,
int  start1,
int  end1,
const CQueryNode FromNode2,
int  start2,
int  end2,
const CQueryNode FromNode3,
int  start3,
int  end3 
)

appends occurrences from FromNode1, FromNode2, and FromNode3 maintaining sort-order and respecting both m_bUseNodeIndices and m_bUseMatchIds

References AddOccurrences(), m_bUseMatchIds, m_bUseNodeIndices, m_OccurrenceMatchIds, m_OccurrenceNodeIndices, and m_Occurrences.

Referenced by AddOccurrence(), and CQueryNearNode::FindOccurrences3().

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

◆ ClearAndReserveOccurrences()

void CQueryNode::ClearAndReserveOccurrences ( int  size)

◆ SwapOccurrences()

void CQueryNode::SwapOccurrences ( CQueryNode Node,
bool  swapChunkLengths = false 
)

swaps m_Occurrences[], m_OccurrenceNodeIndices[], and m_OccurrenceMatchIds[] between caller object and Node

References m_ChunkLengths, m_OccurrenceMatchIds, m_OccurrenceNodeIndices, and m_Occurrences.

Referenced by AddOccurrence(), ConvertOccurrencesToHits(), ConvertOccurrencesToHitsForPatterns(), CQueryWithNode::EvaluateWithoutHits(), and CQueryBinaryOperationNode::hits_and_positions_swap().

Here is the caller graph for this function:

◆ ConvertOccurrencesToHits()

void CQueryNode::ConvertOccurrencesToHits ( bool  bSeparateHits)

◆ ConvertOccurrencesToHitsForPatterns()

void CQueryNode::ConvertOccurrencesToHitsForPatterns ( bool  bSeparateHits)

◆ EnsureChunkOffsets()

void CQueryNode::EnsureChunkOffsets ( )

ensure m_ChunkOffsets[] is populated

References m_ChunkLengths, and m_ChunkOffsets.

Referenced by AddOccurrence().

Here is the caller graph for this function:

◆ SetHolder()

void CQueryNode::SetHolder ( const CConcHolder pHolder)

◆ IsUniversalWildcard()

bool CQueryNode::IsUniversalWildcard ( ) const
virtual

return true iff this is a universal wildcard query (*); default returns false

Reimplemented in CQueryTokenNode.

Referenced by AddOccurrence(), CQuerySequenceNode::EvaluateWithoutHits(), CQueryNearNode::FindOccurrences2(), and CQueryNearNode::FindOccurrences3().

Here is the caller graph for this function:

◆ GetNodeFrequencyByNodeIndex()

size_t CQueryNode::GetNodeFrequencyByNodeIndex ( size_t  NodeIndex) const
virtual

get occurrence count by query-node index; used by rank-sort operator. default implementation in CQueryNode just chokes.

Reimplemented in CQueryNearNode, CQuerySequenceNode, CQueryTokenNode, and CQueryBinaryOperationNode.

Referenced by AddOccurrence(), CQueryNearNode::GetNodeFrequencyByNodeIndex(), CConcSession::InitSortByRank(), and CQueryBinaryOperationNode::pushHit().

Here is the caller graph for this function:

◆ HitOccurrencesBegin()

DWORD CQueryNode::HitOccurrencesBegin ( DWORD  HitNo) const
inline

get the index of the first occurrence in m_Occurrences[] for hit number HitNo

Referenced by GetFirstOccurrenceInHit(), GetLastOccurrenceInHit(), and GetMiddleOccurrenceInHit().

Here is the caller graph for this function:

◆ HitOccurrencesEnd()

DWORD CQueryNode::HitOccurrencesEnd ( DWORD  HitNo) const
inline

get the index of the first occurrence in m_Occurrences[] after hit number HitNo

References GetFirstOccurrenceInHit(), GetLastOccurrenceInHit(), and GetMiddleOccurrenceInHit().

Referenced by GetFirstOccurrenceInHit(), GetLastOccurrenceInHit(), and GetMiddleOccurrenceInHit().

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

◆ GetFirstOccurrenceInHit()

DWORD CQueryNode::GetFirstOccurrenceInHit ( DWORD  HitNo,
BYTE  MatchId 
) const

scan for first occurrence of match-id MatchId for hit HitNo in m_OccurrenceMatchIds[]; only valid if m_bUseMatchIds is true

Returns
least occurence-index i such that: occurrence i belongs to Hits[HitNo] and as match-id MatchId, or (DOWRD)-1 if none exists

References HitOccurrencesBegin(), HitOccurrencesEnd(), and m_OccurrenceMatchIds.

Referenced by HitOccurrencesEnd(), and CConcSession::InitSortByContext().

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

◆ GetLastOccurrenceInHit()

DWORD CQueryNode::GetLastOccurrenceInHit ( DWORD  HitNo,
BYTE  MatchId 
) const

scan for last occurrence of match-id MatchId for hit HitNo in m_OccurrenceMatchIds[]; only valid if m_bUseMatchIds is true

Returns
greatest occurence-index i such that: occurrence i belongs to Hits[HitNo] and as match-id MatchId, or (DWORD)-1 if none exists

References HitOccurrencesBegin(), HitOccurrencesEnd(), and m_OccurrenceMatchIds.

Referenced by HitOccurrencesEnd(), and CConcSession::InitSortByContext().

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

◆ GetMiddleOccurrenceInHit()

DWORD CQueryNode::GetMiddleOccurrenceInHit ( DWORD  HitNo,
BYTE  MatchId 
) const

scan for middle-most occurrence of match-id MatchId for hit HitNo in m_OccurrenceMatchIds[]; only valid if m_bUseMatchIds is true

Returns
middle-most occurence-index i such that: occurrence i belongs to Hits[HitNo] and as match-id MatchId, or (DWORD)-1 if none exists

References HitOccurrencesBegin(), HitOccurrencesEnd(), and m_OccurrenceMatchIds.

Referenced by HitOccurrencesEnd(), and CConcSession::InitSortByContext().

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

◆ BreakStride()

DWORD CQueryNode::BreakStride ( ) const
inline

get average size of gap between breaks in m_Hits[]; returned value is always >= 1

Member Data Documentation

◆ m_bAtomic

bool CQueryNode::m_bAtomic

◆ m_bNegated

bool CQueryNode::m_bNegated

is the node negated?

Referenced by GetNegation(), and SetNegation().

◆ m_Source

string CQueryNode::m_Source

◆ m_Occurrences

vector<CTokenNo> CQueryNode::m_Occurrences

◆ m_bUseNodeIndices

bool CQueryNode::m_bUseNodeIndices

◆ m_OccurrenceNodeIndices

vector<BYTE> CQueryNode::m_OccurrenceNodeIndices

◆ m_bUseMatchIds

bool CQueryNode::m_bUseMatchIds

◆ m_OccurrenceMatchIds

vector<BYTE> CQueryNode::m_OccurrenceMatchIds

◆ m_Hits

vector<CHit> CQueryNode::m_Hits

◆ m_pHolder

const CConcHolder* CQueryNode::m_pHolder

a reference to the parent holder (moo: should be unused until evaluation time, but isn't!)

Referenced by CQueryTokenNode::BuildRegExp(), ConvertOccurrencesToHits(), ConvertOccurrencesToHitsForPatterns(), CQueryTokenNode::EvaluateWithoutHits(), and SetHolder().

◆ m_ChunkLengths

vector<DWORD> CQueryNode::m_ChunkLengths

◆ m_ChunkOffsets

vector<DWORD> CQueryNode::m_ChunkOffsets

chunk offsets, used by CQuerySequenceNode queries; use EnsureChunkOffsets() to populate if required

  • introduced in v2.1.19; still unused (should probably be used to allow binary-search seek for NEAR queries

Referenced by EnsureChunkOffsets().

◆ m_CacheIds

vector<int> CQueryNode::m_CacheIds

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