]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/hash.3
prctl.2: Clarify the unsupported hardware case of EINVAL
[thirdparty/man-pages.git] / man3 / hash.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
a9cd9cb7 4.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
fea681da
MK
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
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.
20.\"
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
31.\" SUCH DAMAGE.
8c9302dc 32.\" %%%LICENSE_END
fea681da
MK
33.\"
34.\" @(#)hash.3 8.6 (Berkeley) 8/18/94
35.\"
4b8c67d9 36.TH HASH 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
37.UC 7
38.SH NAME
39hash \- hash database access method
40.SH SYNOPSIS
41.nf
42.ft B
43#include <sys/types.h>
44#include <db.h>
45.ft R
46.fi
47.SH DESCRIPTION
df21098d
MK
48.IR "Note well" :
49This page documents interfaces provided in glibc up until version 2.1.
50Since version 2.2, glibc no longer provides these interfaces.
51Probably, you are looking for the APIs provided by the
52.I libdb
53library instead.
847e0d88 54.PP
fea681da 55The routine
50963b36 56.BR dbopen (3)
fea681da
MK
57is the library interface to database files.
58One of the supported file formats is hash files.
59The general description of the database access methods is in
31e9a9ec 60.BR dbopen (3),
76c637e1 61this manual page describes only the hash-specific information.
fea681da
MK
62.PP
63The hash data structure is an extensible, dynamic hashing scheme.
64.PP
76c637e1 65The access-method-specific data structure provided to
50963b36 66.BR dbopen (3)
1082a910
MK
67is defined in the
68.I <db.h>
69include file as follows:
e646a1ba 70.PP
088a639b 71.in +4n
e646a1ba 72.EX
fea681da 73typedef struct {
aeb4b1fc
MK
74 unsigned int bsize;
75 unsigned int ffactor;
76 unsigned int nelem;
77 unsigned int cachesize;
78 uint32_t (*hash)(const void *, size_t);
4db2a2ab 79 int lorder;
fea681da 80} HASHINFO;
b8302363 81.EE
4db2a2ab 82.in
fea681da
MK
83.PP
84The elements of this structure are as follows:
fe4d4c41
MK
85.TP 10
86.I bsize
fea681da
MK
87defines the hash table bucket size, and is, by default, 256 bytes.
88It may be preferable to increase the page size for disk-resident tables
89and tables with large data items.
90.TP
fe4d4c41 91.I ffactor
fea681da
MK
92indicates a desired density within the hash table.
93It is an approximation of the number of keys allowed to accumulate in any
94one bucket, determining when the hash table grows or shrinks.
95The default value is 8.
96.TP
fe4d4c41 97.I nelem
fea681da
MK
98is an estimate of the final size of the hash table.
99If not set or set too low, hash tables will expand gracefully as keys
100are entered, although a slight performance degradation may be noticed.
101The default value is 1.
102.TP
fe4d4c41
MK
103.I cachesize
104is the suggested maximum size, in bytes, of the memory cache.
fea681da 105This value is
fe4d4c41
MK
106.IR "only advisory" ,
107and the access method will allocate more memory rather than fail.
fea681da 108.TP
fe4d4c41 109.I hash
df3e4d6d 110is a user-defined hash function.
fea681da
MK
111Since no hash function performs equally well on all possible data, the
112user may find that the built-in hash function does poorly on a particular
113data set.
fe4d4c41 114A user-specified hash functions must take two arguments (a pointer to a byte
fea681da
MK
115string and a length) and return a 32-bit quantity to be used as the hash
116value.
117.TP
fe4d4c41
MK
118.I lorder
119is the byte order for integers in the stored database metadata.
c13182ef 120The number should represent the order as an integer; for example,
fea681da
MK
121big endian order would be the number 4,321.
122If
123.I lorder
16fe1737 124is 0 (no order is specified), the current host order is used.
cfadad46 125If the file already exists, the specified value is ignored and the
fea681da
MK
126value specified when the tree was created is used.
127.PP
c8fe3fa2
MK
128If the file already exists (and the
129.B O_TRUNC
130flag is not specified), the
91163456 131values specified for
fe4d4c41
MK
132.IR bsize ,
133.IR ffactor ,
134.IR lorder ,
135and
136.I nelem
137are
fea681da
MK
138ignored and the values specified when the tree was created are used.
139.PP
140If a hash function is specified,
141.I hash_open
a23d8efa
MK
142attempts to determine if the hash function specified is the same as
143the one with which the database was created, and fails if it is not.
fea681da 144.PP
66d3a13b 145Backward-compatible interfaces to the routines described in
31e9a9ec 146.BR dbm (3),
fea681da 147and
31e9a9ec 148.BR ndbm (3)
fea681da
MK
149are provided, however these interfaces are not compatible with
150previous file formats.
151.SH ERRORS
152The
153.I hash
154access method routines may fail and set
155.I errno
156for any of the errors specified for the library routine
31e9a9ec 157.BR dbopen (3).
e37e3282 158.SH BUGS
fe4d4c41 159Only big and little endian byte order are supported.
47297adb 160.SH SEE ALSO
31e9a9ec
MK
161.BR btree (3),
162.BR dbopen (3),
163.BR mpool (3),
164.BR recno (3)
847e0d88 165.PP
fea681da
MK
166.IR "Dynamic Hash Tables" ,
167Per-Ake Larson, Communications of the ACM, April 1988.
847e0d88 168.PP
fea681da
MK
169.IR "A New Hash Package for UNIX" ,
170Margo Seltzer, USENIX Proceedings, Winter 1991.