summaryrefslogtreecommitdiffstats
path: root/storage/connect/blkfil.h
blob: 61b02c53c14bdc672d6f686d867feb04c9c44f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*************** BlkFil H Declares Source Code File (.H) ***************/
/*  Name: BLKFIL.H    Version 2.1                                      */
/*                                                                     */
/*  (C) Copyright to the author Olivier BERTRAND          2004-2010    */
/*                                                                     */
/*  This file contains the block optimization related classes declares */
/***********************************************************************/
#ifndef __BLKFIL__
#define __BLKFIL__

typedef class BLOCKFILTER *PBF;
typedef class BLOCKINDEX  *PBX;

/***********************************************************************/
/*  Definition of class BLOCKFILTER.                                   */
/***********************************************************************/
class DllExport BLOCKFILTER : public BLOCK {           /* Block Filter */
  friend class BLKFILLOG;
 public:
  // Constructors
  BLOCKFILTER(PTDBDOS tdbp, int op);

  // Implementation
          int  GetResult(void) {return Result;}
          bool Correlated(void) {return Correl;}

  // Methods
  virtual void Reset(PGLOBAL) = 0;
  virtual int  BlockEval(PGLOBAL) = 0;
  virtual void Printf(PGLOBAL g, FILE *f, uint n);
  virtual void Prints(PGLOBAL g, char *ps, uint z);

 protected:
  BLOCKFILTER(void) {}       // Standard constructor not to be used

  // Members
  PTDBDOS Tdbp;         // Owner TDB
  bool    Correl;       // TRUE for correlated subqueries
  int     Opc;          // Comparison operator
  int     Opm;          // Operator modificator
  int     Result;       // Result from evaluation
  }; // end of class BLOCKFILTER

/***********************************************************************/
/*  Definition of class BLKFILLOG (with Op=OP_AND,OP_OR, or OP_NOT)    */
/***********************************************************************/
class DllExport BLKFILLOG : public BLOCKFILTER { /* Logical Op Block Filter */
 public:
  // Constructors
  BLKFILLOG(PTDBDOS tdbp, int op, PBF *bfp, int n);

  // Methods
  virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);

 protected:
  BLKFILLOG(void) {}       // Standard constructor not to be used

  // Members
  PBF *Fil;                // Points to Block filter args
  int N;
  }; // end of class BLKFILLOG

/***********************************************************************/
/*  Definition of class BLKFILARI (with Op=OP_EQ,NE,GT,GE,LT, or LE)   */
/***********************************************************************/
class DllExport BLKFILARI : public BLOCKFILTER { /* Arithm. Op Block Filter */
 public:
  // Constructors
  BLKFILARI(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);

  // Methods
  virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);
  virtual void MakeValueBitmap(void) {}

 protected:
  BLKFILARI(void) {}       // Standard constructor not to be used

  // Members
  PDOSCOL Colp;            // Points to column argument
  PCOL    Cpx;             // Point to subquery "constant" column
  PVAL    Valp;            // Points to constant argument Value
  bool    Sorted;          // True if the column is sorted
  }; // end of class BLKFILARI

/***********************************************************************/
/*  Definition of class BLKFILAR2 (with Op=OP_EQ,NE,GT,GE,LT, or LE)   */
/***********************************************************************/
class DllExport BLKFILAR2 : public BLKFILARI { /* Arithm. Op Block Filter */
 public:
  // Constructors
  BLKFILAR2(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);

  // Methods
  virtual int  BlockEval(PGLOBAL g);
  virtual void MakeValueBitmap(void);

 protected:
  BLKFILAR2(void) {}       // Standard constructor not to be used

  // Members
  uint Bmp;                // The value bitmap used to test blocks
  uint Bxp;                // Bitmap used when Opc = OP_EQ
  }; // end of class BLKFILAR2

/***********************************************************************/
/*  Definition of class BLKFILAR2 (with Op=OP_EQ,NE,GT,GE,LT, or LE)   */
/*  To be used when the bitmap is an array of ULONG bitmaps;           */
/***********************************************************************/
class DllExport BLKFILMR2 : public BLKFILARI { /* Arithm. Op Block Filter */
 public:
  // Constructors
  BLKFILMR2(PGLOBAL g, PTDBDOS tdbp, int op, PXOB *xp);

  // Methods
  virtual int  BlockEval(PGLOBAL g);
  virtual void MakeValueBitmap(void);

 protected:
  BLKFILMR2(void) {}       // Standard constructor not to be used

  // Members
  int    Nbm;              // The number of ULONG bitmaps
  int    N;                // The position of the leftmost ULONG
  bool   Void;             // True if all file blocks can be skipped
  uint  *Bmp;              // The values bitmaps used to test blocks
  uint  *Bxp;              // Bit of values <= max value
  }; // end of class BLKFILMR2

/***********************************************************************/
/*  Definition of class BLKSPCARI (with Op=OP_EQ,NE,GT,GE,LT, or LE)   */
/***********************************************************************/
class DllExport BLKSPCARI : public BLOCKFILTER { /* Arithm. Op Block Filter */
 public:
  // Constructors
  BLKSPCARI(PTDBDOS tdbp, int op, PXOB *xp, int bsize);

