mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Adding files needed for block indexing
added: storage/connect/array.cpp storage/connect/array.h storage/connect/blkfil.cpp storage/connect/blkfil.h storage/connect/filter.cpp storage/connect/filter.h
This commit is contained in:
1095
storage/connect/array.cpp
Normal file
1095
storage/connect/array.cpp
Normal file
File diff suppressed because it is too large
Load Diff
122
storage/connect/array.h
Normal file
122
storage/connect/array.h
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/**************** Array H Declares Source Code File (.H) ***************/
|
||||||
|
/* Name: ARRAY.H Version 3.1 */
|
||||||
|
/* */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
|
||||||
|
/* */
|
||||||
|
/* This file contains the ARRAY and VALBASE derived classes declares. */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include required application header files */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "xobject.h"
|
||||||
|
#include "valblk.h"
|
||||||
|
#include "csort.h"
|
||||||
|
|
||||||
|
typedef class ARRAY *PARRAY;
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Definition of class ARRAY with all its method functions. */
|
||||||
|
/* Note: This is not a general array class that could be defined as */
|
||||||
|
/* a template class, but rather a specific object containing a list */
|
||||||
|
/* of values to be processed by the filter IN operator. */
|
||||||
|
/* In addition it must act as a metaclass by being able to give back */
|
||||||
|
/* the type of values it contains. */
|
||||||
|
/* It must also be able to convert itself from some type to another. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
|
||||||
|
friend class MULAR;
|
||||||
|
//friend class VALLST;
|
||||||
|
//friend class SFROW;
|
||||||
|
public:
|
||||||
|
// Constructors
|
||||||
|
ARRAY(PGLOBAL g, int type, int size, int len = 1, int prec = 0);
|
||||||
|
//ARRAY(PGLOBAL g, PQUERY qryp);
|
||||||
|
//ARRAY(PGLOBAL g, PARRAY par, int k);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual int GetType(void) {return TYPE_ARRAY;}
|
||||||
|
virtual int GetResultType(void) {return Type;}
|
||||||
|
virtual int GetLength(void) {return Len;}
|
||||||
|
virtual int GetLengthEx(void) {return Len;}
|
||||||
|
virtual int GetScale() {return 0;}
|
||||||
|
int GetNval(void) {return Nval;}
|
||||||
|
int GetSize(void) {return Size;}
|
||||||
|
// PVAL GetValp(void) {return Valp;}
|
||||||
|
void SetType(int atype) {Type = atype;}
|
||||||
|
void SetCorrel(bool b) {Correlated = b;}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual void Reset(void) {Bot = -1;}
|
||||||
|
virtual int Qcompare(int *, int *);
|
||||||
|
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
|
||||||
|
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;}
|
||||||
|
virtual int CheckSpcCol(PTDB, int) {return 0;}
|
||||||
|
virtual void Print(PGLOBAL g, FILE *f, UINT n);
|
||||||
|
virtual void Print(PGLOBAL g, char *ps, UINT z);
|
||||||
|
void Empty(void);
|
||||||
|
void SetPrecision(PGLOBAL g, int p);
|
||||||
|
bool AddValue(PGLOBAL g, PSZ sp);
|
||||||
|
bool AddValue(PGLOBAL g, SHORT n);
|
||||||
|
bool AddValue(PGLOBAL g, int n);
|
||||||
|
bool AddValue(PGLOBAL g, double f);
|
||||||
|
bool AddValue(PGLOBAL g, PXOB xp);
|
||||||
|
bool AddValue(PGLOBAL g, PVAL vp);
|
||||||
|
void GetNthValue(PVAL valp, int n);
|
||||||
|
char *GetStringValue(int n);
|
||||||
|
BYTE Vcompare(PVAL vp, int n);
|
||||||
|
void Save(int);
|
||||||
|
void Restore(int);
|
||||||
|
void Move(int, int);
|
||||||
|
bool Sort(PGLOBAL g);
|
||||||
|
bool Find(PVAL valp);
|
||||||
|
bool FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm);
|
||||||
|
int Convert(PGLOBAL g, int k, PVAL vp = NULL);
|
||||||
|
int BlockTest(PGLOBAL g, int opc, int opm,
|
||||||
|
void *minp, void *maxp, bool s);
|
||||||
|
PSZ MakeArrayList(PGLOBAL g);
|
||||||
|
bool CanBeShort(void);
|
||||||
|
bool GetSubValue(PGLOBAL g, PVAL valp, int *kp);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Members
|
||||||
|
PMBV Valblk; // To the MBVALS class
|
||||||
|
PVBLK Vblp; // To Valblock of the data array
|
||||||
|
//PVAL Valp; // The value used for Save and Restore is Value
|
||||||
|
int Size; // Size of value array
|
||||||
|
int Nval; // Total number of items in array
|
||||||
|
int Ndif; // Total number of distinct items in array
|
||||||
|
int Xsize; // Size of Index (used for correlated arrays)
|
||||||
|
int Type; // Type of individual values in the array
|
||||||
|
int Len; // Length of character string
|
||||||
|
int Bot; // Bottom of research index
|
||||||
|
int Top; // Top of research index
|
||||||
|
int X, Inf, Sup; // Used for block optimization
|
||||||
|
bool Correlated; // -----------> Temporary
|
||||||
|
}; // end of class ARRAY
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Definition of class MULAR with all its method functions. */
|
||||||
|
/* This class is used when constructing the arrays of constants used */
|
||||||
|
/* for indexing. Its only purpose is to provide a way to sort, reduce */
|
||||||
|
/* and reorder the arrays of multicolumn indexes as one block. Indeed */
|
||||||
|
/* sorting the arrays independantly would break the correspondance of */
|
||||||
|
/* column values. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class MULAR : public CSORT, public BLOCK { // No need to be an XOBJECT
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
MULAR(PGLOBAL g, int n);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
void SetPars(PARRAY par, int i) {Pars[i] = par;}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual int Qcompare(int *i1, int *i2); // Sort compare routine
|
||||||
|
bool Sort(PGLOBAL g);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Members
|
||||||
|
int Narray; // The number of sub-arrays
|
||||||
|
PARRAY *Pars; // To the block of real arrays
|
||||||
|
}; // end of class ARRAY
|
1080
storage/connect/blkfil.cpp
Normal file
1080
storage/connect/blkfil.cpp
Normal file
File diff suppressed because it is too large
Load Diff
295
storage/connect/blkfil.h
Normal file
295
storage/connect/blkfil.h
Normal file
@@ -0,0 +1,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 Print(PGLOBAL g, FILE *f, UINT n);
|
||||||
|
virtual void Print(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
|
||||||
|
ULONG Bmp; // The value bitmap used to test blocks
|
||||||
|
ULONG 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
|
||||||
|
PULONG Bmp; // The values bitmaps used to test blocks
|
||||||
|
PULONG 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
|
||||||
|
PULONG Bmp; // The values bitmaps used to test blocks
|
||||||
|
PULONG 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 Print(PGLOBAL g, FILE *f, UINT n);
|
||||||
|
virtual void Print(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__
|
1733
storage/connect/filter.cpp
Normal file
1733
storage/connect/filter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
172
storage/connect/filter.h
Normal file
172
storage/connect/filter.h
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*************** Filter H Declares Source Code File (.H) ***************/
|
||||||
|
/* Name: FILTER.H Version 1.2 */
|
||||||
|
/* */
|
||||||
|
/* (C) Copyright to the author Olivier BERTRAND 2010-2012 */
|
||||||
|
/* */
|
||||||
|
/* This file contains the FILTER and derived classes declares. */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Include required application header files */
|
||||||
|
/***********************************************************************/
|
||||||
|
#include "xobject.h"
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Utilities for WHERE condition building. */
|
||||||
|
/***********************************************************************/
|
||||||
|
PFIL MakeFilter(PGLOBAL g, PFIL filp, OPVAL vop, PFIL fp);
|
||||||
|
PFIL MakeFilter(PGLOBAL g, PCOL *colp, POPER pop, PPARM pfirst, bool neg);
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Definition of class FILTER with all its method functions. */
|
||||||
|
/* Note: Most virtual implementation functions are not in use yet */
|
||||||
|
/* but could be in future system evolution. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class DllExport FILTER : public XOBJECT { /* Filter description block */
|
||||||
|
//friend PFIL PrepareFilter(PGLOBAL, PFIL, bool);
|
||||||
|
friend DllExport bool ApplyFilter(PGLOBAL, PFIL, PTDB = NULL);
|
||||||
|
public:
|
||||||
|
// Constructors
|
||||||
|
FILTER(PGLOBAL g, POPER pop, PPARM *tp = NULL);
|
||||||
|
FILTER(PGLOBAL g, OPVAL opc, PPARM *tp = NULL);
|
||||||
|
FILTER(PFIL fil1);
|
||||||
|
|
||||||
|
// Implementation
|
||||||
|
virtual int GetType(void) {return TYPE_FILTER;}
|
||||||
|
virtual int GetResultType(void) {return TYPE_INT;}
|
||||||
|
virtual int GetLength(void) {return 1;}
|
||||||
|
virtual int GetLengthEx(void) {assert(FALSE); return 0;}
|
||||||
|
virtual int GetScale() {return 0;};
|
||||||
|
PFIL GetNext(void) {return Next;}
|
||||||
|
OPVAL GetOpc(void) {return Opc;}
|
||||||
|
int GetOpm(void) {return Opm;}
|
||||||
|
int GetArgType(int i) {return Arg(i)->GetType();}
|
||||||
|
bool GetResult(void) {return Value->GetIntValue() != 0;}
|
||||||
|
PXOB &Arg(int i) {return Test[i].Arg;}
|
||||||
|
PVAL &Val(int i) {return Test[i].Value;}
|
||||||
|
bool &Conv(int i) {return Test[i].Conv;}
|
||||||
|
void SetNext(PFIL filp) {Next = filp;}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual void Reset(void);
|
||||||
|
virtual bool Compare(PXOB) {return FALSE;} // Not used yet
|
||||||
|
virtual bool Init(PGLOBAL);
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
virtual bool SetFormat(PGLOBAL, FORMAT&) {return TRUE;} // NUY
|
||||||
|
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
|
||||||
|
virtual int RefNum(PSQL);
|
||||||
|
virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return NULL;} // NUY
|
||||||
|
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
|
||||||
|
virtual bool CheckLocal(PTDB);
|
||||||
|
virtual int CheckSpcCol(PTDB tdbp, int n);
|
||||||
|
virtual void Print(PGLOBAL g, FILE *f, UINT n);
|
||||||
|
virtual void Print(PGLOBAL g, char *ps, UINT z);
|
||||||
|
PFIL Linearize(bool nosep);
|
||||||
|
PFIL Link(PGLOBAL g, PFIL fil2);
|
||||||
|
PFIL RemoveLastSep(void);
|
||||||
|
// PFIL SortJoin(PGLOBAL g);
|
||||||
|
// bool FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq,
|
||||||
|
// bool tek, bool tk2, bool tc2, bool tix, bool thx);
|
||||||
|
// bool CheckHaving(PGLOBAL g, PSQL sqlp);
|
||||||
|
bool Convert(PGLOBAL g, bool having);
|
||||||
|
int SplitFilter(PFIL *fp);
|
||||||
|
int SplitFilter(PFIL *fp, PTDB tp, int n);
|
||||||
|
PFIL LinkFilter(PGLOBAL g, PFIL fp2);
|
||||||
|
// PFIL Copy(PTABS t);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FILTER(void) {} // Standard constructor not to be used
|
||||||
|
void Constr(PGLOBAL g, OPVAL opc, int opm, PPARM *tp);
|
||||||
|
|
||||||
|
// Members
|
||||||
|
PFIL Next; // Used for linearization
|
||||||
|
OPVAL Opc; // Comparison operator
|
||||||
|
int Opm; // Modificator
|
||||||
|
BYTE Bt; // Operator bitmap
|
||||||
|
struct {
|
||||||
|
int B_T; // Buffer type
|
||||||
|
PXOB Arg; // Points to argument
|
||||||
|
PVAL Value; // Points to argument value
|
||||||
|
bool Conv; // TRUE if argument must be converted
|
||||||
|
} Test[2];
|
||||||
|
}; // end of class FILTER
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTERX: used to replace a filter by a derived class */
|
||||||
|
/* using an Eval method optimizing the filtering evaluation. */
|
||||||
|
/* Note: this works only if the members of the derived class are the */
|
||||||
|
/* same than the ones of the original class (NO added members). */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERX : public FILTER {
|
||||||
|
public:
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL) = 0; // just to prevent direct FILTERX use
|
||||||
|
|
||||||
|
// Fake operator new used to change a filter into a derived filter
|
||||||
|
void * operator new(size_t size, PFIL filp) {return filp;}
|
||||||
|
#if !defined(__BORLANDC__)
|
||||||
|
// Avoid warning C4291 by defining a matching dummy delete operator
|
||||||
|
void operator delete(void *, PFIL) {}
|
||||||
|
#endif
|
||||||
|
}; // end of class FILTERX
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTEREQ: OP_EQ, no conversion and Xobject args. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERCMP : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
FILTERCMP(PGLOBAL g);
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTEREQ
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTERAND: OP_AND, no conversion and Xobject args. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERAND : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTERAND
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTEROR: OP_OR, no conversion and Xobject args. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTEROR : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTEROR
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTERNOT: OP_NOT, no conversion and Xobject args. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERNOT : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTERNOT
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTERIN: OP_IN, no conversion and Array 2nd arg. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERIN : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Methods
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTERIN
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Derived class FILTERTRUE: Always returns TRUE. */
|
||||||
|
/***********************************************************************/
|
||||||
|
class FILTERTRUE : public FILTERX {
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
FILTERTRUE(PVAL valp) {Value = valp; Value->SetValue_bool(TRUE);}
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual void Reset(void);
|
||||||
|
virtual bool Eval(PGLOBAL);
|
||||||
|
}; // end of class FILTERTRUE
|
Reference in New Issue
Block a user