NCBI C++ ToolKit
query_exec.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: query_exec.cpp 73942 2016-08-02 14:12:12Z falkrb $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Anatoliy Kuznetsov
27  *
28  * File Description:
29  * Query execution implementations
30  *
31  */
32 
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbitime.hpp>
37 
39 
41 {
42 }
43 
45  TArgVector& args)
46 {
47  args.resize(0);
50  int i = 0;
51  for (; it != it_end; ++it, ++i) {
52  CTreeNode<CQueryParseNode>* arg_node = *it;
53  args.push_back(arg_node);
54  } // for
55 }
56 
59 {
62  if (it == it_end)
63  return 0;
64  return *it;
65 }
66 
67 
69 {
70  return *(GetExec().GetQTree());
71 }
72 
73 
74 
75 
76 
77 
79 : m_FuncReg(CQueryParseNode::eMaxType),
80  m_QTree(0),
81  m_ExceptionCount(0),
82  m_QueriedCount(0)
83 {
84  for (size_t i = 0; i < m_FuncReg.size(); ++i) {
85  m_FuncReg[i] = 0;
86  }
87 }
88 
90 {
91  for (size_t i = 0; i < m_FuncReg.size(); ++i) {
92  delete m_FuncReg[i];
93  }
94 }
95 
97  CQueryFunctionBase* func)
98 {
99  int i = func_type;
100  delete m_FuncReg[i];
101  m_FuncReg[i] = func;
102  func->SetExec(*this);
103 }
104 
106 {
107  m_ImplicitSearchFunc.reset(func);
108 }
109 
111 {
112  m_QTree = &qtree;
113  CQueryExecEvalFunc visitor(*this);
114  TreeDepthFirstTraverse(*qtree.GetQueryTree(), visitor);
115  m_QTree = 0;
116 }
117 
118 
120 {
121  m_QTree = &qtree;
122  CQueryExecEvalFunc visitor(*this);
123  TreeDepthFirstTraverse(node, visitor);
124  m_QTree = 0;
125 }
126 
127 
Expression evaluation visitor functor.
Definition: query_exec.hpp:249
Base class for evaluation functions.
Definition: query_exec.hpp:68
Query node class.
Definition: query_parse.hpp:79
Query tree and associated utility methods.
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CQueryParseTree * m_QTree
Definition: query_exec.hpp:240
void SetExec(CQueryExec &qexec)
Set reference on parent query execution class.
Definition: query_exec.hpp:116
void AddImplicitSearchFunc(CQueryFunctionBase *func)
This is a callback for implicit search nodes Our syntax allows queries like (a=1) AND "search_term" E...
Definition: query_exec.cpp:105
CQueryParseTree & GetQueryTree()
Get query tree (execution context)
Definition: query_exec.cpp:68
vector< CQueryParseTree::TNode * > TArgVector
Vector for easy argument access.
Definition: query_exec.hpp:72
const TNode * GetQueryTree() const
EType
Query node type.
Definition: query_parse.hpp:84
TFuncReg m_FuncReg
Definition: query_exec.hpp:238
virtual ~CQueryExec()
Definition: query_exec.cpp:89
CQueryParseTree::TNode * GetArg0(CQueryParseTree::TNode &qnode)
Get first sub-node.
Definition: query_exec.cpp:58
unique_ptr< CQueryFunctionBase > m_ImplicitSearchFunc
Definition: query_exec.hpp:239
CQueryExec & GetExec()
Get reference on parent execution environment.
Definition: query_exec.hpp:108
void AddFunc(CQueryParseNode::EType func_type, CQueryFunctionBase *func)
Register function implementation.
Definition: query_exec.cpp:96
CQueryParseTree * GetQTree()
Definition: query_exec.hpp:229
void MakeArgVector(CQueryParseTree::TNode &qnode, TArgVector &args)
Created vector of arguments (translate sub-nodes to vector)
Definition: query_exec.cpp:44
virtual ~CQueryFunctionBase()
Definition: query_exec.cpp:40
virtual void Evaluate(CQueryParseTree &qtree)
Run query tree evaluation.
Definition: query_exec.cpp:110
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TNodeList::iterator TNodeList_I
Definition: ncbi_tree.hpp:109
Fun TreeDepthFirstTraverse(TTreeNode &tree_node, Fun func)
Depth-first tree traversal algorithm.
Definition: ncbi_tree.hpp:504
TNodeList_CI SubNodeBegin(void) const
Return first const iterator on subnode list.
Definition: ncbi_tree.hpp:160
TNodeList_CI SubNodeEnd(void) const
Return last const iterator on subnode list.
Definition: ncbi_tree.hpp:166
int i
Defines: CTimeFormat - storage class for time format.
Query parser execution implementations.
Modified on Mon Jul 22 05:02:10 2024 by modify_doxy.py rev. 669887