1 .\" Copyright (c) 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)btree.3 8.4 (Berkeley) 8/18/94
34 .\" Japanese Version Copyright (c) 1999 Shouichi Saito
35 .\" all rights reserved.
36 .\" Translated Mon Jul 26 21:43:11 JST 1999
37 .\" by Shouichi Saito <ss236rx@ymg.urban.ne.jp>
38 .\" Proofed Mon Aug 16 1999 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
40 .\"WORD: access method アクセスメソッド
41 .\"WORD: prefix (comparison) 前置比較
42 .TH BTREE 3 1994-08-18 "" "Linux Programmer's Manual"
45 .\"O btree \- btree database access method
46 btree \- btree データベースへのアクセスメソッド
50 #include <sys/types.h>
57 .\"O is the library interface to database files.
60 はデータベースファイルに対するライブラリインターフェースである。
61 .\"O One of the supported file formats is btree files.
62 .\"O The general description of the database access methods is in
64 .\"O this manual page describes only the btree specific information.
65 サポートされているファイルフォーマットのひとつに btree ファイルがある。
66 データベースへのアクセスメソッドに関する一般的な記述は
69 このマニュアルページでは btree 特有の情報についてのみ記述する。
71 .\"O The btree data structure is a sorted, balanced tree structure storing
72 .\"O associated key/data pairs.
73 btree データ構造では、ソートされたバランスツリー構造に
74 互いに関連づけられたキー/データ対を格納している。
76 .\"O The btree access method specific data structure provided to
78 .\"O is defined in the
80 .\"O include file as follows:
82 に渡される btree アクセスメソッドに特有のデータ構造体は、
84 インクルードファイルで次のように定義されている。
91 unsigned int cachesize;
95 int (*compare)(const DBT *key1, const DBT *key2);
96 size_t (*prefix)(const DBT *key1, const DBT *key2);
102 .\"O The elements of this structure are as follows:
106 .\"O The flag value is specified by ORing any of the following values:
108 の値は以下の値のいずれかか、これらの論理和で指定される。
112 .\"O Permit duplicate keys in the tree, that is,
113 .\"O permit insertion if the key to be
114 .\"O inserted already exists in the tree.
115 .\"O The default behavior, as described in
117 .\"O is to overwrite a matching key when inserting a new key or to fail if
119 .\"O .B R_NOOVERWRITE
120 .\"O flag is specified.
121 ツリーの中にキーの重複を許す。すなわちツリーの中に挿入されようとしている
122 キーが既に存在していても、その挿入を許可する。デフォルトの動作は
124 に記述されているように、新しいキーが挿入されると一致したキーを上書きする。
130 .\"O flag is overridden by the
131 .\"O .B R_NOOVERWRITE
132 .\"O flag, and if the
133 .\"O .B R_NOOVERWRITE
134 .\"O flag is specified, attempts to insert duplicate keys into
135 .\"O the tree will fail.
141 フラグが指定された場合、ツリーに複製キーを挿入しようとすると失敗する。
143 .\"O If the database contains duplicate keys, the order of retrieval of
144 .\"O key/data pairs is undefined if the
146 .\"O routine is used, however,
148 .\"O routine calls with the
150 .\"O flag set will always return the logical
151 .\"O "first" of any group of duplicate keys.
154 ルーチンを使った場合のキー/データ対の取得順は未定義である。それに対し、
158 ルーチンを使うと、複製キーのグループの中の
163 .\"O A suggested maximum size (in bytes) of the memory cache.
164 想定されるメモリキャッシュの最大サイズ (バイト単位)。
167 .\"O advisory, and the access method will allocate more memory rather than fail.
168 .\"O Since every search examines the root page of the tree, caching the most
169 .\"O recently used pages substantially improves access time.
172 参考であり、アクセスメソッドはこの値を越えたメモリの
174 .\"O In addition, physical writes are delayed as long as possible, so a moderate
175 .\"O cache can reduce the number of I/O operations significantly.
176 加えて、物理的な書き込みは可能な限り遅延されるので、
177 キャッシュの大きさを適度にしておけば I/O 操作の回数をかなり減らすこと
179 .\"O Obviously, using a cache increases (but only increases) the likelihood of
180 .\"O corruption or lost data if the system crashes while a tree is being modified.
181 あきらかにキャッシュを使うと、ツリーが変更されている途中で
182 システムがクラッシュした場合のデータ破壊やデータロストの可能性は
186 .\"O is 0 (no size is specified) a default cache is used.
187 が 0 (サイズが指定されていない) の場合、デフォルトのキャッシュが使われる。
190 .\"O The maximum number of keys which will be stored on any single page.
191 .\"O Not currently implemented.
192 単一ページに納められる最大キー数である。現在実装されていない。
193 .\" The maximum number of keys which will be stored on any single page.
194 .\" Because of the way the btree data structure works,
196 .\" must always be greater than or equal to 2.
199 .\" is 0 (no maximum number of keys is specified) the page fill factor is
200 .\" made as large as possible (which is almost invariably what is wanted).
203 .\"O The minimum number of keys which will be stored on any single page.
204 .\"O This value is used to determine which keys will be stored on overflow
205 .\"O pages, that is, if a key or data item is longer than the pagesize divided
206 .\"O by the minkeypage value, it will be stored on overflow pages instead
207 .\"O of in the page itself.
208 単一ページに納められる最小キー数である。この値は、どのキーを
210 に納めるか決めるのに使われる。すなわちキーまたはデータが
211 minkeypage の値で分割されたページサイズより大きい時、そのページに納め
212 る代わりにオーバーフローページに納めるということである。
215 .\"O is 0 (no minimum number of keys is specified) a value of 2 is used.
216 が 0 (キーの最小値が指定されていない) の場合、値として 2 が使われる。
219 .\"O Page size is the size (in bytes) of the pages used for nodes in the tree.
220 .\"O The minimum page size is 512 bytes and the maximum page size is 64K.
221 ツリーの中のノードに使われるページサイズ (バイト単位)。
222 最小値は 512 バイトで、最大値は 64K である。
225 .\"O is 0 (no page size is specified) a page size is chosen based on the
226 .\"O underlying file system I/O block size.
227 が 0 (ページサイズが指定されていない) の場合、
228 ファイルシステムの I/O ブロックサイズに基づいて決められる。
231 .\"O Compare is the key comparison function.
234 .\"O It must return an integer less than, equal to, or greater than zero if the
235 .\"O first key argument is considered to be respectively less than, equal to,
236 .\"O or greater than the second key argument.
237 最初のキー引数に対し、二番目のキー引数が大きい場合には正の整数を、
238 同じ場合にはゼロを、小さい場合には負の整数を返す。
239 .\"O The same comparison function must be used on a given tree every time it
241 ツリーを開く際には、常に同じ比較関数が使われなければならない。
244 .\"O is NULL (no comparison function is specified), the keys are compared
245 .\"O lexically, with shorter keys considered less than longer keys.
246 が NULL (比較関数が指定されていない) の場合、
247 辞書的に比較される。短いキーは長いキーより小さいことになる。
250 .\"O Prefix is the prefix comparison function.
253 .\"O If specified, this routine must return the number of bytes of the second key
254 .\"O argument which are necessary to determine that it is greater than the first
256 このルーチンは (指定された場合には)、二番目のキー引数の
257 バイト数を返さなくてはならない。これは二番目のキー引数が
258 一番目のキー引数より大きいかどうか決めるのに必要である。
259 .\"NAKANO ちょっと意味わからん...
260 .\"O If the keys are equal, the key length should be returned.
261 .\"O Note, the usefulness of this routine is very data-dependent, but, in some
262 .\"O data sets can produce significantly reduced tree sizes and search times.
263 キーが同じ場合、キーの長さが返る。このルーチンが有用かどうかは、
264 データに強く依存する。しかしデータセットによっては、明らかにツリー
268 .\"O is NULL (no prefix function is specified),
270 .\"O no comparison function is specified, a default lexical comparison routine
273 が NULL (prefix 関数が指定されていない) で、
275 比較関数が指定されていないと、デフォルトの辞書比較ルーチンが使われる。
278 .\"O is NULL and a comparison routine is specified, no prefix comparison is
281 が NULL で比較関数が指定されている場合は、前置比較は行われない。
284 .\"O The byte order for integers in the stored database metadata.
285 .\"O The number should represent the order as an integer; for example,
286 .\"O big endian order would be the number 4,321.
289 .\"O is 0 (no order is specified) the current host order is used.
290 データベースに格納されているメタデータの整数値のバイトオーダー。
291 この数字は、順序を整数で表したものである。
292 例えばビッグエンディアンなら、この数値は 4,321 となる。
294 が 0 (指定されていない) の場合、現在のホスト
297 .\"O If the file already exists (and the
299 .\"O flag is not specified), the
300 .\"O values specified for the arguments
306 .\"O in favor of the values used when the tree was created.
315 ツリーが作られた時に使った値が用いられる。
317 .\"O Forward sequential scans of a tree are from the least key to the greatest.
318 ツリーの前方順検索は、最小キーから最大キーに向かって行われる。
320 .\"O Space freed up by deleting key/data pairs from the tree is never reclaimed,
321 .\"O although it is normally made available for reuse.
322 .\"O This means that the btree storage structure is grow-only.
323 .\"O The only solutions are to avoid excessive deletions, or to create a fresh
324 .\"O tree periodically from a scan of an existing one.
325 ツリーからキー/データ対が削除されることによってできたスペースは、
326 通常再利用できる形になっているが再利用されることは無い。
327 つまり brtee 記憶構造は肥大する一方である。
329 存在するツリーを調べて定期的に新しいツリーを作るか、だけである。
331 .\"O Searches, insertions, and deletions in a btree will all complete in
332 .\"O O lg base N where base is the average fill factor.
333 .\"O Often, inserting ordered data into btrees results in a low fill factor.
334 .\"O This implementation has been modified to make ordered insertion the best
335 .\"O case, resulting in a much better than normal page fill factor.
339 .\"O access method routines may fail and set
341 .\"O for any of the errors specified for the library routine
344 アクセスメソッドルーチンは失敗すると、ライブラリルーチン
351 .\"O Only big and little endian byte order is supported.
352 バイトオーダーとしてはビッグエンディアンとリトルエンディアンのみが
360 .IR "The Ubiquitous B-tree" ,
361 Douglas Comer, ACM Comput. Surv. 11, 2 (June 1979), 121-138.
363 .IR "Prefix B-trees" ,
364 Bayer and Unterauer, ACM Transactions on Database Systems, Vol. 2, 1
367 .IR "The Art of Computer Programming Vol. 3: Sorting and Searching" ,
368 D.E. Knuth, 1968, pp 471-480.