1/*************** BlkFil H Declares Source Code File (.H) ***************/
2/* Name: BLKFIL.H Version 2.1 */
3/* */
4/* (C) Copyright to the author Olivier BERTRAND 2004-2010 */
5/* */
6/* This file contains the block optimization related classes declares */
7/***********************************************************************/
8#ifndef __BLKFIL__
9#define __BLKFIL__
10
11typedef class BLOCKFILTER *PBF;
12typedef class BLOCKINDEX *PBX;
13
14/***********************************************************************/
15/* Definition of class BLOCKFILTER. */
16/***********************************************************************/
17class DllExport BLOCKFILTER : public BLOCK { /* Block Filter */
18 friend class BLKFILLOG;
19 public:
20 // Constructors
21 BLOCKFILTER(PTDBDOS tdbp, int op);
22
23 // Implementation
24 int GetResult(void) {return Result;}
25 bool Correlated(void) {return Correl;}
26
27 // Methods
28 virtual void Reset(PGLOBAL) = 0;
29 virtual int BlockEval(PGLOBAL) = 0;
30 virtual void Printf(PGLOBAL g, FILE *f, uint n);
31 virtual void Prints(PGLOBAL g, char *ps, uint z);
32
33 protected:
34 BLOCKFILTER(void) {} // Standard constructor not to be used
35
36 // Members
37 PTDBDOS Tdbp; // Owner TDB
38 bool Correl; // TRUE for correlated subqueries
39 int Opc; // Comparison operator
40 int Opm; // Operator modificator
41 int Result; // Result from evaluation
42 }; // end of class BLOCKFILTER
43
44/***********************************************************************/
45/* Definition of class BLKFILLOG (with Op=OP_AND,OP_OR, or OP_NOT) */
46/***********************************************************************/
47class DllExport BLKFILLOG : public BLOCKFILTER { /* Logical Op Block Filter */
48 public:
49 // Constructors
50 BLKFILLOG(PTDBDOS tdbp, int op, PBF *bfp, int n);
51
52 // Methods
53 virtual void Reset(PGLOBAL g);
54 virtual int BlockEval(PGLOBAL g);
55
56 protected:
57 BLKFILLOG(void) {} // Standard constructor not to be used
58
59 // Members
60 PBF *Fil; // Points to Block filter args
61 int N;
62 }; // end of class BLKFILLOG
63
64/***********************************************************************/
65/* Definition of class BLKFILARI (with Op=OP_EQ,NE,GT,GE,LT, or LE) */
66/***********************************************************************/
67class DllExport BLKFILARI : public BLOCKFILTER { /* Arithm. Op Block Filter */
68 public:
69 // Constructors
70 BLKFILARI(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);
71
72 // Methods
73 virtual void Reset(PGLOBAL g);
74 virtual int BlockEval(PGLOBAL g);
75 virtual void MakeValueBitmap(void) {}
76
77 protected:
78 BLKFILARI(void) {} // Standard constructor not to be used
79
80 // Members
81 PDOSCOL Colp; // Points to column argument
82 PCOL Cpx; // Point to subquery "constant" column
83 PVAL Valp; // Points to constant argument Value
84 bool Sorted; // True if the column is sorted
85 }; // end of class BLKFILARI
86
87/***********************************************************************/
88/* Definition of class BLKFILAR2 (with Op=OP_EQ,NE,GT,GE,LT, or LE) */
89/***********************************************************************/
90class DllExport BLKFILAR2 : public BLKFILARI { /* Arithm. Op Block Filter */
91 public:
92 // Constructors
93 BLKFILAR2(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);
94
95 // Methods
96 virtual int BlockEval(PGLOBAL g);
97 virtual void MakeValueBitmap(void);
98
99 protected:
100 BLKFILAR2(void) {} // Standard constructor not to be used
101
102 // Members
103 uint Bmp; // The value bitmap used to test blocks
104 uint Bxp; // Bitmap used when Opc = OP_EQ
105 }; // end of class BLKFILAR2
106
107/***********************************************************************/
108/* Definition of class BLKFILAR2 (with Op=OP_EQ,NE,GT,GE,LT, or LE) */
109/* To be used when the bitmap is an array of ULONG bitmaps; */
110/***********************************************************************/
111class DllExport BLKFILMR2 : public BLKFILARI { /* Arithm. Op Block Filter */
112 public:
113 // Constructors
114 BLKFILMR2(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);
115
116 // Methods
117 virtual int BlockEval(PGLOBAL g);
118 virtual void MakeValueBitmap(void);
119
120 protected:
121 BLKFILMR2(void) {} // Standard constructor not to be used
122
123 // Members
124 int Nbm; // The number of ULONG bitmaps
125 int N; // The position of the leftmost ULONG
126 bool Void; // True if all file blocks can be skipped
127 uint *Bmp; // The values bitmaps used to test blocks
128 uint *Bxp; // Bit of values <= max value
129 }; // end of class BLKFILMR2
130
131/***********************************************************************/
132/* Definition of class BLKSPCARI (with Op=OP_EQ,NE,GT,GE,LT, or LE) */
133/***********************************************************************/
134class DllExport BLKSPCARI : public BLOCKFILTER { /* Arithm. Op Block Filter */
135 public:
136 // Constructors
137 BLKSPCARI(PTDBDOS tdbp, int op, PXOB *xp, int bsize);
138
139 // Methods
140 virtual void Reset(PGLOBAL g);
141 virtual int BlockEval(PGLOBAL g);
142
143 protected:
144 BLKSPCARI(void) {} // Standard constructor not to be used
145
146 // Members
147 PCOL Cpx; // Point to subquery "constant" column
148 PVAL Valp; // Points to constant argument Value
149 int Val; // Constant argument Value
150 int Bsize; // Table block size
151 }; // end of class BLKSPCARI
152
153/***********************************************************************/
154/* Definition of class BLKFILIN (with Op=OP_IN) */
155/***********************************************************************/
156class DllExport BLKFILIN : public BLOCKFILTER { // With array arguments.
157 public:
158 // Constructors
159 BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp);
160
161 // Methods
162 virtual void Reset(PGLOBAL g);
163 virtual int BlockEval(PGLOBAL g);
164 virtual void MakeValueBitmap(void) {}
165
166 protected:
167 // Member
168 PDOSCOL Colp; // Points to column argument
169 PARRAY Arap; // Points to array argument
170 bool Sorted; // True if the column is sorted
171 int Type; // Type of array elements
172 }; // end of class BLKFILIN
173
174/***********************************************************************/
175/* Definition of class BLKFILIN2 (with Op=OP_IN) */
176/***********************************************************************/
177class DllExport BLKFILIN2 : public BLKFILIN { // With array arguments.
178 public:
179 // Constructors
180 BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp);
181
182 // Methods
183//virtual void Reset(PGLOBAL g);
184 virtual int BlockEval(PGLOBAL g);
185 virtual void MakeValueBitmap(void);
186
187 protected:
188 // Member
189 int Nbm; // The number of ULONG bitmaps
190 int N; // The position of the leftmost ULONG
191//bool Bitmap; // True for IN operator (temporary)
192 bool Void; // True if all file blocks can be skipped
193 bool Invert; // True when Result must be inverted
194 uint *Bmp; // The values bitmaps used to test blocks
195 uint *Bxp; // Bit of values <= max value
196 PVAL Valp; // Used while building the bitmaps
197 }; // end of class BLKFILIN2
198
199/***********************************************************************/
200/* Definition of class BLKSPCIN (with Op=OP_IN) Special column */
201/***********************************************************************/
202class DllExport BLKSPCIN : public BLOCKFILTER { // With array arguments.
203 public:
204 // Constructors
205 BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp, int bsize);
206
207 // Methods
208 virtual void Reset(PGLOBAL g);
209 virtual int BlockEval(PGLOBAL g);
210
211 protected:
212 // Member
213 PARRAY Arap; // Points to array argument
214 int Bsize; // Table block size
215 }; // end of class BLKSPCIN
216
217// ---------------- Class used in block indexing testing ----------------
218
219#if 0
220/***********************************************************************/
221/* Definition of class BLOCKINDEX. */
222/* Used to test the indexing to joined tables when the foreign key is */
223/* a clustered or sorted column. If the table is joined to several */
224/* tables, blocks will be chained together. */
225/***********************************************************************/
226class DllExport BLOCKINDEX : public BLOCK { /* Indexing Test Block */
227 public:
228 // Constructors
229 BLOCKINDEX(PBX nx, PDOSCOL cp, PKXBASE kp);
230
231 // Implementation
232 PBX GetNext(void) {return Next;}
233
234 // Methods
235 void Reset(void);
236 virtual int BlockEval(PGLOBAL);
237 virtual void Printf(PGLOBAL g, FILE *f, UINT n);
238 virtual void Prints(PGLOBAL g, char *ps, UINT z);
239
240 protected:
241 BLOCKINDEX(void) {} // Standard constructor not to be used
242
243 // Members
244 PBX Next; // To next Index Block
245 PTDBDOS Tdbp; // To table description block
246 PDOSCOL Colp; // Clustered foreign key
247 PKXBASE Kxp; // To Kindex of joined table
248 bool Sorted; // TRUE if column is sorted
249 int Type; // Col/Index type
250 int Result; // Result from evaluation
251 }; // end of class BLOCKINDEX
252
253/***********************************************************************/
254/* Definition of class BLOCKINDX2. (XDB2) */
255/***********************************************************************/
256class DllExport BLOCKINDX2 : public BLOCKINDEX { /* Indexing Test Block */
257 public:
258 // Constructors
259 BLOCKINDX2(PBX nx, PDOSCOL cp, PKXBASE kp);
260
261 // Methods
262 virtual int BlockEval(PGLOBAL);
263
264 protected:
265 BLOCKINDX2(void) {} // Standard constructor not to be used
266
267 // Members
268 int Nbm; // The number of ULONG bitmaps
269 PVBLK Dval; // Array of column distinct values
270 PVBLK Bmap; // Array of block bitmap values
271 }; // end of class BLOCKINDX2
272
273/***********************************************************************/
274/* Definition of class BLKSPCINDX. */
275/* Used to test the indexing to joined tables when the foreign key is */
276/* the ROWID special column. If the table is joined to several */
277/* tables, blocks will be chained together. */
278/***********************************************************************/
279class DllExport BLKSPCINDX : public BLOCKINDEX { /* Indexing Test Block */
280 public:
281 // Constructors
282 BLKSPCINDX(PBX nx, PTDBDOS tp, PKXBASE kp, int bsize);
283
284 // Methods
285 virtual int BlockEval(PGLOBAL);
286
287 protected:
288 BLKSPCINDX(void) {} // Standard constructor not to be used
289
290 // Members
291 int Bsize; // Table block size
292 }; // end of class BLOCKINDEX
293#endif // 0
294
295#endif // __BLKFIL__
296