  // Methods
  virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);

 protected:
  BLKSPCARI(void) {}       // Standard constructor not to be used

  // Members
  PCOL    Cpx;             // Point to subquery "constant" column
  PVAL    Valp;            // Points to constant argument Value
  int     Val;             // Constant argument Value
  int     Bsize;           // Table block size
  }; // end of class BLKSPCARI

/***********************************************************************/
/*  Definition of class BLKFILIN (with Op=OP_IN)                       */
/***********************************************************************/
class DllExport BLKFILIN : public BLOCKFILTER {  // With array arguments.
 public:
  // Constructors
  BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp);

  // Methods
  virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);
  virtual void MakeValueBitmap(void) {}

 protected:
  // Member
  PDOSCOL Colp;            // Points to column argument
  PARRAY  Arap;            // Points to array argument
  bool    Sorted;          // True if the column is sorted
  int     Type;            // Type of array elements
  }; // end of class BLKFILIN

/***********************************************************************/
/*  Definition of class BLKFILIN2 (with Op=OP_IN)                      */
/***********************************************************************/
class DllExport BLKFILIN2 : public BLKFILIN {  // With array arguments.
 public:
  // Constructors
  BLKFILIN2(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp);

  // Methods
//virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);
  virtual void MakeValueBitmap(void);

 protected:
  // Member
  int    Nbm;              // The number of ULONG bitmaps
  int    N;                // The position of the leftmost ULONG
//bool   Bitmap;           // True for IN operator (temporary)
  bool   Void;             // True if all file blocks can be skipped
  bool   Invert;           // True when Result must be inverted
  uint  *Bmp;              // The values bitmaps used to test blocks
  uint  *Bxp;              // Bit of values <= max value
  PVAL   Valp;             // Used while building the bitmaps
  }; // end of class BLKFILIN2

/***********************************************************************/
/*  Definition of class BLKSPCIN (with Op=OP_IN) Special column        */
/***********************************************************************/
class DllExport BLKSPCIN : public BLOCKFILTER {  // With array arguments.
 public:
  // Constructors
  BLKSPCIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp, int bsize);

  // Methods
  virtual void Reset(PGLOBAL g);
  virtual int  BlockEval(PGLOBAL g);

 protected:
  // Member
  PARRAY  Arap;            // Points to array argument
  int     Bsize;           // Table block size
  }; // end of class BLKSPCIN

// ---------------- Class used in block indexing testing ----------------

#if 0
/***********************************************************************/
/*  Definition of class BLOCKINDEX.                                    */
/*  Used to test the indexing to joined tables when the foreign key is */
/*  a clustered or sorted column. If the table is joined to several    */
/*  tables, blocks will be chained together.                           */
/***********************************************************************/
class DllExport BLOCKINDEX : public BLOCK {     /* Indexing Test Block */
 public:
  // Constructors
  BLOCKINDEX(PBX nx, PDOSCOL cp, PKXBASE kp);

  // Implementation
          PBX  GetNext(void) {return Next;}

  // Methods
          void Reset(void);
  virtual int  BlockEval(PGLOBAL);
  virtual void Printf(PGLOBAL g, FILE *f, UINT n);
  virtual void Prints(PGLOBAL g, char *ps, UINT z);

 protected:
  BLOCKINDEX(void) {}   // Standard constructor not to be used

  // Members
  PBX     Next;         // To next Index Block
  PTDBDOS Tdbp;         // To table description block
  PDOSCOL Colp;         // Clustered foreign key
  PKXBASE Kxp;          // To Kindex of joined table
  bool    Sorted;       // TRUE if column is sorted
  int     Type;         // Col/Index type
  int     Result;       // Result from evaluation
  }; // end of class BLOCKINDEX

/***********************************************************************/
/*  Definition of class BLOCKINDX2.     (XDB2)                         */
/***********************************************************************/
class DllExport BLOCKINDX2 : public BLOCKINDEX { /* Indexing Test Block */
 public:
  // Constructors
  BLOCKINDX2(PBX nx, PDOSCOL cp, PKXBASE kp);

  // Methods
  virtual int  BlockEval(PGLOBAL);

 protected:
  BLOCKINDX2(void) {}   // Standard constructor not to be used

  // Members
  int   Nbm;            // The number of ULONG bitmaps
  PVBLK Dval;           // Array of column distinct values
  PVBLK Bmap;           // Array of block bitmap values
  }; // end of class BLOCKINDX2

/***********************************************************************/
/*  Definition of class BLKSPCINDX.                                    */
/*  Used to test the indexing to joined tables when the foreign key is */
/*  the ROWID special column. If the table is joined to several        */
/*  tables, blocks will be chained together.                           */
/***********************************************************************/
class DllExport BLKSPCINDX : public BLOCKINDEX { /* Indexing Test Block */
 public:
  // Constructors
  BLKSPCINDX(PBX nx, PTDBDOS tp, PKXBASE kp, int bsize);

  // Methods
  virtual int  BlockEval(PGLOBAL);

 protected:
  BLKSPCINDX(void) {}   // Standard constructor not to be used

  // Members
  int     Bsize;        // Table block size
  }; // end of class BLOCKINDEX
#endif // 0

#endif // __BLKFIL__