2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB: Db::set_h_ffactor</title>
8
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
12
<a name="2"><!--meow--></a>
13
<table width="100%"><tr valign=top>
15
<h1>Db::set_h_ffactor</h1>
18
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
23
#include <db_cxx.h>
26
Db::set_h_ffactor(u_int32_t h_ffactor);
29
<p>Set the desired density within the hash table.
30
<p>The density is an approximation of the number of keys allowed to
31
accumulate in any one bucket, determining when the hash table grows or
32
shrinks. If you know the average sizes of the keys and data in your
33
data set, setting the fill factor can enhance performance. A reasonable
34
rule computing fill factor is to set it to the following:
35
<p><blockquote><pre>(pagesize - 32) / (average_key_size + average_data_size + 8)</pre></blockquote>
36
<p>If no value is specified, the fill factor will be selected dynamically as
38
<p>The Db::set_h_ffactor method configures a database, not only operations performed
39
using the specified <a href="../api_cxx/db_class.html">Db</a> handle.
40
<p>The Db::set_h_ffactor interface may not be called after the <a href="../api_cxx/db_open.html">Db::open</a>
42
If the database already exists when
43
<a href="../api_cxx/db_open.html">Db::open</a> is called, the information specified to Db::set_h_ffactor will
45
<p>The Db::set_h_ffactor method either returns a non-zero error value or throws an exception that
46
encapsulates a non-zero error value on failure, and returns 0 on success.
48
<p>The Db::set_h_ffactor method may fail and throw an exception or return a non-zero error for the following conditions:
50
<p><dt>EINVAL<dd>An invalid flag value or parameter was specified.
51
<p>Called after <a href="../api_cxx/db_open.html">Db::open</a> was called.
53
<p>The Db::set_h_ffactor method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods.
54
If a catastrophic error has occurred, the Db::set_h_ffactor method may fail and
55
either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a
56
<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>,
57
in which case all subsequent Berkeley DB calls will fail in the same way.
59
<a href="../api_cxx/db_class.html">Db</a>
61
<a href="../api_cxx/db_list.html">Databases and Related Methods</a>
63
<table width="100%"><tr><td><br></td><td align=right>
64
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
66
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>