229 lines
6.1 KiB
HTML
229 lines
6.1 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of HASH</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>HASH</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
hash - hash database access method
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>>
|
|
#include <<A HREF="file:///usr/include/db.h">db.h</A>>
|
|
</B></PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<I>Note well</I>:
|
|
|
|
This page documents interfaces provided in glibc up until version 2.1.
|
|
Since version 2.2, glibc no longer provides these interfaces.
|
|
Probably, you are looking for the APIs provided by the
|
|
<I>libdb</I>
|
|
|
|
library instead.
|
|
<P>
|
|
|
|
The routine
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3)
|
|
|
|
is the library interface to database files.
|
|
One of the supported file formats is hash files.
|
|
The general description of the database access methods is in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3),
|
|
|
|
this manual page describes only the hash-specific information.
|
|
<P>
|
|
|
|
The hash data structure is an extensible, dynamic hashing scheme.
|
|
<P>
|
|
|
|
The access-method-specific data structure provided to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3)
|
|
|
|
is defined in the
|
|
<I><<A HREF="file:///usr/include/db.h">db.h</A>></I>
|
|
|
|
include file as follows:
|
|
<P>
|
|
|
|
|
|
|
|
typedef struct {
|
|
<BR> unsigned int bsize;
|
|
<BR> unsigned int ffactor;
|
|
<BR> unsigned int nelem;
|
|
<BR> unsigned int cachesize;
|
|
<BR> uint32_t (*hash)(const void *, size_t);
|
|
<BR> int lorder;
|
|
} HASHINFO;
|
|
|
|
|
|
<P>
|
|
|
|
The elements of this structure are as follows:
|
|
<DL COMPACT>
|
|
<DT id="1"><I>bsize</I>
|
|
|
|
<DD>
|
|
defines the hash table bucket size, and is, by default, 256 bytes.
|
|
It may be preferable to increase the page size for disk-resident tables
|
|
and tables with large data items.
|
|
<DT id="2"><I>ffactor</I>
|
|
|
|
<DD>
|
|
indicates a desired density within the hash table.
|
|
It is an approximation of the number of keys allowed to accumulate in any
|
|
one bucket, determining when the hash table grows or shrinks.
|
|
The default value is 8.
|
|
<DT id="3"><I>nelem</I>
|
|
|
|
<DD>
|
|
is an estimate of the final size of the hash table.
|
|
If not set or set too low, hash tables will expand gracefully as keys
|
|
are entered, although a slight performance degradation may be noticed.
|
|
The default value is 1.
|
|
<DT id="4"><I>cachesize</I>
|
|
|
|
<DD>
|
|
is the suggested maximum size, in bytes, of the memory cache.
|
|
This value is
|
|
<I>only advisory</I>,
|
|
|
|
and the access method will allocate more memory rather than fail.
|
|
<DT id="5"><I>hash</I>
|
|
|
|
<DD>
|
|
is a user-defined hash function.
|
|
Since no hash function performs equally well on all possible data, the
|
|
user may find that the built-in hash function does poorly on a particular
|
|
data set.
|
|
A user-specified hash functions must take two arguments (a pointer to a byte
|
|
string and a length) and return a 32-bit quantity to be used as the hash
|
|
value.
|
|
<DT id="6"><I>lorder</I>
|
|
|
|
<DD>
|
|
is the byte order for integers in the stored database metadata.
|
|
The number should represent the order as an integer; for example,
|
|
big endian order would be the number 4,321.
|
|
If
|
|
<I>lorder</I>
|
|
|
|
is 0 (no order is specified), the current host order is used.
|
|
If the file already exists, the specified value is ignored and the
|
|
value specified when the tree was created is used.
|
|
</DL>
|
|
<P>
|
|
|
|
If the file already exists (and the
|
|
<B>O_TRUNC</B>
|
|
|
|
flag is not specified), the
|
|
values specified for
|
|
<I>bsize</I>,
|
|
|
|
<I>ffactor</I>,
|
|
|
|
<I>lorder</I>,
|
|
|
|
and
|
|
<I>nelem</I>
|
|
|
|
are
|
|
ignored and the values specified when the tree was created are used.
|
|
<P>
|
|
|
|
If a hash function is specified,
|
|
<I>hash_open</I>
|
|
|
|
attempts to determine if the hash function specified is the same as
|
|
the one with which the database was created, and fails if it is not.
|
|
<P>
|
|
|
|
Backward-compatible interfaces to the routines described in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbm">dbm</A></B>(3),
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ndbm">ndbm</A></B>(3)
|
|
|
|
are provided, however these interfaces are not compatible with
|
|
previous file formats.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
The
|
|
<I>hash</I>
|
|
|
|
access method routines may fail and set
|
|
<I>errno</I>
|
|
|
|
for any of the errors specified for the library routine
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3).
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
Only big and little endian byte order are supported.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+btree">btree</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+dbopen">dbopen</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mpool">mpool</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+recno">recno</A></B>(3)
|
|
|
|
<P>
|
|
|
|
<I>Dynamic Hash Tables</I>,
|
|
|
|
Per-Ake Larson, Communications of the ACM, April 1988.
|
|
<P>
|
|
|
|
<I>A New Hash Package for UNIX</I>,
|
|
|
|
Margo Seltzer, USENIX Proceedings, Winter 1991.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="8"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="9"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="10"><A HREF="#lbAE">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAF">BUGS</A><DD>
|
|
<DT id="12"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="13"><A HREF="#lbAH">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:45 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|