/***********************************************************************/ /* Structures used when checking for possible indexing */ /***********************************************************************/ typedefstruct index_col *PICOL; typedefstruct index_val *PIVAL; typedefstruct index_def *PINDX; typedefstruct indx_used *PXUSED;
typedefstruct index_val : public BLOCK {
index_val(PXOB xp) {Next = NULL; Xval = xp; Kp = NULL;}
PIVAL Next; // Next value
PXOB Xval; // To value or array int *Kp; // The coordinates in a LSTBLK
} IVAL;
typedefstruct index_col : public BLOCK {
index_col(PCOL cp)
{Next = Nxtgrp = NULL; Colp = cp; Ngrp = N = 0; Vals = NULL;}
PICOL Next; // Next column
PICOL Nxtgrp; // Next group
PCOL Colp; // The column
PIVAL Vals; // To column values int Ngrp; // Group number of values int N; // Column number of values
} ICOL;
typedefstruct index_off { union { #ifdefined(WORDS_BIGENDIAN) struct {int High; int Low;} v; #else// !WORDS_BIGENDIAN struct {int Low; int High;} v; #endif//!WORDS_BIGENDIAN
longlong Val; // File position
}; // end of union
} IOFF;
/***********************************************************************/ /* Index definition block. */ /***********************************************************************/ class DllExport INDEXDEF : public BLOCK { /* Index description block */ friendclass PLUGCAT; friendclass DOSDEF; friendclass ha_connect; friendint PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add); public: // Constructor
INDEXDEF(char *name, bool uniq = false, int n = 0);
protected:
PIXDEF Next; /* To next block */
PKPDEF ToKeyParts; /* To the key part definitions */ char *Name; /* Index name */ bool Unique; /* true if defined as unique */ bool Invalid; /* true if marked as Invalid */ bool AutoInc; /* true if unique key in auto increment */ bool Dynamic; /* KINDEX style */ bool Mapped; /* Use file mapping */ int Nparts; /* Number of key parts */ int ID; /* Index ID number */ int MaxSame; /* Max number of same values */
}; // end of INDEXDEF
typedefstruct indx_used : public BLOCK {
indx_used(PTDB tp, PIXDEF xdp, PCOL *cp, int k)
{Tname = (char*)tp->GetName(); Xname = xdp->GetName(); Cp = cp; K = k;}
PXUSED Next; char *Tname;
PSZ Xname;
PCOL *Cp; int K;
} XUSED;
/***********************************************************************/ /* Index Key Part definition block. */ /***********************************************************************/ class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */ friendclass INDEXDEF; friendclass XINDEX; friendclass PLUGCAT; friendclass DOSDEF; friendclass ha_connect; friendint PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add); public:
KPARTDEF(PSZ name, int n); // Constructor
protected:
PKPDEF Next; /* To next block */
PSZ Name; /* Field name */ int Mxsame; /* Field max same values */ int Ncol; /* Field number */ int Klen; /* Key length */
}; // end of KPARTDEF
/***********************************************************************/ /* This is the XDB Index virtual base class declaration. */ /***********************************************************************/ class DllExport XXBASE : public CSORT, public BLOCK { friendclass INDEXDEF; friendclass KXYCOL; public: // Constructor
XXBASE(PTDBDOS tbxp, bool b);
protected: // Members
PTDBASE Tbxp; // Points to calling table TDB
PXCOL To_KeyCol; // To KeyCol class list
MBLOCK Record; // Record allocation block int* &To_Rec; // We are using ftell, fseek int Cur_K; // Index of current record int Old_K; // Index of last record int Num_K; // Size of Rec_K pointer array int Ndif; // Number of distinct values int Bot; // Bottom of research index int Top; // Top of research index int Inf, Sup; // Used for block optimization
OPVAL Op; // Search operator bool Mul; // true if multiple bool Srtd; // true for sorted column bool Dynamic; // true when dynamically made int Val_K; // Index of current value int Nblk; // Number of blocks int Sblk; // Block size int Thresh; // Thresh for sorting join indexes int ID; // Index ID number int Nth; // Nth constant to fetch
}; // end of class XXBASE
/***********************************************************************/ /* This is the standard (multicolumn) Index class declaration. */ /***********************************************************************/ class DllExport XINDEX : public XXBASE { friendclass KXYCOL; public: // Constructor
XINDEX(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp,
PCOL *cp, PXOB *xp = NULL, int k = 0);
// Members
PIXDEF Xdp; // To index definition
PTDBDOS Tdbp; // Points to calling table TDB
PXLOAD X; // To XLOAD class
PXCOL To_LastCol; // To the last key part block
PXCOL To_LastVal; // To the last used key part block
PCOL *To_Cols; // To array of indexed columns
PXOB *To_Vals; // To array of column values int Nk; // The number of indexed columns int Nval; // The number of used columns int Incr; // Increment of record position int MaxSame; // Max number of same values
}; // end of class XINDEX
/***********************************************************************/ /* This is the fast single column index class declaration. */ /***********************************************************************/ class DllExport XINDXS : public XINDEX { friendclass KXYCOL; public: // Constructor
XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp = NULL);
// Methods int Qcompare(int *, int *) override; int Fetch(PGLOBAL g) override; int FastFind(void) override; bool NextVal(bool eq) override; bool PrevVal(void) override; int Range(PGLOBAL g, int limit = 0, bool incl = true) override; int GroupSize(void) override;
protected: // Members
}; // end of class XINDXS
/***********************************************************************/ /* This is the saving/loading index utility base class. */ /***********************************************************************/ class DllExport XLOAD : public BLOCK { friendclass XINDEX; friendclass XBIGEX; friendclass XBIGXS; public: // Constructor
XLOAD(void);
// Methods virtualbool Open(PGLOBAL g, char *filename, int id, MODE mode) = 0; virtualbool Seek(PGLOBAL g, int low, int high, int origin) = 0; virtualbool Read(PGLOBAL g, void *buf, int n, int size) = 0; virtualint Write(PGLOBAL g, void *buf, int n, int size, bool& rc) = 0; virtualvoid Close(char *fn, int id) = 0; virtualvoid Close(void); #ifdefined(XMAP) virtualvoid *FileView(PGLOBAL g, char *fn) = 0; #endif// XMAP
protected: // Members #ifdefined(_WIN32)
HANDLE Hfile; // Handle to file or map #else// UNIX int Hfile; // Descriptor to file or map #endif// UNIX
IOFF NewOff; // New offset
}; // end of class XLOAD
/***********************************************************************/ /* This is the saving/loading indexes utility class. */ /***********************************************************************/ class DllExport XFILE : public XLOAD { public: // Constructor
XFILE(void);
// Methods bool Open(PGLOBAL g, char *filename, int id, MODE mode) override; bool Seek(PGLOBAL g, int low, int high, int origin) override; bool Read(PGLOBAL g, void *buf, int n, int size) override; int Write(PGLOBAL g, void *buf, int n, int size, bool& rc) override; void Close(char *fn, int id) override; void Close(void) override; #ifdefined(XMAP) void *FileView(PGLOBAL g, char *fn) override; #endif// XMAP
protected: // Members
FILE *Xfile; // Index stream file #ifdefined(XMAP)
MMP Mmp; // Mapped view base address and length #endif// XMAP
}; // end of class XFILE
/***********************************************************************/ /* This is the saving/loading huge indexes utility class. */ /***********************************************************************/ class DllExport XHUGE : public XLOAD { public: // Constructor
XHUGE(void) : XLOAD() {}
// Methods using XLOAD::Close; bool Open(PGLOBAL g, char *filename, int id, MODE mode) override; bool Seek(PGLOBAL g, int low, int high, int origin) override; bool Read(PGLOBAL g, void *buf, int n, int size) override; int Write(PGLOBAL g, void *buf, int n, int size, bool& rc) override; void Close(char *fn, int id) override; #ifdefined(XMAP) void *FileView(PGLOBAL g, char *fn) override; #endif// XMAP
protected: // Members
}; // end of class XHUGE
/***********************************************************************/ /* This is the XDB index for columns containing ROWID values. */ /***********************************************************************/ class DllExport XXROW : public XXBASE { friendclass KXYCOL; public: // Constructor
XXROW(PTDBDOS tbxp);
// Methods bool Init(PGLOBAL g) override; #ifdefined(XMAP) bool MapInit(PGLOBAL) override {returntrue;} #endif// XMAP int Fetch(PGLOBAL g) override; int FastFind(void) override; int MaxRange(void) override {return1;} int Range(PGLOBAL g, int limit = 0, bool incl = true) override; int Qcompare(int *, int *) override {assert(false); return0;} bool Make(PGLOBAL, PIXDEF) override {returnfalse;} void Close(void) override {}
protected: // Members
PTDBDOS Tdbp; // Points to calling table TDB
PVAL Valp; // The value to match in index
}; // end of class XXROW
/***********************************************************************/ /* Definition of class KXYCOL used to store values of indexed columns */ /***********************************************************************/ class KXYCOL: public BLOCK { friendclass INDEXDEF; friendclass XINDEX; friendclass XINDXS; friendclass XBIGEX; friendclass XBIGXS; friendclass TDBDOS; public: // Constructors
KXYCOL(PKXBASE kp);
// Implementation int GetType(void) {return Type;} void SetValue(PCOL colp, int i);
public: // Methods virtualbool Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln); virtualbool InitFind(PGLOBAL g, PXOB xp); virtualvoid ReAlloc(PGLOBAL g, int n); virtualvoid FreeData(void); virtualvoid FillValue(PVAL valp); virtualint CompVal(int i); // void InitBinFind(void *vp); bool MakeBlockArray(PGLOBAL g, int nb, int size); int Compare(int i1, int i2); int CompBval(int i); void Save(int i) {Valp->SetBinValue(Kblp->GetValPtr(i));} void Restore(int j) {Kblp->SetValue(Valp, j);} void Move(int j, int k) {Kblp->Move(k, j);}
// Specific functions #ifdefined(XMAP)
BYTE *MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m); #endif// XMAP int *MakeOffset(PGLOBAL g, int n);
protected: // Members
PXCOL Next; // To next in the key part list
PXCOL Previous; // To previous in the key part list
PKXBASE Kxp; // To the INDEX class block
PCOL Colp; // To matching object if a column bool IsSorted; // true if column is already sorted bool Asc; // true for ascending sort, false for Desc
MBLOCK Keys; // Data array allocation block void* &To_Keys; // To data array
PVBLK Kblp; // To Valblock of the data array
MBLOCK Bkeys; // Block array allocation block void* &To_Bkeys; // To block array
PVBLK Blkp; // To Valblock of the block array
PVAL Valp; // Value use by Find int Klen; // Length of character string or num value int Kprec; // The Value(s) precision or CI int Type; // The Value(s) type bool Prefix; // Key on CHAR column prefix
MBLOCK Koff; // Offset allocation block
CPINT &Kof; // Reference to offset array int Val_K; // Index of current column value int Ndf; // Number of stored values int Mxs; // Max same for this column
}; // end of class KXYCOL
#endif// __XINDEX_H__
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.