3 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Joerg Sonnenberger.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd compute a perfect hash function
40 .Op Fl c Ar utilisation
42 .Op Fl i Ar iterations
49 reads a number of keys one per line from standard input or
51 It computes an order-preserving minimal perfect hash function and writes
59 to write the resulting key mapping to
61 Each line gives the result of the hash function for the corresponding input
66 determines the space efficiency.
68 Supported arguments for
72 This results in an order preserving minimal perfect hash function.
75 must be at least 2, the default.
76 The number of iterations needed grows if the utilisation is very near to 2.
80 The resulting hash function needs three instead of two table lookups when
85 must be at least 1.24, the default.
86 This makes the output for
88 noticable smaller than the output for
91 This results in a non-order preserving minimal perfect hash function.
92 Output size is approximately 2.85 bit per key for the default value of
95 This is also the smallest supported value.
98 Supported arguments for
100 .Bl -tag -width "mi_vector_hash"
101 .It Sy mi_vector_hash
102 Platform-independent version of Jenkins parallel hash.
104 .Xr mi_vector_hash 3 .
107 The number of iterations can be limited with
110 outputs a function matching
112 .Fn hash "const void * restrict" "size_t"
114 The function expects the key length as second argument, for strings not
115 including the terminating NUL.
116 It is the responsibility of the caller to pass in only valid keys or compare
117 the resulting index to the key.
118 The function name can be changed using
122 flag is specified, it will be static.
124 After each failing iteration, a dot is written to stderr.
130 .An J\(:org Sonnenberger