home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
trl14db.zip
/
TRLPRG.EXE
/
NDXSIZE.PRG
< prev
next >
Wrap
Text File
|
1990-10-22
|
1KB
|
47 lines
*********
* NDXSIZE.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.
* Note : This is accurate when doing an "INDEX ON" maintenance.
* : The file size will vary during use.
*********
PARAMETERS keylen, last_recno
PRIVATE maxitem, b_nodes, node_cnt
IF last_recno = 0
tr_retn = 1024 && size of empty ndx file, any key size
IF (fox)
RETURN (tr_retn)
ELSE
RETURN
ENDIF
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
tr_retn = INT( node_cnt * 512 )
IF fox
RETURN (tr_retn)
ENDIF
* 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 *