User manual - DT-900 高速ファイルサーチライブラリver.1.00(2006年9月29日)

Hash Library User’s Manual 19
注意事項
注意事項注意事項
注意事項
インデックスファイルの総データレコード数(V)は、重要です。
サンプルプログラムでは、V=40でデータファイルを定義しています。
インデックスファイルの総インデックス数(W)は、総データレコードの1.2倍の48となっています。はじめ
に、10レコードを消費し、さらに10レコードを追加するとデータファイルの残容量は20になります。.
し、残容量(20)以上のデータを追加する必要が生じた場合は、Vの値を増やし、再度 iHashAssign()
関数を実行する必要があります。
以下に、プログラム例を示します。
1. Vをより大きな値 (80)に書き換えます.
2. iHashAssign() 関数を実行します。
long ll = 8, /* To hold Length of Key. */
lV = 80
lV = 80lV = 80
lV = 80, /* To hold Volume of Data file. */
lL = 10, /* To hold Length of Data record. */
lW1 = (lV*120)/100, /* To hold volume of Index file. */
lCount = 0; /* To hold a execution counter. */
W, V, L, Iを以下の値とします(Vのみ40
4040
4080
8080
80に変更)
l = キー長 = 8
L = データレコード長 = 10
V =
V = V =
V = 総データレコード数
総データレコード数総データレコード数
総データレコード数 = 80
= 80 = 80
= 80
W = 96
int iI; /* To hold result of HashFunctins.*/
char *pszBuff, /* Key input to Hash Functions. */
*pszReadBuf; /* To hold read/write data. */
/*--------------------- HASH ASIGN START ----------------------------------*/
fpData = fopen("a:\\sample.dat","r");
fpIndex = fopen("b:\\sample.idx","w+");
pszBuff = malloc((size_t)(40));
iDisplayMessage ("HASH asign started : ");
iI = iHashAssign (fpData, fpIndex, ll, lV, lL, lW1);
if (iI != 0)
{
iDisplayMessage ("** ERROR: HashAssign **");
sprintf (pszBuff, "%d",iI);
iDisplayMessage (pszBuff);
}
iHashAssign()関数実行後、インデックスファイルのヘッダ部は以下のようになります。
00000060 indicates W = 96 }
indicates W = 96 }indicates W = 96 }
indicates W = 96 }
00000050 indicates V = 80 }
indicates V = 80 }indicates V = 80 }
indicates V = 80 }
0000000A indicates L = 10 }
indicates L = 10 } indicates L = 10 }
indicates L = 10 } ヘッダ
ヘッダヘッダ
ヘッダ
00000008 indicates l = 8 }
indicates l = 8 }indicates l = 8 }
indicates l = 8 }
00000028 indicates N = 40 }
indicates N = 40 }indicates N = 40 }
indicates N = 40 }
00000001
0000000B
00000015