summaryrefslogtreecommitdiff
path: root/src/include/xbindex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/xbindex.h')
-rwxr-xr-xsrc/include/xbindex.h184
1 files changed, 96 insertions, 88 deletions
diff --git a/src/include/xbindex.h b/src/include/xbindex.h
index b42f76e..959562c 100755
--- a/src/include/xbindex.h
+++ b/src/include/xbindex.h
@@ -167,7 +167,6 @@ class XBDLLEXPORT xbIx : public xbFile {
virtual xbBool GetSortOrder( void *vpTag ) const = 0;
virtual xbInt16 Open( const xbString &sFileName );
- virtual xbInt16 Reindex( void **vpTag ) = 0;
virtual xbInt16 SetCurTag( xbInt16 iTagNo ) = 0;
virtual xbInt16 SetCurTag( xbString &sTagName ) = 0;
virtual void SetCurTag( void * vpCurTag );
@@ -176,6 +175,10 @@ class XBDLLEXPORT xbIx : public xbFile {
virtual void TestStub( char *s, void *vpTag ) {};
+
+ virtual xbInt16 Reindex( void **vpTag ) = 0;
+
+
#ifdef XB_DEBUG_SUPPORT
virtual xbInt16 DumpFreeBlocks( xbInt16 iOpt = 0 ) { return XB_NO_ERROR; }
virtual xbInt16 DumpHeader( xbInt16 iDestOpt = 0, xbInt16 iFmtOpt = 0 ) = 0;
@@ -199,17 +202,13 @@ class XBDLLEXPORT xbIx : public xbFile {
virtual xbInt16 CreateKeys( xbInt16 iOpt );
virtual xbInt16 CreateKey( void * vpTag, xbInt16 iOpt ) = 0;
virtual xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo ) = 0;
-// virtual xbInt16 DeleteKeys( xbUInt32 ulRecNo );
virtual xbInt16 DeleteKeys();
virtual xbInt16 DeleteKey( void *vpTag ) = 0;
-
virtual xbInt16 DeleteTag( void *vpTag ) = 0;
-
virtual xbInt16 FindKeyForCurRec( void *vpTag ) = 0;
virtual xbIxNode *FreeNodeChain( xbIxNode *np );
virtual xbInt16 GetBlock( void *vpTag, xbUInt32 ulBlockNo, xbInt16 iOpt, xbUInt32 ulAddlBuf = 0 );
-// virtual xbBool GetIndexUpdated() const = 0;
virtual xbInt32 GetKeyCount( xbIxNode *npNode ) const;
virtual char *GetKeyData( xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iKeyItemLen ) const;
virtual xbInt16 GetKeySts( void *vpTag ) const = 0;
@@ -217,9 +216,9 @@ class XBDLLEXPORT xbIx : public xbFile {
virtual xbInt16 InsertNodeL( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, char * cpKeyBuf, xbUInt32 uiPtr ) = 0;
virtual xbInt16 InsertNodeI( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, xbUInt32 uiPtr ) = 0;
virtual xbInt16 KeyExists( void * ) = 0;
-// virtual xbInt16 KeyUpdated( void *vpTag ) const = 0;
virtual void NodeFree( xbIxNode * ixNode );
virtual xbInt16 ReadHeadBlock( xbInt16 iOpt = 0 ) = 0;
+ // virtual xbInt16 Reindex( void **vpTag ) = 0;
virtual void SetDbf( xbDbf *dbf );
virtual xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr ) = 0;
virtual xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr ) = 0;
@@ -267,7 +266,6 @@ struct XBDLLEXPORT xbNdxTag {
char *cpKeyBuf; // key buffer, for searches and adds
char *cpKeyBuf2; // key buffer, for deletes
xbString sTagName; // tag name - is the file name without the extension
-// xbInt16 iKeyUpdated; // key updated? set in method KeyUpdated, checked in AddKey and DeleteKey routines
xbBool bFoundSts; // key found? used to determine if new key should be added in XB_EMULATE_DBASE mode in AddKey
@@ -307,7 +305,6 @@ class XBDLLEXPORT xbIxNdx : public xbIx {
~xbIxNdx();
xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt );
xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
-// xbInt16 DeleteTag( void *vpTag );
xbInt16 FindKey( void *vpTag, const void *vpKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
xbInt16 GetFirstKey( void *vpTag, xbInt16 iRetrieveSw );
@@ -326,12 +323,9 @@ class XBDLLEXPORT xbIxNdx : public xbIx {
xbInt16 GetTagCount() const;
xbBool GetUnique( void *vpTag = NULL ) const;
xbBool GetSortOrder( void *vpTag ) const;
- xbInt16 Reindex( void **vpTag );
xbInt16 SetCurTag( xbInt16 iTagNo );
xbInt16 SetCurTag( xbString &sTagName );
-
-
#ifdef XB_DEBUG_SUPPORT
xbInt16 DumpTagBlocks( xbInt16 iOpt = 1, void *vpTag = NULL );
xbInt16 DumpHeader( xbInt16 iOpt = 0, xbInt16 iFmt = 0 );
@@ -340,6 +334,9 @@ class XBDLLEXPORT xbIxNdx : public xbIx {
xbInt16 DumpNode( void * vpTag, xbIxNode * pNode, xbInt16 iOption ) const;
#endif
+ xbInt16 Reindex( void **vpTag );
+
+
protected:
friend class xbDbf;
xbInt16 AddKey( void *vpTag, xbUInt32 ulRecNo );
@@ -349,20 +346,16 @@ class XBDLLEXPORT xbIxNdx : public xbIx {
xbInt16 CreateKey( void * vpTag, xbInt16 iOpt );
xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo );
xbInt16 DeleteKey( void *vpTag );
-
xbInt16 DeleteTag( void *vpTag );
-
xbInt16 FindKeyForCurRec( void *vpTag );
-// xbBool GetIndexUpdated() const;
xbInt16 GetKeyTypeN( const void *vpTag ) const;
xbInt16 GetKeySts( void *vpTag ) const;
xbInt16 GetLastKey( xbUInt32 ulNodeNo, void *vpTag, xbInt16 iRetrieveSw = 1 );
xbInt16 InsertNodeI( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, xbUInt32 uiPtr );
xbInt16 InsertNodeL( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, char * cpKeyBuf, xbUInt32 uiPtr );
xbInt16 KeyExists( void *vpTag = NULL );
-// xbBool KeyFiltered( void *vpTag ) const;
-// xbInt16 KeyUpdated( void *vpTag ) const;
xbInt16 ReadHeadBlock(xbInt16 iOpt); // read the header node of the disk NDX file
+// xbInt16 Reindex( void **vpTag );
xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr );
xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
xbInt16 UpdateTagKey( char cAction, void *vpTag, xbUInt32 ulRecNo = 0 );
@@ -377,7 +370,6 @@ class XBDLLEXPORT xbIxNdx : public xbIx {
xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const;
xbInt16 KeySetPosAdd( xbNdxTag *npTag, xbUInt32 ulAddKeyRecNo );
xbInt16 KeySetPosDel( xbNdxTag *npTag );
- // void SetCurNode( void *vpTag, xbIxNode *np );
xbNdxTag *ndxTag;
};
@@ -409,7 +401,6 @@ struct XBDLLEXPORT xbMdxTag {
// one unused byte fits here
char cTag11; // dbase sets to 0x1B
-
xbInt16 iKeyLen;
xbInt16 iKeysPerBlock;
xbInt16 iSecKeyType;
@@ -418,10 +409,8 @@ struct XBDLLEXPORT xbMdxTag {
char cSerialNo; // Increments +1 for each tag update
char cUnique;
xbString *sKeyExp; // Key expression
-
char cHasFilter; // 0x00 or 0x01
char cHasKeys; // 0x00 or 0x01
-
xbUInt32 ulLeftChild; // dbase 7 sets this to the root page on tag creation
xbUInt32 ulRightChild; // dbase 7 sets this to the root page on tag creation
@@ -441,12 +430,6 @@ struct XBDLLEXPORT xbMdxTag {
char *cpKeyBuf; // key buffer
char *cpKeyBuf2; // key buffer
-// xbBool iKeyUpdated; // key updated? set in method CreateKey, checked in AddKey and DeleteKey routines
- // 0 - no update
- // 1 - Add
- // 2 - Update
- // 3 - Delete
-// xbBool bKeyFiltered; // key filtered? True if included key, False if excluded key. Set in method CreateKey, checked in AddKey and DeleteKey routines
xbString *sTagName; // string tag name
@@ -469,59 +452,67 @@ class XBDLLEXPORT xbIxMdx : public xbIx {
public:
xbIxMdx( xbDbf * d );
~xbIxMdx();
- xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt );
- xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
-// xbInt16 DeleteTag( void *vpTag );
- xbInt16 FindKey( void *vpTag, const void *vKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
- xbInt16 FindKey( void *vpTag, xbDouble dKey, xbInt16 iRetrieveSw );
- xbInt16 GetFirstKey( void *vpTag, xbInt16 lRetrieveSw );
- xbString &GetKeyExpression( const void *vpTag ) const;
- xbString &GetKeyFilter( const void *vpTag ) const;
- char GetKeyType( const void *vpTag ) const;
- xbInt16 GetLastKey( void *vpTag, xbInt16 lRetrieveSw );
- xbInt16 GetNextKey( void *vpTag, xbInt16 lRetrieveSw );
- xbInt16 GetPrevKey( void *vpTag, xbInt16 lRetrieveSw );
- xbBool GetReuseEmptyNodesSw() const;
- xbBool GetSortOrder( void *vpTag ) const;
- void *GetTag( xbInt16 iTagNo ) const;
- void *GetTag( xbString &sTagName ) const;
- xbInt16 GetTagCount() const;
+ virtual xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt );
+ virtual xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
+ virtual xbInt16 FindKey( void *vpTag, const void *vKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
+ virtual xbInt16 FindKey( void *vpTag, xbDouble dKey, xbInt16 iRetrieveSw );
+ virtual xbInt16 GetFirstKey( void *vpTag, xbInt16 lRetrieveSw );
+ virtual xbString &GetKeyExpression( const void *vpTag ) const;
+ virtual xbString &GetKeyFilter( const void *vpTag ) const;
+ virtual char GetKeyType( const void *vpTag ) const;
+ virtual xbInt16 GetLastKey( void *vpTag, xbInt16 lRetrieveSw );
+ virtual xbInt16 GetNextKey( void *vpTag, xbInt16 lRetrieveSw );
+ virtual xbInt16 GetPrevKey( void *vpTag, xbInt16 lRetrieveSw );
+ virtual xbBool GetReuseEmptyNodesSw() const;
+ virtual xbBool GetSortOrder( void *vpTag ) const;
+ virtual void *GetTag( xbInt16 iTagNo ) const;
+ virtual void *GetTag( xbString &sTagName ) const;
+ virtual xbInt16 GetTagCount() const;
- xbString &GetTagName( void *vpTag ) const;
- const char * GetTagName( void *vpTag, xbInt16 iOpt ) const;
- void GetTagName( void *vpTag, xbString &sTagName );
+ virtual xbString &GetTagName( void *vpTag ) const;
+ virtual const char * GetTagName( void *vpTag, xbInt16 iOpt ) const;
+ virtual void GetTagName( void *vpTag, xbString &sTagName );
+
+ virtual xbInt16 GetUnique( void *vpTag ) const;
+ virtual xbInt16 SetCurTag( xbInt16 iTagNo );
+ virtual xbInt16 SetCurTag( xbString &sTagName );
+ void SetReuseEmptyNodesSw( xbBool bReuse );
+
+ void TestStub( char *s, void *vpTag );
- xbInt16 GetUnique( void *vpTag ) const;
- xbInt16 Reindex( void **vpTag );
- xbInt16 SetCurTag( xbInt16 iTagNo );
- xbInt16 SetCurTag( xbString &sTagName );
- void SetReuseEmptyNodesSw( xbBool bReuse );
- void TestStub( char *s, void *vpTag );
+ virtual xbInt16 Reindex( void **vpTag );
+
protected:
friend class xbDbf;
xbInt16 AddKey( void *vpTag, xbUInt32 ulRecNo );
xbIxNode *AllocateIxNode( xbMdxTag * mpTag, xbUInt32 ulBufSize, xbUInt32 ulBlock2 );
+ void CalcBtreePointers();
+ char CalcTagKeyFmt( xbExp &exp );
+
xbInt16 CheckForDupKey( void *vpTag );
- xbInt16 Close();
+ virtual xbInt16 Close();
xbInt16 CreateKey( void * vpTag, xbInt16 iOpt );
xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo );
xbInt16 DeleteKey( void *vpTag );
- xbInt16 DeleteTag( void *vpTag );
+ virtual xbInt16 DeleteTag( void *vpTag );
xbInt16 FindKeyForCurRec( void *vpTag );
xbInt16 GetKeySts( void *vpTag ) const;
xbInt16 GetLastKey( xbUInt32 ulBlockNo, void *vpTag, xbInt16 lRetrieveSw );
void *GetTagTblPtr() const;
+
+ xbInt16 HarvestTagNodes( xbMdxTag *mpTag, xbBool bRecycleRoot = xbFalse );
void Init( xbInt16 iOpt = 0 );
xbInt16 InsertNodeI( void *vpTag, xbIxNode *npNode, xbInt16 iSlotNo, xbUInt32 uiPtr );
xbInt16 InsertNodeL( void *vpTag, xbIxNode *npNode, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
xbInt16 KeyExists( void * );
xbInt16 LoadTagTable();
xbInt16 ReadHeadBlock(xbInt16 iOpt); // read the header node of the disk file
+ //virtual xbInt16 Reindex( void **vpTag );
xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr );
xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
xbInt16 UpdateTagKey( char cAction, void *vpTag, xbUInt32 ulRecNo = 0 );
@@ -535,34 +526,10 @@ class XBDLLEXPORT xbIxMdx : public xbIx {
void DumpIxNodeChain( void *vpTag, xbInt16 iOutputOpt ) const;
#endif
- private:
- xbInt16 AddKeyNewRoot( xbMdxTag *npTag, xbIxNode *npLeft, xbIxNode *npRight );
- void AppendNodeChain( void *vpTag, xbIxNode *npNode );
- xbUInt32 BlockToPage( xbUInt32 ulBlockNo );
- void CalcBtreePointers();
- char CalcTagKeyFmt( xbExp &exp );
- char CalcTagFwdThread1();
- char CalcTagFwdThread2();
- xbMdxTag *ClearTagTable();
- xbInt16 DumpBlock( xbInt16 iOpt, xbUInt32 ulBlockNo, xbMdxTag * mpTag );
- xbInt16 GetDbfPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulDbfPtr ) const;
- xbInt16 GetKeyPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulKeyPtr ) const;
- xbInt16 GetLastKeyForBlockNo( void *vpTag, xbUInt32 ulBlockNo, char *cpKeyBuf );
- xbInt16 HarvestEmptyNode( xbMdxTag *mpTag, xbIxNode *npNode, xbInt16 iOpt, xbBool bHarvestRoot = xbFalse );
- xbInt16 HarvestTagNodes( xbMdxTag *mpTag, xbBool bRecycleRoot = xbFalse );
- xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const;
- xbInt16 KeySetPosAdd( xbMdxTag *mpTag, xbUInt32 ulAddKeyRecNo );
- xbInt16 KeySetPosDel( xbMdxTag *mpTag );
- xbInt16 LoadTagDetail( xbInt16 iOption, xbMdxTag *tte );
- xbUInt32 PageToBlock( xbUInt32 ulPageNo );
- xbInt16 TagSerialNo( xbInt16 iOption, xbMdxTag *mpTag );
- xbInt16 UpdateTagSize( xbMdxTag *mpTag, xbUInt32 ulTagSz );
- #ifdef XB_DEBUG_SUPPORT
- xbInt16 PrintKey( void *vpTag, xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iDepth, char cType, xbInt16 iOutputOpt );
- #endif
+ xbMdxTag *mdxTagTbl;
- // MDX File Header Fields
+// MDX File Header Fields
char cVersion;
char cCreateYY;
char cCreateMM;
@@ -588,18 +555,59 @@ class XBDLLEXPORT xbIxMdx : public xbIx {
// end of MDX Header fields
-
- xbMdxTag *mdxTagTbl;
-
xbBool bReuseEmptyNodes; // Reuese empty MDX nodes when all keys deleted?
// DBase 7.x and MS ODBC drivers do not reuse empty nodes, leaves them stranded in the file
// Codebase 6.x reuses empty nodes.
// Setting this to True will reuse empty nodes in the same manner Codebase 6.x reuses them.
+
+ private:
+ xbInt16 AddKeyNewRoot( xbMdxTag *npTag, xbIxNode *npLeft, xbIxNode *npRight );
+ void AppendNodeChain( void *vpTag, xbIxNode *npNode );
+ xbUInt32 BlockToPage( xbUInt32 ulBlockNo );
+ xbMdxTag *ClearTagTable();
+ xbInt16 DumpBlock( xbInt16 iOpt, xbUInt32 ulBlockNo, xbMdxTag * mpTag );
+ xbInt16 GetDbfPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulDbfPtr ) const;
+ xbInt16 GetKeyPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulKeyPtr ) const;
+ xbInt16 GetLastKeyForBlockNo( void *vpTag, xbUInt32 ulBlockNo, char *cpKeyBuf );
+ xbInt16 HarvestEmptyNode( xbMdxTag *mpTag, xbIxNode *npNode, xbInt16 iOpt, xbBool bHarvestRoot = xbFalse );
+ xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const;
+ xbInt16 KeySetPosAdd( xbMdxTag *mpTag, xbUInt32 ulAddKeyRecNo );
+ xbInt16 KeySetPosDel( xbMdxTag *mpTag );
+ xbInt16 LoadTagDetail( xbInt16 iOption, xbMdxTag *tte );
+ xbUInt32 PageToBlock( xbUInt32 ulPageNo );
+ xbInt16 TagSerialNo( xbInt16 iOption, xbMdxTag *mpTag );
+ xbInt16 UpdateTagSize( xbMdxTag *mpTag, xbUInt32 ulTagSz );
+
+ #ifdef XB_DEBUG_SUPPORT
+ xbInt16 PrintKey( void *vpTag, xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iDepth, char cType, xbInt16 iOutputOpt );
+ #endif
+
+
+ };
+ #endif /* XB_MDX_SUPPORT */
+
+
+#ifdef XB_TDX_SUPPORT
+
+class XBDLLEXPORT xbIxTdx : public xbIxMdx {
+ public:
+ xbIxTdx( xbDbf * d );
+ ~xbIxTdx();
+
+ xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
+
+ protected:
+ friend class xbDbf;
+ xbInt16 Close();
+ xbInt16 DeleteTag( void *vpTag );
+
+ private:
};
-#endif /* XB_MDX_SUPPORT */
-
-} /* namespace xb */
-#endif /* XB_INDEX_SUPPORT */
-#endif /* __XB_INDEX_H__ */
+#endif /* XB_TDX_SUPPORT */
+
+
+ } /* namespace xb */
+ #endif /* XB_INDEX_SUPPORT */
+#endif /* __XB_INDEX_H__ */