source: trunk/gsdl/src/mgpp/text/MGQuery.h@ 860

Last change on this file since 860 was 860, checked in by rjmcnab, 24 years ago

Fixed a couple of bugs and made building silent if needed.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/**************************************************************************
2 *
3 * MGQuery.h -- Query related functions
4 * Copyright (C) 1999 Rodger McNab
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: MGQuery.h 860 2000-01-18 03:53:24Z rjmcnab $
21 *
22 **************************************************************************/
23
24#ifndef MGQUERY_H
25#define MGQUERY_H
26
27#include "IndexData.h"
28#include <limits.h>
29#include "Terms.h"
30
31
32
33// forms base for defining and calculating the boolean
34// part of a query
35class QueryNode {
36public:
37 QueryNode ();
38 virtual ~QueryNode ();
39
40 virtual void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
41 QueryResult &result) const;
42 virtual void Free ();
43 virtual void Print (ostream &s, int indent=0) const;
44};
45
46
47
48void PrintIndent (ostream &s, int indent);
49void PrintIndentText (ostream &s, char *text, int indent);
50void PrintNode (ostream &s, QueryNode *node, int indent=0);
51
52
53
54// basic boolean nodes
55
56class AndQueryNode : public QueryNode {
57public:
58 QueryNode *leftNode;
59 QueryNode *rightNode;
60
61 AndQueryNode ();
62 ~AndQueryNode ();
63
64 void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
65 QueryResult &result) const;
66 void Free ();
67 void Print (ostream &s, int indent=0) const;
68};
69
70class OrQueryNode : public QueryNode {
71public:
72 QueryNode *leftNode;
73 QueryNode *rightNode;
74
75 OrQueryNode ();
76 ~OrQueryNode ();
77
78 void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
79 QueryResult &result) const;
80 void Free ();
81 void Print (ostream &s, int indent=0) const;
82};
83
84class NotQueryNode : public QueryNode {
85public:
86 QueryNode *queryNode;
87 QueryNode *notNode;
88
89 NotQueryNode ();
90 ~NotQueryNode ();
91
92 void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
93 QueryResult &result) const;
94 void Free ();
95 void Print (ostream &s, int indent=0) const;
96};
97
98
99
100class TagNode {
101public:
102 UCArray tagName;
103
104 void Clear ();
105 TagNode () { Clear (); }
106
107 void Calculate (IndexData &indexData, FragRangeArray &fragRange) const;
108 void Free ();
109 void Print (ostream &s, int indent=0) const;
110};
111
112
113#define NO_TERM_RANGE_START (LONG_MIN/2)
114#define NO_TERM_RANGE_END (LONG_MAX/2)
115
116class TermNode {
117public:
118 UCArray term;
119 unsigned long termWeight;
120 unsigned long stemMethod;
121 signed long startRange; // range relative to last term
122 signed long endRange;
123
124 void Clear ();
125 TermNode ();
126
127 // fragLimits can be NULL if not neede
128 void Calculate (IndexData &indexData,
129 bool needFragFreqs,
130 FragRangeArray *fragLimits,
131 FragData &fragData) const;
132 void Free ();
133 void Print (ostream &s, int indent=0) const;
134};
135
136typedef vector<TermNode> TermNodeArray;
137
138
139class ProxMatchQueryNode : public QueryNode {
140public:
141 TagNode *tagNodePtr; // optional field
142 TermNodeArray terms;
143
144 ProxMatchQueryNode ();
145 ~ProxMatchQueryNode ();
146
147 void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
148 QueryResult &result) const;
149 void Free ();
150 void Print (ostream &s, int indent=0) const;
151};
152
153
154void MGQuery (IndexData &indexData,
155 const QueryInfo &queryInfo,
156 const QueryNode *queryTree,
157 QueryResult &result);
158
159
160#endif
Note: See TracBrowser for help on using the repository browser.