| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>DB->set_h_ffactor()</title> |
| 7 | <link rel="stylesheet" href="apiReference.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> |
| 10 | <link rel="up" href="db.html" title="Chapter 2. The DB Handle" /> |
| 11 | <link rel="prev" href="dbset_h_compare.html" title="DB->set_h_compare()" /> |
| 12 | <link rel="next" href="dbset_h_hash.html" title="DB->set_h_hash()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DB->set_h_ffactor()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dbset_h_compare.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 2. |
| 26 | The DB Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="dbset_h_hash.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="dbset_h_ffactor"></a>DB->set_h_ffactor()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB->set_h_ffactor(DB *db, u_int32_t h_ffactor); </pre> |
| 45 | <p> |
| 46 | Set the desired density within the hash table. If no value is |
| 47 | specified, the fill factor will be selected dynamically as pages |
| 48 | are filled. |
| 49 | </p> |
| 50 | <p> |
| 51 | The density is an approximation of the number of keys allowed to |
| 52 | accumulate in any one bucket, determining when the hash table grows or |
| 53 | shrinks. If you know the average sizes of the keys and data in your |
| 54 | data set, setting the fill factor can enhance performance. A reasonable |
| 55 | rule computing fill factor is to set it to the following: |
| 56 | </p> |
| 57 | <pre class="programlisting"> (pagesize - 32) / (average_key_size + average_data_size + 8) </pre> |
| 58 | <p> |
| 59 | The <code class="methodname">DB->set_h_ffactor()</code> method configures a database, not only |
| 60 | operations performed using the specified |
| 61 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> handle. |
| 62 | </p> |
| 63 | <p> |
| 64 | The <code class="methodname">DB->set_h_ffactor()</code> method may not be called after the |
| 65 | <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method is called. If |
| 66 | the database already exists when <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> |
| 67 | is called, the information specified to <code class="methodname">DB->set_h_ffactor()</code> will be ignored. |
| 68 | </p> |
| 69 | <p> |
| 70 | The <code class="methodname">DB->set_h_ffactor()</code> <span> |
| 71 | <span> |
| 72 | method returns a non-zero error value on failure and 0 on success. |
| 73 | </span> |
| 74 | |
| 75 | </span> |
| 76 | </p> |
| 77 | <div class="sect2" lang="en" xml:lang="en"> |
| 78 | <div class="titlepage"> |
| 79 | <div> |
| 80 | <div> |
| 81 | <h3 class="title"><a id="idp50370888"></a>Parameters</h3> |
| 82 | </div> |
| 83 | </div> |
| 84 | </div> |
| 85 | <div class="sect3" lang="en" xml:lang="en"> |
| 86 | <div class="titlepage"> |
| 87 | <div> |
| 88 | <div> |
| 89 | <h4 class="title"><a id="idp50266472"></a>h_ffactor</h4> |
| 90 | </div> |
| 91 | </div> |
| 92 | </div> |
| 93 | <p> |
| 94 | The <span class="bold"><strong>h_ffactor</strong></span> parameter is the |
| 95 | desired density within the hash table. |
| 96 | </p> |
| 97 | </div> |
| 98 | </div> |
| 99 | <div class="sect2" lang="en" xml:lang="en"> |
| 100 | <div class="titlepage"> |
| 101 | <div> |
| 102 | <div> |
| 103 | <h3 class="title"><a id="idp50373888"></a>Errors</h3> |
| 104 | </div> |
| 105 | </div> |
| 106 | </div> |
| 107 | <p> |
| 108 | The <code class="methodname">DB->set_h_ffactor()</code> <span> |
| 109 | <span> |
| 110 | method may fail and return one of the following non-zero errors: |
| 111 | </span> |
| 112 | |
| 113 | </span> |
| 114 | </p> |
| 115 | <div class="sect3" lang="en" xml:lang="en"> |
| 116 | <div class="titlepage"> |
| 117 | <div> |
| 118 | <div> |
| 119 | <h4 class="title"><a id="idp50381872"></a>EINVAL</h4> |
| 120 | </div> |
| 121 | </div> |
| 122 | </div> |
| 123 | <p> |
| 124 | If the method was called after <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> |
| 125 | was called; or if an invalid flag value or parameter was specified. |
| 126 | </p> |
| 127 | </div> |
| 128 | </div> |
| 129 | <div class="sect2" lang="en" xml:lang="en"> |
| 130 | <div class="titlepage"> |
| 131 | <div> |
| 132 | <div> |
| 133 | <h3 class="title"><a id="idp50370424"></a>Class</h3> |
| 134 | </div> |
| 135 | </div> |
| 136 | </div> |
| 137 | <p> |
| 138 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 139 | </p> |
| 140 | </div> |
| 141 | <div class="sect2" lang="en" xml:lang="en"> |
| 142 | <div class="titlepage"> |
| 143 | <div> |
| 144 | <div> |
| 145 | <h3 class="title"><a id="idp50372776"></a>See Also</h3> |
| 146 | </div> |
| 147 | </div> |
| 148 | </div> |
| 149 | <p> |
| 150 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 151 | </p> |
| 152 | </div> |
| 153 | </div> |
| 154 | <div class="navfooter"> |
| 155 | <hr /> |
| 156 | <table width="100%" summary="Navigation footer"> |
| 157 | <tr> |
| 158 | <td width="40%" align="left"><a accesskey="p" href="dbset_h_compare.html">Prev</a> </td> |
| 159 | <td width="20%" align="center"> |
| 160 | <a accesskey="u" href="db.html">Up</a> |
| 161 | </td> |
| 162 | <td width="40%" align="right"> <a accesskey="n" href="dbset_h_hash.html">Next</a></td> |
| 163 | </tr> |
| 164 | <tr> |
| 165 | <td width="40%" align="left" valign="top">DB->set_h_compare() </td> |
| 166 | <td width="20%" align="center"> |
| 167 | <a accesskey="h" href="index.html">Home</a> |
| 168 | </td> |
| 169 | <td width="40%" align="right" valign="top"> DB->set_h_hash()</td> |
| 170 | </tr> |
| 171 | </table> |
| 172 | </div> |
| 173 | </body> |
| 174 | </html> |