1 .\" Copyright (c) 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
6 .\" @(#)hash.3 8.6 (Berkeley) 8/18/94
8 .TH HASH 3 2017-09-15 "" "Linux Programmer's Manual"
11 hash \- hash database access method
14 .RI ( libc ", " \-lc )
18 #include <sys/types.h>
24 This page documents interfaces provided in glibc up until version 2.1.
25 Since version 2.2, glibc no longer provides these interfaces.
26 Probably, you are looking for the APIs provided by the
32 is the library interface to database files.
33 One of the supported file formats is hash files.
34 The general description of the database access methods is in
36 this manual page describes only the hash-specific information.
38 The hash data structure is an extensible, dynamic hashing scheme.
40 The access-method-specific data structure provided to
44 include file as follows:
52 unsigned int cachesize;
53 uint32_t (*hash)(const void *, size_t);
59 The elements of this structure are as follows:
62 defines the hash table bucket size, and is, by default, 256 bytes.
63 It may be preferable to increase the page size for disk-resident tables
64 and tables with large data items.
67 indicates a desired density within the hash table.
68 It is an approximation of the number of keys allowed to accumulate in any
69 one bucket, determining when the hash table grows or shrinks.
70 The default value is 8.
73 is an estimate of the final size of the hash table.
74 If not set or set too low, hash tables will expand gracefully as keys
75 are entered, although a slight performance degradation may be noticed.
76 The default value is 1.
79 is the suggested maximum size, in bytes, of the memory cache.
82 and the access method will allocate more memory rather than fail.
85 is a user-defined hash function.
86 Since no hash function performs equally well on all possible data, the
87 user may find that the built-in hash function does poorly on a particular
89 A user-specified hash functions must take two arguments (a pointer to a byte
90 string and a length) and return a 32-bit quantity to be used as the hash
94 is the byte order for integers in the stored database metadata.
95 The number should represent the order as an integer; for example,
96 big endian order would be the number 4,321.
99 is 0 (no order is specified), the current host order is used.
100 If the file already exists, the specified value is ignored and the
101 value specified when the tree was created is used.
103 If the file already exists (and the
105 flag is not specified), the
113 ignored and the values specified when the tree was created are used.
115 If a hash function is specified,
117 attempts to determine if the hash function specified is the same as
118 the one with which the database was created, and fails if it is not.
120 Backward-compatible interfaces to the routines described in
124 are provided, however these interfaces are not compatible with
125 previous file formats.
129 access method routines may fail and set
131 for any of the errors specified for the library routine
134 Only big and little endian byte order are supported.
141 .IR "Dynamic Hash Tables" ,
142 Per-Ake Larson, Communications of the ACM, April 1988.
144 .IR "A New Hash Package for UNIX" ,
145 Margo Seltzer, USENIX Proceedings, Winter 1991.