home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / trl14db.zip / TRLPRG.EXE / NDXSIZE.PRG < prev    next >
Text File  |  1990-10-22  |  1KB  |  47 lines

  1. *********
  2. *  NDXSIZE.PRG
  3. *
  4. *  by Leonard Zerman and Tom Rettig
  5. *
  6. *  Placed in the Public Domain by Tom Rettig Associates, 10/22/1990.
  7. *
  8. *  Syntax: NDXSIZE( <key size>, <no. of records> )
  9. *  Return: <expN> integer maximum potential number of bytes in index file.
  10. *  Note  : This is accurate when doing an "INDEX ON" maintenance.
  11. *        : The file size will vary during use.
  12. *********
  13. PARAMETERS keylen, last_recno
  14. PRIVATE maxitem, b_nodes, node_cnt
  15. IF last_recno = 0
  16.    tr_retn = 1024               && size of empty ndx file, any key size
  17.       IF (fox)
  18.          RETURN (tr_retn)
  19.       ELSE
  20.          RETURN
  21.       ENDIF
  22. ENDIF
  23. maxitem  = INT( 504 / (keylen + 8 ) )    && maximum items per node
  24. b_nodes  = ( last_recno / maxitem )      && nodes per branch
  25. * Calculate number of nodes in tree
  26. node_cnt = b_nodes + 2 
  27. maxitem  = maxitem + 1
  28. DO WHILE ( b_nodes > maxitem )
  29.    b_nodes  = INT(( b_nodes - 1 ) / maxitem ) + 1   
  30.    node_cnt = ( node_cnt + b_nodes )
  31. ENDDO
  32. tr_retn = INT( node_cnt * 512 )
  33. IF fox
  34.    RETURN (tr_retn)
  35. ENDIF
  36.  
  37. * return statement is based on this algorithm:
  38. * maxitem            The number of key entries per a node.
  39. * b_nodes            The number of nodes on 1 branch of the tree.
  40. * node_cnt           This is calculated as nodes on the tree are counted
  41. *                    in the DO WHILE loop.  The loop counts all nodes on 
  42. *                    the tree.  
  43. * (node_cnt * 512)   512 bytes per node.
  44.  
  45. * eofunc ndxsize *
  46.  
  47.