diff options
Diffstat (limited to 'docs/html/xbc9.html')
-rwxr-xr-x | docs/html/xbc9.html | 393 |
1 files changed, 234 insertions, 159 deletions
diff --git a/docs/html/xbc9.html b/docs/html/xbc9.html index afcd2fa..1d39a96 100755 --- a/docs/html/xbc9.html +++ b/docs/html/xbc9.html @@ -2,179 +2,254 @@ <HTML> <TITLE>Xbase DBMS Chapter 9</TITLE> <BODY BGCOLOR=#FFFFFF> -<H2><p align="center">NTX Indices</p></H2> -<p align="center">Chapter Updated 11/28/22</p><hr> +<H2><p align="center">Class xbXBase</p></H2> +<p align="center">Chapter Updated 04/28/23</p><hr> +<h3>Class xbXBase - Core Level Class</h3> -<h3>This chapter might be out of date. The NTX module is pending review and updates for release 4.x.x</h3> -The objective of this chapter is to provide information regarding the -basic concepts of how .NTX index files work in the Xbase environment.<br><br> +The xbXBase class is the core class that needs to be in every application program. +Established an instance of class xbXBase before any other Xbase calls are made. -The information in this chapter has been gathered by searching the internet -and by examining the structure of known good NTX indexes.<br><br> +<i>xbXBase x</i> -<h4>NTX Index File Characteristics</h4> - -<ul><li>NTX indices maintain keys in ascending sort order only.<br><br> -<li>NTX indices support <em>unique</em> or <em>non unique</em> keys.<br><br> - -<em>Unique</em> keys must be unique. The database update routines will -fail if an attempt to add a non-unique key is performed.<br><br> - -<em>Non-unique</em> Keys are not required to be unique, duplicate -keys are allowed if the index is created with the XB_NOT_UNIQUE -setting. Duplicate keys are stored in record number order.<br><br> - -<li>NTX indexes are automatically updated by the Xbase library after the -indices are opened.<br><br> - -<li>Character keys are left justified and padded on the right with spaces.<br><br> - -<li>Numeric keys are stored as eight byte double values.<br><br> - -The numeric key processing logic performs floating point numeric -calculations on eight byte double values. This logic may be compute intensive -and slow on older machines, especially the older intel processors without a -math coprocessor chip. - -</ul> - - -<h4>NTX File Internals</h4> - -NTX files are comprised of two or more 1024 byte blocks or nodes of -information. There are three types of nodes: Head Nodes, Interior -Nodes and Leaf Nodes.<br><br> - -The <em>Head Node</em> is the first node in the file starting at -position zero (0) and contains information about the NTX file. There -is only one Head Node in each index and it always starts at the -beginning of the file.<br><br> - - -<TABLE BORDER> -<CAPTION ALIGN="TOP"><h3>NTX Header Node</H3></CAPTION> -<TR VALIGN="BASELINE"> -<TR><TH ALIGN="LEFT">Type<TD>Size<TD>Field Name<TD>Description -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Signature Byte<TD>The Clipper signature byte. 0x003h indicates Clipper 87. 0x006h indicates Clipper 5.x -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Indexing Version Number<TD>Documented as the "Compiler Version" but I have observed an increasing number. Incremented whenever the index is changed. -<TR><TH ALIGN="LEFT">xbLong<TD>4<TD>First Node Offset<TD>The offset to the first node. -<TR><TH ALIGN="LEFT">xbLong<TD>4<TD>First Unused Page Offset<TD>The offset to the first unused node. -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Key Size + 8<TD>The Key Size plus 8 bytes. -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Key Size<TD>The size (length) of the key. -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Number of Decimals<TD>Number of decimal places in key. -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>Max Items Per Node<TD>The maximum number of key per node. -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>1/2 The Max Items Per Node<TD>Half the maximum number of key per node. Important in a B-tree system, as this is the minimum number of keys that must be on a page. -<TR><TH ALIGN="LEFT">char<TD>256<TD>KeyExpression<TD>Key expression string -<TR><TH ALIGN="LEFT">char<TD>1<TD>Unique<TD>Unique indicator<br> - 00 - Not Unique - XB_NON_UNIQUE<br> - 01 - Unique - XB_UNIQUE -<TR><TH ALIGN="LEFT">char<TD>745<TD>Unused<TD>Unused - - -<TR><TH ALIGN="LEFT"><TD>1024<TD><TD>Total bytes in node -</TABLE> <br><br> -The following structure is used by the Xbase NTX routines: -<xmp> +xbXBase is derived from base classes xbTblMgr and xbSsv. +<br><br><br><br> + +<center> +<table border=1> +<tr><th width=40%>Method</th><th>Description</th><th>Category</th></tr> + + +<tr><td>xbInt16 CloseAllTables()</td><td>Close all open tables.</td><td>Table</tr> + +<tr><td>xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf &dbf, int dummy )</td><td>Open highest version available for sTableName.</td><td>Table</tr> +<tr><td>xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf **dbf )</td><td>Open highest version available for sTableName.</td><td>Table</tr> +<tr><td>xbDbf * Open( const xbString &sTableName, xbInt16 &iRc )</td><td>Open the highest available version of the dbf file. Defaults to XB_READ_WRITE and XB_MULTI_USER mode.</td><td>Table</tr> +<tr><td>xbDbf * Open( const xbString &sTableName, const xbString &sAlias, xbInt16 iOpenMode, xbInt16 iShareMode, xbInt16 iVersion, xbInt16 &iRc )</td><td>Open table.</td><td>Table</tr> + +<tr><td colspan=3><hr></td></tr> +<tr><td>void DisableMsgLogging()</td><td>Disable logging routines.</td><td>Logging</td></tr> +<tr><td>void EnableMsgLogging ()</td><td>Enable logging routines.</td><td>Logging</td></tr> +<tr><td>xbInt16 FlushLog()</td><td>Flush any queued logfile updates to disk.</td><td>Logging</td></tr> +<tr><td>const xbString &GetLogDirectory () const</td><td>Get the current logfile directory.</td><td>Logging</td></tr> +<tr><td>const xbString &GetLogFileName () const</td><td>Get the current logfile name.</td><td>Logging</td></tr> +<tr><td>const xbString &GetLogFqFileName() const</td><td>Get fully qualified logfile name.</td><td>Logging</td></tr> +<tr><td>xbBool GetLogStatus () const</td><td>Get the logging status.</td><td>Logging</td></tr> +<tr><td>void SetLogDirectory( const xbString &sLogFileDirectory )</td><td>Set the log directory. Must be done while logging is off.</td><td>Logging</td></tr> +<tr><td>void SetLogFileName( const xbString &sLogFileName )</td><td>Set the log file name. Must be done while logging is off.</td><td>Logging</td></tr> +<tr><td>void SetLogSize( size_t lSize )</td><td>Set the logfile size. After the size is reached, the log file roll.</td><td>Logging</td></tr> +<tr><td>xbInt16 WriteLogBytes ( xbUInt32 lCnt, const char *p )</td><td>Write lCnt bytes pointed to by pointer p to the logfile.</td><td>Logging</td></tr> +<tr><td>xbInt16 WriteLogMessage( const xbString &sLogMessage, xbInt16 iOutputOpt = 0 )</td><td>Write a string to the logfile.</td><td>Logging</td></tr> + +<tr><td colspan=3><hr></td></tr> + +<tr><td>xbInt16 xbXBase::CreateFqn( const xbString &sDirIn, const xbString &sNameIn, const xbString &sExtIn, xbString &sFqnOut )</td> +<td>Create fully qualified file name from directory, file name and optional extension. This routine sets the correct separators dependent on OS. +</td><td>Misc</td></tr> + + +<tr><td>xbInt16 xbXBase::GetCmdLineOpt( xbInt32 lArgc, char **sArgv, xbString &sOptRqst, xbString &sParmOut )<br> +xbXBase::GetCmdLineOpt( xbInt32 lArgc, char **sArgv, const char *sOptRqst, xbString &sParmOut )</td><td>Parse command line values seeking given parameter info.</td><td>Misc</td></tr> + +<tr><td>void xbSleep( xbInt32 lMillisecs )</td><td>Sleep command, used mainly in lock commands for waiting between retries.</td><td>Misc</td></td></tr> + +<tr><td colspan=3><hr></td></tr> +<tr><td>xbInt16 ABS( xbDouble dIn, xbDouble &dOut )</td><td>Dbase ABS function.</td><td>Expression</td></tr> +<tr><td>xbInt16 ALLTRIM( const xbString &sIn, xbString &sOut )</td><td>Dbase ALLTRIM function.</td><td>Expression</td></tr> +<tr><td>xbInt16 ASC( const xbString &s, xbDouble &dAscOut )</td><td>Dbase ASC function.</td><td>Expression</td></tr> +<tr><td>xbInt16 AT( const xbString &sSrchFor, const xbString &sBase, xbDouble &dPos )</td><td>Dbase AT function.</td><td>Expression</td></tr> +<tr><td>xbInt16 CDOW( xbDate &dInDate, xbString &sOutDow )</td><td>Dbase CDOW function.</td><td>Expression</td></tr> +<tr><td>xbInt16 CHR( xbDouble dAsciCd, xbString &sOut )</td><td>Dbase CHR function.</td><td>Expression</td></tr> +<tr><td>xbInt16 CMONTH( xbDate &dInDate, xbString &sOutMonth )</td><td>Dbase CMONTH function.</td><td>Expression</td></tr> +<tr><td>xbInt16 CTOD( const xbString &sInDate, xbDate &dOutDate )</td><td>Dbase CTOD function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DATE( xbDate &dOutDate )</td><td>Dbase DATE function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DAY( const xbDate &dInDate, xbDouble &dOutDay )</td><td>Dbase DAY function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DEL( xbDbf * d, xbString &sOut, xbInt16 iRecBufSw = 0 )</td><td>Dbase DEL function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DELETED( xbDbf * d, xbBool &bOut, xbInt16 iRecBufSw = 0 )</td><td>Dbase DELETED function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DESCEND( const xbString &sIn,xbString &sOut )<br>xbInt16 DESCEND( const xbDate &dInDate, xbDate &dOutDate )<br>xbInt16 DESCEND( const xbDouble dIn, xbDouble &dsOut )</td><td>Dbase DESCEND function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DOW( const xbDate &sInDate, xbDouble &dDowOut )</td><td>Dbase DOW function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DTOC( xbDate &dInDate, xbString &sOutFmtDate )</td><td>Dbase DTOC function.</td><td>Expression</td></tr> +<tr><td>xbInt16 DTOS( xbDate &dInDate, xbString &sOutFmtDate )</td><td>Dbase DTOS function.</td><td>Expression</td></tr> +<tr><td>xbInt16 EXP( xbDouble dIn, xbDouble &dOut )</td><td>Dbase EXP function.</td><td>Expression</td></tr> +<tr><td>xbInt16 IIF( xbBool bResult, const xbString &sTrueResult, const xbString &sFalseResult, xbString &sResult )</td><td>Dbase IIF function.</td><td>Expression</td></tr> +<tr><td>xbInt16 INT( xbDouble dIn, xbDouble &dOut )</td><td>Dbase INT function.</td><td>Expression</td></tr> +<tr><td>xbInt16 ISALPHA( const xbString &s, xbBool &bResult )</td><td>Dbase ISALPHA function.</td><td>Expression</td></tr> +<tr><td>xbInt16 ISLOWER( const xbString &s, xbBool &bResult )</td><td>Dbase ISLOWER function.</td><td>Expression</td></tr> +<tr><td>xbInt16 ISUPPER( const xbString &s, xbBool &bResult )</td><td>Dbase ISUPPER function.</td><td>Expression</td></tr> +<tr><td>xbInt16 LEFT( const xbString &sIn, xbUInt32 lCharCnt, xbString &sOut )</td><td>Dbase LEF function.</td><td>Expression</td></tr> +<tr><td>xbInt16 LEN( const xbString &sIn, xbDouble &dLen )</td><td>Dbase LEN function.</td><td>Expression</td></tr> +<tr><td>xbInt16 LOG( xbDouble dIn, xbDouble &dOut )</td><td>Dbase LOG function.</td><td>Expression</td></tr> +<tr><td>xbInt16 LOWER( const xbString &sIn, xbString &sOut )</td><td>Dbase LOWER function.</td><td>Expression</td></tr> +<tr><td>xbInt16 LTRIM( const xbString &sIn, xbString & sOut )</td><td>Dbase LTRIM function.</td><td>Expression</td></tr> +<tr><td>xbInt16 MAX( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut )</td><td>Dbase MAX function.</td><td>Expression</td></tr> +<tr><td>xbInt16 MIN( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut )</td><td>Dbase MIN function.</td><td>Expression</td></tr> +<tr><td>xbInt16 MONTH( xbDate &dInDate, xbDouble &dMonthOut )</td><td>Dbase MONTH function.</td><td>Expression</td></tr> +<tr><td>xbInt16 RECCOUNT( xbDbf * d, xbDouble &dRecOut )</td><td>Dbase RECCOUNT function.</td><td>Expression</td></tr> +<tr><td>xbInt16 RECNO( xbDbf * d, xbDouble &dRecOut )</td><td>Dbase RECNO function.</td><td>Expression</td></tr> +<tr><td>xbInt16 REPLICATE( const xbString &sIn, xbUInt32 ulRepCnt, xbString &sOut )</td><td>Dbase REPLICATE function.</td><td>Expression</td></tr> +<tr><td>xbInt16 RIGHT( const xbString &sIn, xbUInt32 iCharCnt, xbString &sOut )</td><td>Dbase RIGHT function.</td><td>Expression</td></tr> +<tr><td>xbInt16 RTRIM( const xbString &sIn, xbString &sOut )</td><td>Dbase RTRIM function.</td><td>Expression</td></tr> +<tr><td>xbInt16 SPACE( xbInt32 lCnt, xbString &sOut )</td><td>Dbase SPACE function.</td><td>Expression</td></tr> +<tr><td>xbInt16 SQRT( xbDouble dBase, xbDouble &dSqrRt )</td><td>Dbase SQRT function.</td><td>Expression</td></tr> +<tr><td>xbInt16 STOD( const xbString &sIn, xbDate &sDateOut )</td><td>Dbase STOD function.</td><td>Expression</td></tr> +<tr><td>xbInt16 STR( xbDouble dIn, xbString &sOut )</td><td>Dbase function.</td><td>Expression</td></tr> +<tr><td>xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbString &sOut )<br> + xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut )<br> + xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sPadChar, xbString &sOut )</td><td>Dbase STR function.</td><td>Expression</td></tr> +<tr><td>xbInt16 STRZERO( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut )</td><td>Dbase STRZERO function.</td><td>Expression</td></tr> +<tr><td>xbInt16 SUBSTR( const xbString &sIn, xbUInt32 ulStartPos, xbUInt32 ulLen, xbString &sOut )</td><td>Dbase SUBSTR function.</td><td>Expression</td></tr> +<tr><td>xbInt16 TRIM( const xbString &sIn, xbString &sOut )</td><td>Dbase TRIM function.</td><td>Expression</td></tr> +<tr><td>xbInt16 UPPER( const xbString &sIn, xbString &sOut )</td><td>Dbase UPPER function.</td><td>Expression</td></tr> +<tr><td>xbInt16 VAL( const xbString &sIn, xbDouble &dOut )</td><td>Dbase VAL function.</td><td>Expression</td></tr> +<tr><td>xbInt16 YEAR( xbDate &dInDate, xbDouble &dOutYear )</td><td>Dbase YEAR function.</td><td>Expression</td></tr> +</table> -struct NtxHeadNode { /* ntx header on disk */ - xbUShort Signature; /* Clipper 5.x or Clipper 87 */ - xbUShort Version; /* Compiler Version */ - /* Also turns out to be */ - /* a last modified counter */ - xbULong StartNode; /* Offset in file for first node */ - xbULong UnusedOffset; /* First free node offset */ - xbUShort KeySize; /* Size of items (KeyLen + 8) */ - xbUShort KeyLen; /* Size of the Key */ - xbUShort DecimalCount; /* Number of decimal positions */ - xbUShort KeysPerNode; /* Max number of keys per node */ - xbUShort HalfKeysPerNode; /* Min number of keys per node */ - char KeyExpression[256]; /* Null terminated key expression */ - unsigned Unique; /* Unique Flag */ - char NotUsed[745]; -}; +<br><br> +<hr> -</xmp> +<h3>Example program using xbXbase methods</h3> +</center> +<xmp> +/* xb_ex_ssv.cpp +XBase64 Software Library -<br><br> +Copyright (c) 1997,2003,2014,2021,2022,2023 Gary A Kunkel + +The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. + +Email Contact: + + XDB-devel@lists.sourceforge.net + XDB-users@lists.sourceforge.net + +This program demonstrates using functionality of the xbSsv class (Shared system values) + +*/ + +#include "xbase.h" + +using namespace xb; + +int main( int ac, char ** av ){ + + xbXBase x; // set up xbase for business + xbString sMsg; // a message string + + sMsg.Sprintf( "Program [%s] initializing...", av[0] ); + std::cout << sMsg.Str() << std::endl; + + // example code to set up log file usage + #ifdef XB_LOGGING_SUPPORT + char cSeperator; // is this a unix (/) or windows (\) file system + xbString sLog; // general string for log file activities + sLog = x.GetLogFqFileName().Str(); // get the system default log file name + std::cout << "System default logfile is [" << sLog.Str() << "]" << std::endl; + + cSeperator = sLog.GetPathSeparator(); // get the seperator from + std::cout << "Path seperator = [" << cSeperator << "]" << std::endl; + + sLog.Sprintf( "..%c", cSeperator ); + x.SetLogDirectory( sLog ); + std::cout << "sLog = [" << sLog.Str() << "]\n"; + + sLog = x.GetLogFqFileName().Str(); // get the system default log file name + std::cout << "New logfile is [" << sLog.Str() << "]" << std::endl; + + // turn on logging after file name set + x.EnableMsgLogging(); + #endif // XB_LOGGING_SUPPORT + + // const char *GetErrorMessage( xbInt16 ErrorCode ) const; + // void DisplayError( xbInt16 ErrorCode ) const; + std::cout << "DisplayError( -100 ) - "; + x.DisplayError( -100 ); + // << "]" << std::endl; + + + // void SetDefaultDateFormat( const xbString &sDefaultDateFormat ); + // xbString& GetDefaultDateFormat() const; + std::cout << "GetDefaultDateFormat() - " << x.GetDefaultDateFormat() << std::endl; + + // void SetDataDirectory ( const xbString &sDataDirectory ); + // xbString& GetDataDirectory() const; + std::cout << "GetDataDirectory() - " << x.GetDataDirectory() << std::endl; + + // xbInt16 GetEndianType() const; + if( x.GetEndianType() == 'L' ) + std::cout << "Little Endian Architecture." << std::endl; + else + std::cout << "Bid Endian Architecture." << std::endl; + + //xbBool GetDefaultAutoCommit() const; + //void SetDefaultAutoCommit( xbBool bDefaultAutoCommit ); + if( x.GetDefaultAutoCommit()) + std::cout << "AutoCommit is on." << std::endl; + else + std::cout << "AutoCommit is off." << std::endl; + + //xbBool GetMultiUser () const; + //void SetMultiUser ( xbBool bMultiUser ); + if( x.GetMultiUser()) + std::cout << "Multi user (locking) is enabled." << std::endl; + else + std::cout << "Multi user (locking) not enabled." << std::endl; + + #if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) + // xbInt16 GetUniqueKeyOpt () const; + // xbInt16 SetUniqueKeyOpt ( xbInt16 iUniqueKeyOpt ); + // XB_HALT_ON_DUPKEY + // XB_EMULATE_DBASE + if( x.GetUniqueKeyOpt() == XB_HALT_ON_DUPKEY ) + std::cout << "UniqueKey option - XB_HALT_ON_DUPKEY" << std::endl; + else if( x.GetUniqueKeyOpt() == XB_EMULATE_DBASE ) + std::cout << "UniqueKey option - XB_EMULATE_DBASE" << std::endl; + #endif // (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT) + + #ifdef XB_LOCKING_SUPPORT + //xbInt16 GetDefaultLockRetries () const; + //void SetDefaultLockRetries ( xbInt16 iRetryCount ); + //xbInt32 GetDefaultLockWait () const; + //void SetDefaultLockWait ( xbInt32 lRetryWait ); + //xbInt16 GetDefaultLockFlavor () const; + //void SetDefaultLockFlavor ( xbInt16 iLockFlavor ); + //xbBool GetDefaultAutoLock () const; + //void SetDefaultAutoLock ( xbBool bAutoLock ); + //void EnableDefaultAutoLock (); + //void DisableDefaultAutoLock (); + + std::cout << "GetDefaultLockRetries() - " << x.GetDefaultLockRetries() << std::endl; + std::cout << "GetDefaultLockWait() - " << x.GetDefaultLockWait() << std::endl; + std::cout << "GetDefaultAutoLock() - " << x.GetDefaultAutoLock() << std::endl; + #endif // XB_LOCKING_SUPPORT + + #ifdef XB_MDX_SUPPORT + // xbInt16 GetCreateMdxBlockSize() const; + // xbInt16 SetCreateMdxBlockSize( xbInt16 ulBlockSize ); + std::cout << "GetCreateMdxBlockSize() - " << x.GetCreateMdxBlockSize() << std::endl; + #endif // XB_MDX_SUPPORT + + #ifdef XB_BLOCKREAD_SUPPORT + // xbUInt32 GetDefaultBlockReadSize() const; + // void SetDefaultBlockReadSize( xbUInt32 ulDfltBlockReadSize ); + std::cout << "GetDefaultBlockReadSize() - " << x.GetDefaultBlockReadSize() << std::endl; + #endif // XB_BLOCKREAD_SUPPORT + + //xbBool BitSet ( unsigned char c, xbInt16 iBitNo ) const; + //void BitDump ( unsigned char c ) const; + //void BitDump ( char c ) const; + std::cout << "BitDump( 'A' ) - "; + x.BitDump( 'A' ); + + return 0; +} -<h4>Interior and Leaf Nodes</h4> - -NTX files use a B-tree system to store keys. A B-tree is a balanced, -on disk tree who's design minimizes disk access. Interior Nodes and -Leaf Nodes share the same structure in an NTX file. The difference is -that interior nodes point to other nodes. Leaf nodes point to -nothing. Keys in both interior nodes and leaf nodes point to records -in a DBF file. - -Interior nodes have field LeftNodeNo valued which points to the node -which points to the keys which are less than the key value in the KeyVal -field. There is one more LeftNodeNo value in the node than there are keys. The -Last LeftNodeNo points to the node which is greater than the highest -key value in the node. <br><br> - -Leaf nodes have 0 in the LeftNodeNo field.<br><br> - - -<TABLE BORDER> -<CAPTION ALIGN="TOP"><h3>NTX Interior Node and Leaf Node Structure</H3></CAPTION> -<TR VALIGN="BASELINE"> -<TR><TH ALIGN="LEFT">Type<TD>Size<TD>Field Name<TD>Description -<TR><TH ALIGN="LEFT">xbShort<TD>2<TD>NoOfKeysThisNode<TD>The number of key values in this node. (N) -<TR><TH ALIGN="LEFT">Array of xbUShort<TD>2<TD>offsets[]<TD>Array of - <pre>HeadNode.KeysPerNode +1</pre> unsigned longs. - These values are the offsets (in bytes) of each key - in this node, from the beginning of the node. -<TR><TH ALIGN="LEFT">char<TD>variable<TD>KeyRecs<TD>A repeating structure of - pointers and keys. See the next table for the KeyRec structure. -</TABLE> -<br><br> -One primary difference between NDX files and NTX files is that NTX -files uses an array of offsets on all interior and leaf nodes. Each -offset is the byte count from the beginning of the node where each -KeyRec will be found. The order of the array of offsets determines -the order of keys on a given node. When keys are added or deleted, -thus changing the order of the keys on a node, only the order of the -offset array is changed. All other key data is not moved. This results -in slightly better index performance. - -<BR> -<TABLE BORDER> -<CAPTION ALIGN="TOP"><h3>KeyRec Structure</H3></CAPTION> -<TR VALIGN="BASELINE"> -<TR><TH ALIGN="LEFT">Type<TD>Size<TD>Field Name<TD>Description -<TR><TH ALIGN="LEFT">xbLong<TD>4<TD>LeftNodeNo<TD>The node number (offset from beginning of file) of the lower node - for this key. 0 in Leaf Nodes. -<TR><TH ALIGN="LEFT">xbLong<TD>4<TD>DbfRecNo<TD>The DBF record number for this key. - 0 in Interior Nodes. -<TR><TH ALIGN="LEFT">char<TD>KeyLen<TD>KeyValue<TD>The key value. -</TABLE> +</xmp> <br><br> -For those interested in knowing how the Xbase DBMS manipulates and -navigates index files, the following discussion may be helpfull.<br><br> - -Xbase DBMS navigates through NTX files by using an in-memory chain of -nodes of the current location / key in use. It starts by reading the -Head Node of the index, which points to the first node of the -file. The first node of the file will be a leaf node if the index is -small or will be an interior node if the index has more than one leaf -node. The first interior node is loaded into memory, added to the -node chain and points to the next node to read. The node is made up -of one or more keys. If it is a leaf node, the logic looks for a -matching key on the node. It continues down the tree, adding the -nodes to the in-memory node chain until it reaches the correct -node. If it finds a matching key in the leaf node, it returns a XB_FOUND -condition. If it doesn't find an exact match in the leaf node, it -returns a XB_NOT_FOUND condition and stops on the key which is greater -than the search key given. - <hr> -<A HREF="mailto:bob@#synxis.com"> -Author: Bob Cotton - bob@synxis.com</A><br> <p><img src="xbase.jpg"><br><hr> </BODY> </HTML> |