.\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)hash.3 8.6 (Berkeley) 8/18/94 .\" .\" Japanese Version Copyright (c) 1999 Shouichi Saito .\" all rights reserved. .\" Translated Mon Jul 26 14:22:49 JST 1999 .\" by Shouichi Saito .\" Proofed Tue Aug 17 1999 by NAKANO Takeo .\" Updated 2008-02-10, Akihiro MOTOKI , LDP v2.77 .\" .\"WORD: access method アクセスメソッド .\"WORD: bucket バケット .\" .TH HASH 3 1994-08-18 "" "Linux Programmer's Manual" .UC 7 .SH 名前 .\"O hash \- hash database access method hash \- hash データベースへのアクセスメソッド .SH 書式 .nf .ft B #include #include .ft R .fi .SH 説明 .\"O The routine .\"O .BR dbopen (3) .\"O is the library interface to database files. .\"O One of the supported file formats is hash files. ルーチン .BR dbopen (3) はデータベースファイルに対するライブラリインターフェースである。 サポートされているファイルフォーマットのひとつに hash ファイルがある。 .\"O The general description of the database access methods is in .\"O .BR dbopen (3), .\"O this manual page describes only the hash specific information. データベースへのアクセスメソッドに関する一般的な記述は .BR dbopen (3) に書かれている。 このマニュアルページでは hash 特有の情報についてのみ記述する。 .PP .\"O The hash data structure is an extensible, dynamic hashing scheme. hash データ構造は、拡張可能な動的ハッシュスキームである。 .PP .\"O The access method specific data structure provided to .\"O .BR dbopen (3) .\"O is defined in the .\"O .I .\"O include file as follows: .BR dbopen (3) に渡される hash アクセスメソッドに特有のデータ構造体は、 .I インクルードファイルで以下のように定義されている。 .in +4n .nf typedef struct { unsigned int bsize; unsigned int ffactor; unsigned int nelem; unsigned int cachesize; uint32_t (*hash)(const void *, size_t); int lorder; } HASHINFO; .fi .in .PP .\"O The elements of this structure are as follows: この構造体の要素を以下に示す。 .TP 10 .I bsize .\"O defines the hash table bucket size, and is, by default, 256 bytes. .\"O It may be preferable to increase the page size for disk-resident tables .\"O and tables with large data items. hash テーブルバケット (table bucket) のサイズを定義する。 デフォルトは 256 バイトである。 ディスクに置かれるテーブルやデータアイテムが大きいテーブルでは ページサイズを大きくするほうが良いだろう。 .TP .I ffactor .\"O indicates a desired density within the hash table. .\"O It is an approximation of the number of keys allowed to accumulate in any .\"O one bucket, determining when the hash table grows or shrinks. .\"O The default value is 8. ユーザが望む hash テーブル中の密度である。 これはそれぞれのバケットに格納できるキーの概数であり、 hash テーブルを拡大・縮小を作用する。 デフォルトは 8 である。 .TP .I nelem .\"O is an estimate of the final size of the hash table. .\"O If not set or set too low, hash tables will expand gracefully as keys .\"O are entered, although a slight performance degradation may be noticed. .\"O The default value is 1. hash テーブルの最終サイズを大まかに見積もった値である。 この値がセットされていなかったり、あまりに低くセットされていると、 hash テーブルはキーが入ってくるに応じて拡張される。 しかし少しパフォーマンスが (おそらく気付く程度に) 落ちる。 デフォルト値は 1 である。 .TP .I cachesize .\"O is the suggested maximum size, in bytes, of the memory cache. .\"O This value is .\"O .IR "only advisory" , .\"O and the access method will allocate more memory rather than fail. メモリキャッシュの最大値 (バイト単位) の参考値。 この値は .BR あくまで参考であり 、 アクセスメソッドはこの値を越えたメモリの割り当てに成功することもある。 .TP .I hash .\"O is a user-defined hash function. .\"O Since no hash function performs equally well on all possible data, the .\"O user may find that the built-in hash function does poorly on a particular .\"O data set. はユーザー定義の hash 関数である。 全てのデータに対してうまく作用する hash 関数と言うのはないから、 特定のデータセットに対しては組み込みの hash 関数では パフォーマンスが低いこともあるかもしれない。 .\"O A user-specified hash functions must take two arguments (a pointer to a byte .\"O string and a length) and return a 32-bit quantity to be used as the hash .\"O value. ユーザー定義の hash 関数は二つの引数をとらなくてはならない (バイト文字 列へのポインタと、長さ)。 そして hash 値として使われる 32ビットの値を返さなくてはならない。 .TP .I lorder .\"O is the byte order for integers in the stored database metadata. .\"O The number should represent the order as an integer; for example, .\"O big endian order would be the number 4,321. データベースに格納されているメタデータの整数値のバイトオーダー。 この数字は、順序を整数で表したものである。 例えばビッグエンディアンなら、この数値は 4,321 となる。 .\"O If .I lorder .\"O is 0 (no order is specified) the current host order is used. .\"O If the file already exists, the specified value is ignored and the .\"O value specified when the tree was created is used. が 0 (指定されていない)場合、現在のホスト で使われている並び順が使われる。 ファイルが既に存在する場合、指定した値は無視されツリーが作られ た時に指定されていた値が使われる。 .PP .\"O If the file already exists (and the .\"O .B O_TRUNC .\"O flag is not specified), the .\"O values specified for .\"O .IR bsize , .\"O .IR ffactor , .\"O .IR lorder , .\"O and .\"O .I nelem .\"O are .\"O ignored and the values specified when the tree was created are used. .\"NAKANO the tree → the hash, でしょう. ファイルが既に存在している (または .B O_TRUNC フラグが指定されていない) と、 .IR bsize , .IR ffactor , .IR lorder , .I nelem に指定された値は無視され、 ハッシュが作られた時に使った値が使われる。 .PP .\"O If a hash function is specified, hash 関数が指定されると、 .I hash_open .\"O will attempt to determine if the hash function specified is the same as .\"O the one with which the database was created, and will fail if it is not. はデータベースが作られた時に指定されていた hash 関数と今回指定された hash 関数が同じかどうかを調べ、 同じでない場合には失敗する。 .PP .\"O Backward-compatible interfaces to the routines described in .BR dbm (3), と .\"O and .BR ndbm (3) に記述されているルーチンへの過去互換を取るためのインターフェイスが 存在する。しかしこれらのインターフェイスは以前のファイルフォー マットとは互換性がない。 .\"O are provided, however these interfaces are not compatible with .\"O previous file formats. .SH エラー .\"O The .\"O .I hash .\"O access method routines may fail and set .\"O .I errno .\"O for any of the errors specified for the library routine .\"O .BR dbopen (3). .I hash アクセスメソッドルーチンは、失敗するとライブラリルーチン .BR dbopen (3) で指定されているエラーに応じた .I errno をセットする。 .SH バグ .\"O Only big and little endian byte order are supported. バイトオーダーとしてはビッグエンディアンとリトルエンディアンのみが サポートされている。 .SH 関連項目 .BR btree (3), .BR dbopen (3), .BR mpool (3), .BR recno (3) .sp .IR "Dynamic Hash Tables" , Per-Ake Larson, Communications of the ACM, April 1988. .sp .IR "A New Hash Package for UNIX" , Margo Seltzer, USENIX Proceedings, Winter 1991.