1 .\" $NetBSD: hash.3,v 1.14 2010/12/16 11:57:20 jruoho Exp $
3 .\" Copyright (c) 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)hash.3 8.6 (Berkeley) 8/18/94
37 .Nd hash database access method
44 is the library interface to database files.
45 One of the supported file formats is hash files.
46 The general description of the database access methods is in
48 this manual page describes only the hash specific information.
50 The hash data structure is an extensible, dynamic hashing scheme.
52 The access method specific data structure provided to
57 .Bd -literal -offset indent
63 uint32_t (*hash)(const void *, size_t);
68 The elements of this structure are as follows:
69 .Bl -tag -width cachesizex
72 defines the hash table bucket size, and defaults to 4096 for in-memory tables.
75 is 0 (no bucket size is specified) a bucket size is chosen based on the
76 underlying file system I/O block size.
77 It may be preferable to increase the page size for disk-resident
78 tables and tables with large data items.
81 indicates a desired density within the hash table.
82 It is an approximation of the number of keys allowed to accumulate in
83 any one bucket, determining when the hash table grows or shrinks.
84 The default value is 8.
87 is an estimate of the final size of the hash table.
88 If not set or set too low, hash tables will expand gracefully as keys
89 are entered, although a slight performance degradation may be
91 The default value is 1.
93 A suggested maximum size, in bytes, of the memory cache.
96 advisory, and the access method will allocate more memory rather
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
104 User specified hash functions must take two arguments (a pointer to a
105 byte string and a length) and return a 32-bit quantity to be used as
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.
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.
118 If the file already exists (and the
120 flag is not specified), the values specified for the parameters
126 are ignored and the values specified when the tree was created are
129 If a hash function is specified,
131 will attempt to determine if the hash function specified is the same
132 as the one with which the database was created, and will fail if it is
135 .\"Backward compatible interfaces to the routines described in
139 .\"are provided, however these interfaces are not compatible with
140 .\"previous file formats.
144 access method routines may fail and set
146 for any of the errors specified for the library routine
155 .%T Dynamic Hash Tables
157 .%J Communications of the ACM
163 .%T A New Hash Package for UNIX
165 .%I USENIX Association
166 .%B Proceedings of the 1991 Winter USENIX Technical Conference
169 .%U http://www.usenix.org/publications/library/proceedings/seltzer2.pdf
172 Only big and little endian byte order is supported.