==============================================================================
Topic: ISAM
Title: Empty Index Block Calculation Lies
Posted by: Jeff Kreider
Mail box: JABA/AM
Date posted: 05/22/93
Time posted: 8:39 PM
Times read: 21
------------------------------- Message Text ---------------------------------
Jeff Kreider, Consultant is chagrinned. Not only did he write a
bug, he lied to you. In "Inside ISAM", appendix D, I describe
how to write a basic program to anticipate the number of empty
index blocks required of ISMBLD based on the parameters
prompted. In the analysis, I show that it is necessary to
calculate the number of blocks required for each of the three
levels of an ISAM index. Each of these formulas requires
isolating a number "X" in the form:
In the process of solving for X, I point out that it is the
integer amount of X that is needed and any fractional part may
be ignored. "WRONG, calculus breath!" I say to myself. The
fractional part IS significant. Ignoring it could make the
calculated blocks short by as much as 3 blocks.
Consequently, I have placed in the UPLOAD: account ISMBLD.BAS
which is a program built with the correct algorithm (I suspect
it will be moved, eventually, to the Basic Utilities account).
Those of you who have "Inside ISAM", the following are the
details on how to change your copy for accuracy:
Page 151:
WAS:
N=INT((REC'CNT-BLK+1)/HLF'BLK)
SHOULD BE:
N=(REC'CNT-BLK+1)/HLF'BLK
IF N # INT(N) THEN N=INT(N+1)
WAS:
Z=INT((THIRD'LEVEL - BLK)/HLF'BLK)
SHOULD BE:
Z=(THIRD'LEVEL - BLK)/HLF'BLK
IF Z # INT(Z) THEN Z=INT(Z+1)
Page 152 at the top:
WAS:
I = INT((SEC'LEVEL - BLK)/HLF'BLK)
SHOULD BE:
I = (SEC'LEVEL - BLK)/HLF'BLK
IF I # INT(I) THEN I=INT(I+1)
Page 154, Note #2 should read:
Our assumption is that the last block contains BLK-1
entries, which are subtracted from the record count
(REC'CNT) to calculate N. Any fractional part of N, will
cause another block to be required. This fractional part
suggests that less than HLF'BLK entries will reside in
it. Actually, this block will also have HLF'BLK entries
the entries in the last block will be reduced from the
BLK-1 entries of our assumption.
Similar changes should be noted in AMSD Journal Article, "ISAM:
Calculating the Number of Empty Index Blocks", file 3.3.7 in the
Software Volume from November, 1985.
I was curious why it took so long (8 years!) for the problem to
materialize. A case in point is with a 12-byte key because a 12
byte key with 15000 records will exactly fill the ISAM index
during ISMBLD. Most people build a file from 10 to 50% bigger
than their current needs and rebuild when the file runs out of
room or they notice it is within 80 to 95% of capacity. In
either case, how big it should have been is either academic or
goes unnoticed.
I apologize for any inconvenience this may have caused.