OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man3 / hash.3
1 .\" Copyright (c) 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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.
19 .\"
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
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)hash.3      8.6 (Berkeley) 8/18/94
33 .\"
34 .\" Japanese Version Copyright (c) 1999 Shouichi Saito
35 .\"     all rights reserved.
36 .\" Translated Mon Jul 26 14:22:49 JST 1999
37 .\"     by Shouichi Saito <ss236rx@ymg.urban.ne.jp>
38 .\" Proofed Tue Aug 17 1999 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
39 .\" Updated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
40 .\"
41 .\"WORD:        access method           ¥¢¥¯¥»¥¹¥á¥½¥Ã¥É
42 .\"WORD:        bucket                  ¥Ð¥±¥Ã¥È
43 .\"
44 .TH HASH 3 1994-08-18 "" "Linux Programmer's Manual"
45 .UC 7
46 .SH Ì¾Á°
47 .\"O hash \- hash database access method
48 hash \- hash ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤Î¥¢¥¯¥»¥¹¥á¥½¥Ã¥É
49 .SH ½ñ¼°
50 .nf
51 .ft B
52 #include <sys/types.h>
53 #include <db.h>
54 .ft R
55 .fi
56 .SH ÀâÌÀ
57 .\"O The routine
58 .\"O .BR dbopen (3)
59 .\"O is the library interface to database files.
60 .\"O One of the supported file formats is hash files.
61 ¥ë¡¼¥Á¥ó
62 .BR dbopen (3)
63 ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥é¥¤¥Ö¥é¥ê¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¤¢¤ë¡£
64 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Î¤Ò¤È¤Ä¤Ë hash ¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¡£
65 .\"O The general description of the database access methods is in
66 .\"O .BR dbopen (3),
67 .\"O this manual page describes only the hash specific information.
68 ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ø¤Î¥¢¥¯¥»¥¹¥á¥½¥Ã¥É¤Ë´Ø¤¹¤ë°ìÈÌŪ¤Êµ­½Ò¤Ï
69 .BR dbopen (3)
70 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¡£
71 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ç¤Ï hash ÆÃÍ­¤Î¾ðÊó¤Ë¤Ä¤¤¤Æ¤Î¤ßµ­½Ò¤¹¤ë¡£
72 .PP
73 .\"O The hash data structure is an extensible, dynamic hashing scheme.
74 hash ¥Ç¡¼¥¿¹½Â¤¤Ï¡¢³ÈÄ¥²Äǽ¤ÊưŪ¥Ï¥Ã¥·¥å¥¹¥­¡¼¥à¤Ç¤¢¤ë¡£
75 .PP
76 .\"O The access method specific data structure provided to
77 .\"O .BR dbopen (3)
78 .\"O is defined in the
79 .\"O .I <db.h>
80 .\"O include file as follows:
81 .BR dbopen (3)
82 ¤ËÅϤµ¤ì¤ë hash ¥¢¥¯¥»¥¹¥á¥½¥Ã¥É¤ËÆÃÍ­¤Î¥Ç¡¼¥¿¹½Â¤ÂΤϡ¢
83 .I <db.h>
84 ¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
85 .in +4n
86 .nf
87
88 typedef struct {
89     unsigned int       bsize;
90     unsigned int       ffactor;
91     unsigned int       nelem;
92     unsigned int       cachesize;
93     uint32_t         (*hash)(const void *, size_t);
94     int         lorder;
95 } HASHINFO;
96 .fi
97 .in
98 .PP
99 .\"O The elements of this structure are as follows:
100 ¤³¤Î¹½Â¤ÂΤÎÍ×ÁǤò°Ê²¼¤Ë¼¨¤¹¡£
101 .TP 10
102 .I bsize
103 .\"O defines the hash table bucket size, and is, by default, 256 bytes.
104 .\"O It may be preferable to increase the page size for disk-resident tables
105 .\"O and tables with large data items.
106 hash ¥Æ¡¼¥Ö¥ë¥Ð¥±¥Ã¥È (table bucket) ¤Î¥µ¥¤¥º¤òÄêµÁ¤¹¤ë¡£
107 ¥Ç¥Õ¥©¥ë¥È¤Ï 256 ¥Ð¥¤¥È¤Ç¤¢¤ë¡£
108 ¥Ç¥£¥¹¥¯¤ËÃÖ¤«¤ì¤ë¥Æ¡¼¥Ö¥ë¤ä¥Ç¡¼¥¿¥¢¥¤¥Æ¥à¤¬Â礭¤¤¥Æ¡¼¥Ö¥ë¤Ç¤Ï
109 ¥Ú¡¼¥¸¥µ¥¤¥º¤òÂ礭¤¯¤¹¤ë¤Û¤¦¤¬Îɤ¤¤À¤í¤¦¡£
110 .TP
111 .I ffactor
112 .\"O indicates a desired density within the hash table.
113 .\"O It is an approximation of the number of keys allowed to accumulate in any
114 .\"O one bucket, determining when the hash table grows or shrinks.
115 .\"O The default value is 8.
116 ¥æ¡¼¥¶¤¬Ë¾¤à hash ¥Æ¡¼¥Ö¥ëÃæ¤ÎÌ©Å٤Ǥ¢¤ë¡£
117 ¤³¤ì¤Ï¤½¤ì¤¾¤ì¤Î¥Ð¥±¥Ã¥È¤Ë³ÊǼ¤Ç¤­¤ë¥­¡¼¤Î³µ¿ô¤Ç¤¢¤ê¡¢
118 hash ¥Æ¡¼¥Ö¥ë¤ò³ÈÂ硦½Ì¾®¤òºîÍѤ¹¤ë¡£
119 ¥Ç¥Õ¥©¥ë¥È¤Ï 8 ¤Ç¤¢¤ë¡£
120 .TP
121 .I nelem
122 .\"O is an estimate of the final size of the hash table.
123 .\"O If not set or set too low, hash tables will expand gracefully as keys
124 .\"O are entered, although a slight performance degradation may be noticed.
125 .\"O The default value is 1.
126 hash ¥Æ¡¼¥Ö¥ë¤ÎºÇ½ª¥µ¥¤¥º¤òÂç¤Þ¤«¤Ë¸«ÀѤâ¤Ã¤¿ÃͤǤ¢¤ë¡£
127 ¤³¤ÎÃͤ¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¤ê¡¢¤¢¤Þ¤ê¤ËÄ㤯¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¤È¡¢
128 hash ¥Æ¡¼¥Ö¥ë¤Ï¥­¡¼¤¬Æþ¤Ã¤Æ¤¯¤ë¤Ë±þ¤¸¤Æ³ÈÄ¥¤µ¤ì¤ë¡£
129 ¤·¤«¤·¾¯¤·¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤¬ (¤ª¤½¤é¤¯µ¤ÉÕ¤¯ÄøÅÙ¤Ë) Íî¤Á¤ë¡£
130 ¥Ç¥Õ¥©¥ë¥ÈÃͤϠ1 ¤Ç¤¢¤ë¡£
131 .TP
132 .I cachesize
133 .\"O is the suggested maximum size, in bytes, of the memory cache.
134 .\"O This value is
135 .\"O .IR "only advisory" ,
136 .\"O and the access method will allocate more memory rather than fail.
137 ¥á¥â¥ê¥­¥ã¥Ã¥·¥å¤ÎºÇÂçÃÍ (¥Ð¥¤¥Èñ°Ì) ¤Î»²¹ÍÃÍ¡£
138 ¤³¤ÎÃͤÏ
139 .BR ¤¢¤¯¤Þ¤Ç»²¹Í¤Ç¤¢¤ê ¡¢
140 ¥¢¥¯¥»¥¹¥á¥½¥Ã¥É¤Ï¤³¤ÎÃͤò±Û¤¨¤¿¥á¥â¥ê¤Î³ä¤êÅö¤Æ¤ËÀ®¸ù¤¹¤ë¤³¤È¤â¤¢¤ë¡£
141 .TP
142 .I hash
143 .\"O is a user-defined hash function.
144 .\"O Since no hash function performs equally well on all possible data, the
145 .\"O user may find that the built-in hash function does poorly on a particular
146 .\"O data set.
147 ¤Ï¥æ¡¼¥¶¡¼ÄêµÁ¤Î hash ´Ø¿ô¤Ç¤¢¤ë¡£
148 Á´¤Æ¤Î¥Ç¡¼¥¿¤ËÂФ·¤Æ¤¦¤Þ¤¯ºîÍѤ¹¤ë hash ´Ø¿ô¤È¸À¤¦¤Î¤Ï¤Ê¤¤¤«¤é¡¢
149 ÆÃÄê¤Î¥Ç¡¼¥¿¥»¥Ã¥È¤ËÂФ·¤Æ¤ÏÁȤ߹þ¤ß¤Î hash ´Ø¿ô¤Ç¤Ï
150 ¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤¬Ä㤤¤³¤È¤â¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
151 .\"O A user-specified hash functions must take two arguments (a pointer to a byte
152 .\"O string and a length) and return a 32-bit quantity to be used as the hash
153 .\"O value.
154 ¥æ¡¼¥¶¡¼ÄêµÁ¤Î hash ´Ø¿ô¤ÏÆó¤Ä¤Î°ú¿ô¤ò¤È¤é¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤ (¥Ð¥¤¥Èʸ»ú
155 Îó¤Ø¤Î¥Ý¥¤¥ó¥¿¤È¡¢Ä¹¤µ)¡£
156 ¤½¤·¤Æ hash ÃͤȤ·¤Æ»È¤ï¤ì¤ë 32¥Ó¥Ã¥È¤ÎÃͤòÊÖ¤µ¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
157 .TP
158 .I lorder
159 .\"O is the byte order for integers in the stored database metadata.
160 .\"O The number should represent the order as an integer; for example,
161 .\"O big endian order would be the number 4,321.
162 ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¥á¥¿¥Ç¡¼¥¿¤ÎÀ°¿ôÃͤΥХ¤¥È¥ª¡¼¥À¡¼¡£
163 ¤³¤Î¿ô»ú¤Ï¡¢½ç½ø¤òÀ°¿ô¤Çɽ¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
164 Î㤨¤Ð¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó¤Ê¤é¡¢¤³¤Î¿ôÃͤϠ4,321 ¤È¤Ê¤ë¡£
165 .\"O If
166 .I lorder
167 .\"O is 0 (no order is specified) the current host order is used.
168 .\"O If the file already exists, the specified value is ignored and the
169 .\"O value specified when the tree was created is used.
170 ¤¬ 0 (»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤)¾ì¹ç¡¢¸½ºß¤Î¥Û¥¹¥È
171 ¤Ç»È¤ï¤ì¤Æ¤¤¤ëʤӽ礬»È¤ï¤ì¤ë¡£
172 ¥Õ¥¡¥¤¥ë¤¬´û¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢»ØÄꤷ¤¿ÃͤÏ̵»ë¤µ¤ì¥Ä¥ê¡¼¤¬ºî¤é¤ì
173 ¤¿»þ¤Ë»ØÄꤵ¤ì¤Æ¤¤¤¿Ãͤ¬»È¤ï¤ì¤ë¡£
174 .PP
175 .\"O If the file already exists (and the
176 .\"O .B O_TRUNC
177 .\"O flag is not specified), the
178 .\"O values specified for
179 .\"O .IR bsize ,
180 .\"O .IR ffactor ,
181 .\"O .IR lorder ,
182 .\"O and
183 .\"O .I nelem
184 .\"O are
185 .\"O ignored and the values specified when the tree was created are used.
186 .\"NAKANO the tree ¢ª the hash, ¤Ç¤·¤ç¤¦.
187 ¥Õ¥¡¥¤¥ë¤¬´û¤Ë¸ºß¤·¤Æ¤¤¤ë (¤Þ¤¿¤Ï
188 .B O_TRUNC
189 ¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤) ¤È¡¢
190 .IR bsize ,
191 .IR ffactor ,
192 .IR lorder ,
193 .I nelem
194 ¤Ë»ØÄꤵ¤ì¤¿ÃͤÏ̵»ë¤µ¤ì¡¢
195 ¥Ï¥Ã¥·¥å¤¬ºî¤é¤ì¤¿»þ¤Ë»È¤Ã¤¿Ãͤ¬»È¤ï¤ì¤ë¡£
196 .PP
197 .\"O If a hash function is specified,
198 hash ´Ø¿ô¤¬»ØÄꤵ¤ì¤ë¤È¡¢
199 .I hash_open
200 .\"O will attempt to determine if the hash function specified is the same as
201 .\"O the one with which the database was created, and will fail if it is not.
202 ¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ºî¤é¤ì¤¿»þ¤Ë»ØÄꤵ¤ì¤Æ¤¤¤¿
203 hash ´Ø¿ô¤Èº£²ó»ØÄꤵ¤ì¤¿ hash ´Ø¿ô¤¬Æ±¤¸¤«¤É¤¦¤«¤òÄ´¤Ù¡¢
204 Ʊ¤¸¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï¼ºÇÔ¤¹¤ë¡£
205 .PP
206 .\"O Backward-compatible interfaces to the routines described in
207 .BR dbm (3),
208 ¤È
209 .\"O and
210 .BR ndbm (3)
211 ¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ë¥ë¡¼¥Á¥ó¤Ø¤Î²áµî¸ß´¹¤ò¼è¤ë¤¿¤á¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤¬
212 ¸ºß¤¹¤ë¡£¤·¤«¤·¤³¤ì¤é¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤Ï°ÊÁ°¤Î¥Õ¥¡¥¤¥ë¥Õ¥©¡¼
213 ¥Þ¥Ã¥È¤È¤Ï¸ß´¹À­¤¬¤Ê¤¤¡£
214 .\"O are provided, however these interfaces are not compatible with
215 .\"O previous file formats.
216 .SH ¥¨¥é¡¼
217 .\"O The
218 .\"O .I hash
219 .\"O access method routines may fail and set
220 .\"O .I errno
221 .\"O for any of the errors specified for the library routine
222 .\"O .BR dbopen (3).
223 .I hash
224 ¥¢¥¯¥»¥¹¥á¥½¥Ã¥É¥ë¡¼¥Á¥ó¤Ï¡¢¼ºÇÔ¤¹¤ë¤È¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á¥ó
225 .BR dbopen (3)
226 ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¥¨¥é¡¼¤Ë±þ¤¸¤¿
227 .I errno
228 ¤ò¥»¥Ã¥È¤¹¤ë¡£
229 .SH ¥Ð¥°
230 .\"O Only big and little endian byte order are supported.
231 ¥Ð¥¤¥È¥ª¡¼¥À¡¼¤È¤·¤Æ¤Ï¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó¤È¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó¤Î¤ß¤¬
232 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
233 .SH ´ØÏ¢¹àÌÜ
234 .BR btree (3),
235 .BR dbopen (3),
236 .BR mpool (3),
237 .BR recno (3)
238 .sp
239 .IR "Dynamic Hash Tables" ,
240 Per-Ake Larson, Communications of the ACM, April 1988.
241 .sp
242 .IR "A New Hash Package for UNIX" ,
243 Margo Seltzer, USENIX Proceedings, Winter 1991.