Commit | Line | Data |
---|---|---|
ad787160 C |
1 | .\" Copyright (c) 1990, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
f52ca292 | 3 | .\" |
ad787160 C |
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. | |
f52ca292 | 19 | .\" |
ad787160 C |
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. | |
f52ca292 | 31 | .\" |
ad787160 C |
32 | .\" @(#)hash.3 8.1 (Berkeley) 7/19/93 |
33 | .\" | |
34 | .TH HASH 3 "July 19, 1993" | |
f52ca292 KB |
35 | .UC 7 |
36 | .SH NAME | |
37 | hash \- hash database access method | |
38 | .SH SYNOPSIS | |
39 | .nf | |
40 | .ft B | |
41 | #include <sys/types.h> | |
42 | #include <db.h> | |
43 | .ft R | |
44 | .fi | |
45 | .SH DESCRIPTION | |
46 | The routine | |
47 | .IR dbopen | |
48 | is the library interface to database files. | |
49 | One of the supported file formats is hash files. | |
50 | The general description of the database access methods is in | |
51 | .IR dbopen (3), | |
52 | this manual page describes only the hash specific information. | |
53 | .PP | |
54 | The hash data structure is an extensible, dynamic hashing scheme. | |
55 | .PP | |
56 | The access method specific data structure provided to | |
57 | .I dbopen | |
58 | is defined in the <db.h> include file as follows: | |
59 | .sp | |
60 | typedef struct { | |
61 | .RS | |
62 | int bsize; | |
63 | .br | |
f52ca292 KB |
64 | int ffactor; |
65 | .br | |
ad787160 | 66 | int nelem; |
f52ca292 | 67 | .br |
ad787160 | 68 | int cachesize; |
f52ca292 | 69 | .br |
ad787160 C |
70 | u_long (*hash)(const void *, size_t); |
71 | .br | |
72 | int lorder; | |
f52ca292 KB |
73 | .RE |
74 | } HASHINFO; | |
75 | .PP | |
76 | The elements of this structure are as follows: | |
77 | .TP | |
78 | bsize | |
79 | .I Bsize | |
80 | defines the hash table bucket size, and is, by default, 256 bytes. | |
81 | It may be preferable to increase the page size for disk-resident tables | |
82 | and tables with large data items. | |
83 | .TP | |
84 | cachesize | |
85 | A suggested maximum size, in bytes, of the memory cache. | |
86 | This value is | |
87 | .B only | |
88 | advisory, and the access method will allocate more memory rather | |
89 | than fail. | |
90 | .TP | |
91 | ffactor | |
92 | .I Ffactor | |
93 | indicates a desired density within the hash table. | |
94 | It is an approximation of the number of keys allowed to accumulate in any | |
95 | one bucket, determining when the hash table grows or shrinks. | |
96 | The default value is 8. | |
97 | .TP | |
98 | hash | |
99 | .I Hash | |
100 | is a user defined hash function. | |
101 | Since no hash function performs equally well on all possible data, the | |
102 | user may find that the built-in hash function does poorly on a particular | |
103 | data set. | |
104 | User specified hash functions must take two arguments (a pointer to a byte | |
105 | string and a length) and return an u_long to be used as the hash value. | |
106 | .TP | |
107 | lorder | |
108 | The byte order for integers in the stored database metadata. | |
109 | The number should represent the order as an integer; for example, | |
110 | big endian order would be the number 4,321. | |
111 | If | |
112 | .I lorder | |
113 | is 0 (no order is specified) the current host order is used. | |
114 | If the file already exists, the specified value is ignored and the | |
115 | value specified when the tree was created is used. | |
116 | .TP | |
117 | nelem | |
118 | .I Nelem | |
119 | is an estimate of the final size of the hash table. | |
120 | If not set or set too low, hash tables will expand gracefully as keys | |
121 | are entered, although a slight performance degradation may be noticed. | |
122 | The default value is 1. | |
123 | .PP | |
124 | If the file already exists (and the O_TRUNC flag is not specified), the | |
125 | values specified for the parameters bsize, ffactor, lorder and nelem are | |
126 | ignored and the values specified when the tree was created are used. | |
127 | .PP | |
128 | If a hash function is specified, | |
129 | .I hash_open | |
130 | will attempt to determine if the hash function specified is the same as | |
131 | the one with which the database was created, and will fail if it is not. | |
132 | .PP | |
133 | Backward compatible interfaces to the routines described in | |
134 | .IR dbm (3), | |
135 | and | |
136 | .IR ndbm (3) | |
137 | are provided, however, these interfaces are not compatible with | |
138 | previous file formats. | |
139 | .SH "SEE ALSO" | |
140 | .IR btree (3), | |
141 | .IR dbopen (3), | |
142 | .IR mpool (3), | |
143 | .IR recno (3) | |
144 | .br | |
145 | .IR "Dynamic Hash Tables" , | |
146 | Per-Ake Larson, Communications of the ACM, April 1988. | |
147 | .br | |
148 | .IR "A New Hash Package for UNIX" , | |
149 | Margo Seltzer, USENIX Proceedings, Winter 1991. | |
150 | .SH BUGS | |
151 | Only big and little endian byte order is supported. |