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

Last change on this file since 927 was 927, checked in by kjm18, 24 years ago

added feature to retrieve doc nums at a different level than the level
queried at. eg query at Document level, but retrieve section level docnums
bug in mg_perf_hash_build.cpp fixed

  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 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 927 2000-02-15 22:45:22Z kjm18 $
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
116/* NOTE: range stuff - the range values are for the previous term relative
117to the current term. So if searching for the phrase "the cat", 'the' doesn't
118need range limits, but 'cat' has a range of -2 to -1. ie, if have found 'cat'
119then 'the' has to be at position between -2 and -1 relative to 'cat'.
120"the cat" could also be searched for by 'cat' with no range limits, then 'the' with range 0 to 1.
121 */
122class TermNode {
123public:
124 UCArray term;
125 unsigned long termWeight;
126 unsigned long stemMethod;
127 signed long startRange; // range relative to last term
128 signed long endRange;
129
130 void Clear ();
131 TermNode ();
132
133 // fragLimits can be NULL if not neede
134 void Calculate (IndexData &indexData,
135 bool needFragFreqs,
136 FragRangeArray *fragLimits,
137 FragData &fragData) const;
138 void Free ();
139 void Print (ostream &s, int indent=0) const;
140};
141
142typedef vector<TermNode> TermNodeArray;
143
144
145class ProxMatchQueryNode : public QueryNode {
146public:
147 TagNode *tagNodePtr; // optional field
148 TermNodeArray terms;
149
150 ProxMatchQueryNode ();
151 ~ProxMatchQueryNode ();
152
153 void Calculate (IndexData &indexData, const QueryInfo &queryInfo,
154 QueryResult &result) const;
155 void Free ();
156 void Print (ostream &s, int indent=0) const;
157};
158
159
160void MGQuery (IndexData &indexData,
161 const QueryInfo &queryInfo,
162 const QueryNode *queryTree,
163 QueryResult &result);
164
165// this function for retriving results with both section doc nums
166// and Document docnums
167void MGQuery (IndexData &indexData,
168 const QueryInfo &queryInfo,
169 const QueryNode *queryTree,
170 ExtQueryResult &result, UCArray &level);
171
172
173#endif
Note: See TracBrowser for help on using the repository browser.