NCBI C++ ToolKit
|
Classes | |
class | CBDB_QueryNode |
Query node class. More... | |
class | CBDB_Query |
Query class incapsulates query tree (query clause) and implements set of utility methods to construct query trees. More... | |
class | CBDB_FileScanner |
Scans the BDB file, searches the matching records. More... | |
Typedefs | |
typedef CTreeNode< CBDB_QueryNode > | CBDB_Query::TQueryClause |
Enumerations | |
enum | CBDB_QueryNode::ENodeType { CBDB_QueryNode::eLogical , CBDB_QueryNode::eOperator , CBDB_QueryNode::eFunction , CBDB_QueryNode::eValue , CBDB_QueryNode::eDBField } |
enum | CBDB_QueryNode::ELogicalType { CBDB_QueryNode::eAnd , CBDB_QueryNode::eOr , CBDB_QueryNode::eNot } |
Subtype of ENodeType - eLogical. More... | |
enum | CBDB_QueryNode::EOperatorType { CBDB_QueryNode::eEQ , CBDB_QueryNode::eGT , CBDB_QueryNode::eGE , CBDB_QueryNode::eLT , CBDB_QueryNode::eLE } |
Subtype of ENodeType - eOperator. More... | |
enum | CBDB_FileScanner::EScanAction { CBDB_FileScanner::eContinue , CBDB_FileScanner::eStop } |
Scanner control codes. More... | |
Definition at line 141 of file bdb_query.hpp.
Subtype of ENodeType - eLogical.
Enumerator | |
---|---|
eAnd | |
eOr | |
eNot |
Definition at line 63 of file bdb_query.hpp.
Enumerator | |
---|---|
eLogical | |
eOperator | |
eFunction | |
eValue | |
eDBField |
Definition at line 53 of file bdb_query.hpp.
Subtype of ENodeType - eOperator.
Enumerator | |
---|---|
eEQ | |
eGT | |
eGE | |
eLT | |
eLE |
Definition at line 71 of file bdb_query.hpp.
Scanner control codes.
Enumerator | |
---|---|
eContinue | Keep scanning. |
eStop | Stop search process. |
Definition at line 212 of file bdb_query.hpp.
void BDB_ParseQuery | ( | const char * | query_str, |
CBDB_Query * | query | ||
) |
Parse query string, build the correct the query statement.
query_str | - source query string |
query | - query object owns the statement (query clause tree) after successful parsing. |
Definition at line 187 of file bdb_query_parser_main.cpp.
References env, CResourcePool_Base< Value, Lock, CF >::ForgetAll(), CResourcePool_Base< Value, Lock, CF >::GetFreeList(), query, and yyparse.
Referenced by CBDB_FileDumper::SetQuery().
void BDB_PrintQueryTree | ( | CNcbiOstream & | os, |
const CBDB_Query & | query | ||
) |
Function prints the query tree on the specified ostream (Intended more for debugging purposes)
Definition at line 1112 of file bdb_query.cpp.
References query, and TreeDepthFirstTraverse().
CBDB_FileScanner::CBDB_FileScanner | ( | CBDB_File & | db_file | ) |
Definition at line 765 of file bdb_query.cpp.
|
private |
|
private |
CBDB_Query::CBDB_Query | ( | TQueryClause * | qc = 0 | ) |
Contruct the query.
If QueryClause is NOT NULL takes the ownership.
qc | Query clause. (Should be created by new) |
Definition at line 121 of file bdb_query.cpp.
References CBDB_Query::m_QueryClause.
CBDB_QueryNode::CBDB_QueryNode | ( | const CBDB_QueryNode & | qnode | ) |
Definition at line 69 of file bdb_query.cpp.
References CBDB_QueryNode::LogicalType, CBDB_QueryNode::m_NodeType, CBDB_QueryNode::m_NotFlag, CBDB_QueryNode::m_SubType, and CBDB_QueryNode::m_Value.
CBDB_QueryNode::CBDB_QueryNode | ( | ELogicalType | ltype | ) |
Construction of logical (AND, OR, etc) node.
Definition at line 53 of file bdb_query.cpp.
References CBDB_QueryNode::m_SubType.
CBDB_QueryNode::CBDB_QueryNode | ( | EOperatorType | otype, |
bool | not_flag = false |
||
) |
Construction of operator node.
Definition at line 60 of file bdb_query.cpp.
References CBDB_QueryNode::m_SubType.
Constuction of value type node.
Definition at line 47 of file bdb_query.cpp.
|
protected |
Returns TRUE if file record matches the query.
Definition at line 961 of file bdb_query.cpp.
References CBDB_QueryNode::GetAltValue(), CBDB_QueryNode::GetValue(), CTreeNode< TValue, TKeyGetterP >::GetValue(), CBDB_FileScanner::m_File, query, CBDB_FileScanner::ResolveFields(), and TreeDepthFirstTraverse().
Referenced by CBDB_FileScanner::Scan(), and CBDB_FileScanner::StaticEvaluate().
Get alternative value.
Definition at line 120 of file bdb_query.hpp.
References CBDB_QueryNode::m_AltValue.
Referenced by CBDB_FileScanner::Evaluate().
|
inline |
Definition at line 114 of file bdb_query.hpp.
References CBDB_QueryNode::m_SubType.
Referenced by CScannerFunctorArgN::GetArguments().
CBDB_QueryNode::ELogicalType CBDB_QueryNode::GetLogicType | ( | ) | const |
Definition at line 93 of file bdb_query.cpp.
References BDB_THROW, CBDB_QueryNode::eLogical, CBDB_QueryNode::m_NodeType, and CBDB_QueryNode::m_SubType.
Referenced by CQueryTreePrintFunc::operator()(), and CScannerEvaluateFunc::operator()().
CBDB_QueryNode::EOperatorType CBDB_QueryNode::GetOperatorType | ( | ) | const |
Definition at line 102 of file bdb_query.cpp.
References BDB_THROW, CBDB_QueryNode::eOperator, CBDB_QueryNode::m_NodeType, and CBDB_QueryNode::m_SubType.
Referenced by CQueryTreePrintFunc::operator()(), and CScannerEvaluateFunc::operator()().
|
inline |
Definition at line 149 of file bdb_query.hpp.
References CBDB_Query::m_QueryClause.
|
inline |
Definition at line 150 of file bdb_query.hpp.
References CBDB_Query::m_QueryClause.
|
inline |
Definition at line 94 of file bdb_query.hpp.
References CBDB_QueryNode::m_NodeType.
Referenced by CScannerFunctorArgN::GetArguments(), CQueryTreePrintFunc::operator()(), CQueryTreeFieldResolveFunc::operator()(), CScannerEvaluateFunc::operator()(), and s_ResetQueryNode().
|
inline |
Definition at line 104 of file bdb_query.hpp.
References CBDB_QueryNode::m_Value.
Definition at line 103 of file bdb_query.hpp.
References CBDB_QueryNode::m_Value.
Referenced by CBDB_FileScanner::Evaluate(), CScannerFunctorArgN::GetArguments(), CQueryTreePrintFunc::operator()(), CQueryTreeFieldResolveFunc::operator()(), and CScannerEvaluateFunc::operator()().
|
inline |
Definition at line 107 of file bdb_query.hpp.
References CBDB_QueryNode::m_Value.
Referenced by CQueryTreePrintFunc::operator()(), CQueryTreeFieldResolveFunc::operator()(), and CScannerEvaluateFunc::operator()().
|
inline |
Definition at line 99 of file bdb_query.hpp.
References CBDB_QueryNode::m_NotFlag.
Referenced by CQueryTreePrintFunc::operator()(), and CScannerEvaluateFunc::operator()().
|
static |
Creates new logical node of the query.
Definition at line 191 of file bdb_query.cpp.
Referenced by yyparse().
|
static |
Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree).
Function receives two argument nodes which are attached to the result clause. In terms of memory management caller does not need to deallocate them.
otype | - type of the operator to create |
arg1 | - argument node. |
arg2 | - argument node. |
Definition at line 177 of file bdb_query.cpp.
|
static |
Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree).
Definition at line 164 of file bdb_query.cpp.
Referenced by yyparse().
|
virtual |
Called when scanner finds a record matching the query terms Function returns a control code (EScanAction) to confirm or interrupt scanning process.
Reimplemented in CBDB_DumpScanner.
Definition at line 776 of file bdb_query.cpp.
References CBDB_FileScanner::eContinue.
Referenced by CBDB_FileScanner::Scan().
|
private |
|
private |
CBDB_QueryNode & CBDB_QueryNode::operator= | ( | const CBDB_QueryNode & | qnode | ) |
Definition at line 78 of file bdb_query.cpp.
References CBDB_QueryNode::LogicalType, CBDB_QueryNode::m_NodeType, CBDB_QueryNode::m_NotFlag, CBDB_QueryNode::m_SubType, and CBDB_QueryNode::m_Value.
void CBDB_Query::ResetQueryClause | ( | ) |
Definition at line 152 of file bdb_query.cpp.
References CBDB_Query::m_QueryClause, s_ResetQueryNode(), and TreeDepthFirstTraverse().
Referenced by CBDB_FileDumper::Dump().
|
protected |
Definition at line 988 of file bdb_query.cpp.
References CBDB_FileScanner::m_File, query, and TreeDepthFirstTraverse().
Referenced by CBDB_FileScanner::Evaluate(), and CBDB_FileScanner::Scan().
void CBDB_FileScanner::Scan | ( | CBDB_FileCursor & | cur, |
CBDB_Query & | query | ||
) |
Scan the BDB file cursor, search the qualified records When record found function calls OnRecordFound.
Definition at line 801 of file bdb_query.cpp.
References eBDB_Ok, CBDB_FileScanner::eStop, CBDB_FileScanner::Evaluate(), CBDB_FileCursor::Fetch(), CBDB_FileScanner::OnRecordFound(), query, and CBDB_FileScanner::ResolveFields().
void CBDB_FileScanner::Scan | ( | CBDB_Query & | query | ) |
Scan the BDB file, search the qualified records When record found function calls OnRecordFound.
Definition at line 782 of file bdb_query.cpp.
References eBDB_Ok, CBDB_FileCursor::eFirst, CBDB_FileScanner::eStop, CBDB_FileScanner::Evaluate(), CBDB_FileCursor::Fetch(), CBDB_FileScanner::m_File, CBDB_FileScanner::OnRecordFound(), query, CBDB_FileScanner::ResolveFields(), and CBDB_FileCursor::SetCondition().
Set alternative value.
Definition at line 117 of file bdb_query.hpp.
References CBDB_QueryNode::m_AltValue.
Referenced by CScannerEvaluateFunc::operator()(), and s_ResetQueryNode().
void CBDB_QueryNode::SetField | ( | int | field_idx | ) |
Set node type to eDBField.
field_idx | database field index |
Definition at line 111 of file bdb_query.cpp.
References CBDB_QueryNode::eDBField, CBDB_QueryNode::m_NodeType, and CBDB_QueryNode::m_SubType.
Referenced by CQueryTreeFieldResolveFunc::operator()().
|
inline |
Set NOT flag (NOT EQ, etc)
Definition at line 101 of file bdb_query.hpp.
References CBDB_QueryNode::m_NotFlag.
void CBDB_Query::SetQueryClause | ( | TQueryClause * | query_clause | ) |
Replace current query clause with the new one.
CBDB_Query object takes ownership on the passed argument.
Definition at line 157 of file bdb_query.cpp.
References CBDB_Query::m_QueryClause.
Definition at line 105 of file bdb_query.hpp.
References CBDB_QueryNode::m_Value, and rapidjson::value.
Referenced by CScannerFunctorEQ::Eval(), CScannerFunctorAND::Eval(), CScannerFunctorOR::Eval(), CScannerFunctorNOT::Eval(), CQueryTreeFieldResolveFunc::operator()(), s_ResetQueryNode(), and CScannerFunctorArgN::SetResult().
|
inline |
Static query evaluation without changing current position in the database file.
Intended purpose: debugging
Definition at line 234 of file bdb_query.hpp.
References CBDB_FileScanner::Evaluate(), and query.
Referenced by CBDB_FileDumper::Dump().
|
virtual |
Definition at line 771 of file bdb_query.cpp.
CBDB_Query::~CBDB_Query | ( | ) |
Definition at line 130 of file bdb_query.cpp.
References CBDB_Query::m_QueryClause.
CBDB_QueryNode::~CBDB_QueryNode | ( | ) |
Definition at line 88 of file bdb_query.cpp.
int CBDB_QueryNode::FieldIdx |
Definition at line 128 of file bdb_query.hpp.
int { ... } ::FieldIdx |
Definition at line 128 of file bdb_query.hpp.
ELogicalType { ... } ::LogicalType |
Definition at line 126 of file bdb_query.hpp.
ELogicalType CBDB_QueryNode::LogicalType |
Definition at line 126 of file bdb_query.hpp.
Referenced by CBDB_QueryNode::CBDB_QueryNode(), and CBDB_QueryNode::operator=().
|
protected |
Alternative value.
Definition at line 132 of file bdb_query.hpp.
Referenced by CBDB_QueryNode::GetAltValue(), and CBDB_QueryNode::SetAltValue().
|
protected |
Searched BDB file.
Definition at line 254 of file bdb_query.hpp.
Referenced by CBDB_FileScanner::Evaluate(), CBDB_FileScanner::ResolveFields(), and CBDB_FileScanner::Scan().
|
protected |
Definition at line 124 of file bdb_query.hpp.
Referenced by CBDB_QueryNode::CBDB_QueryNode(), CBDB_QueryNode::GetLogicType(), CBDB_QueryNode::GetOperatorType(), CBDB_QueryNode::GetType(), CBDB_QueryNode::operator=(), and CBDB_QueryNode::SetField().
|
protected |
Inverted function.
Definition at line 130 of file bdb_query.hpp.
Referenced by CBDB_QueryNode::CBDB_QueryNode(), CBDB_QueryNode::IsNot(), CBDB_QueryNode::operator=(), and CBDB_QueryNode::SetNot().
TQueryClause* CBDB_Query::m_QueryClause |
Definition at line 198 of file bdb_query.hpp.
Referenced by CBDB_Query::CBDB_Query(), CBDB_Query::GetQueryClause(), CBDB_Query::ResetQueryClause(), CBDB_Query::SetQueryClause(), and CBDB_Query::~CBDB_Query().
union { ... } CBDB_QueryNode::m_SubType |
|
protected |
Definition at line 131 of file bdb_query.hpp.
Referenced by CBDB_QueryNode::CBDB_QueryNode(), CBDB_QueryNode::GetValue(), CBDB_QueryNode::HasValue(), CBDB_QueryNode::operator=(), and CBDB_QueryNode::SetValue().
EOperatorType CBDB_QueryNode::OperatorType |
Definition at line 127 of file bdb_query.hpp.
EOperatorType { ... } ::OperatorType |
Definition at line 127 of file bdb_query.hpp.