home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
tr_ndxsz.prg
< prev
next >
Wrap
Text File
|
1990-10-21
|
1KB
|
45 lines
*********
* TR_NDXSZ.PRG
*
* by Leonard Zerman and Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: NDXSIZE( <key size>, <no. of records> )
* Return: <expN> integer maximum potential number of bytes in index file
*********
FUNCTION NDXSIZE
*
PARAMETERS keylen, last_recno
MEMVAR maxitem, b_nodes, node_cnt
PRIVATE maxitem, b_nodes, node_cnt
IF last_recno == 0
RETURN 1024 && size of empty ndx file, any key size
ENDIF
maxitem = INT( 504 / (keylen + 8 ) ) && maximum items per node
b_nodes = ( last_recno / maxitem ) && nodes per branch
* Calculate number of nodes in tree
node_cnt = b_nodes + 2
maxitem = maxitem + 1
DO WHILE ( b_nodes > maxitem )
b_nodes = INT(( b_nodes - 1 ) / maxitem ) + 1
node_cnt = ( node_cnt + b_nodes )
ENDDO
RETURN ( INT(node_cnt * 512) )
* return statement is based on this algorithm:
* maxitem The number of key entries per a node.
* b_nodes The number of nodes on 1 branch of the tree.
* node_cnt This is calculated as nodes on the tree are counted
* in the DO WHILE loop. The loop counts all nodes on
* the tree.
* (node_cnt * 512) 512 bytes per node.
* eofunc ndxsize