1 .\" Copyright (c) 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. All advertising materials mentioning features or use of this software
14 .\" must display the following acknowledgement:
15 .\" This product includes software developed by the University of
16 .\" California, Berkeley and its contributors.
17 .\" 4. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)hash.3 8.6 (Berkeley) 8/18/94
36 .TH HASH 3 2017-09-15 "" "Linux Programmer's Manual"
39 hash \- hash database access method
43 #include <sys/types.h>
49 This page documents interfaces provided in glibc up until version 2.1.
50 Since version 2.2, glibc no longer provides these interfaces.
51 Probably, you are looking for the APIs provided by the
57 is the library interface to database files.
58 One of the supported file formats is hash files.
59 The general description of the database access methods is in
61 this manual page describes only the hash-specific information.
63 The hash data structure is an extensible, dynamic hashing scheme.
65 The access-method-specific data structure provided to
69 include file as follows:
77 unsigned int cachesize;
78 uint32_t (*hash)(const void *, size_t);
84 The elements of this structure are as follows:
87 defines the hash table bucket size, and is, by default, 256 bytes.
88 It may be preferable to increase the page size for disk-resident tables
89 and tables with large data items.
92 indicates a desired density within the hash table.
93 It is an approximation of the number of keys allowed to accumulate in any
94 one bucket, determining when the hash table grows or shrinks.
95 The default value is 8.
98 is an estimate of the final size of the hash table.
99 If not set or set too low, hash tables will expand gracefully as keys
100 are entered, although a slight performance degradation may be noticed.
101 The default value is 1.
104 is the suggested maximum size, in bytes, of the memory cache.
106 .IR "only advisory" ,
107 and the access method will allocate more memory rather than fail.
110 is a user-defined hash function.
111 Since no hash function performs equally well on all possible data, the
112 user may find that the built-in hash function does poorly on a particular
114 A user-specified hash functions must take two arguments (a pointer to a byte
115 string and a length) and return a 32-bit quantity to be used as the hash
119 is the byte order for integers in the stored database metadata.
120 The number should represent the order as an integer; for example,
121 big endian order would be the number 4,321.
124 is 0 (no order is specified), the current host order is used.
125 If the file already exists, the specified value is ignored and the
126 value specified when the tree was created is used.
128 If the file already exists (and the
130 flag is not specified), the
138 ignored and the values specified when the tree was created are used.
140 If a hash function is specified,
142 attempts to determine if the hash function specified is the same as
143 the one with which the database was created, and fails if it is not.
145 Backward-compatible interfaces to the routines described in
149 are provided, however these interfaces are not compatible with
150 previous file formats.
154 access method routines may fail and set
156 for any of the errors specified for the library routine
159 Only big and little endian byte order are supported.
166 .IR "Dynamic Hash Tables" ,
167 Per-Ake Larson, Communications of the ACM, April 1988.
169 .IR "A New Hash Package for UNIX" ,
170 Margo Seltzer, USENIX Proceedings, Winter 1991.