| 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_hash()</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_ffactor.html" title="DB->set_h_ffactor()" /> |
| 12 | <link rel="next" href="dbset_h_nelem.html" title="DB->set_h_nelem()" /> |
| 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_hash()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="dbset_h_ffactor.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_nelem.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_hash"></a>DB->set_h_hash()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB->set_h_hash(DB *db, |
| 45 | u_int32_t (*h_hash_fcn)(DB *dbp, const void *bytes, |
| 46 | u_int32_t length)); </pre> |
| 47 | <p> |
| 48 | Set a user-defined hash function; if no hash function is specified, a |
| 49 | default hash function is used. Because no hash function performs |
| 50 | equally well on all possible data, the user may find that the built-in |
| 51 | hash function performs poorly with a particular data set. |
| 52 | </p> |
| 53 | <p> |
| 54 | The <code class="methodname">DB->set_h_hash()</code> method configures operations performed using the |
| 55 | specified <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> handle, not |
| 56 | all operations performed on the underlying database. |
| 57 | </p> |
| 58 | <p> |
| 59 | The <code class="methodname">DB->set_h_hash()</code> method may not be called after the |
| 60 | <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method is called. If |
| 61 | the database already exists when <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> |
| 62 | is called, the information specified to <code class="methodname">DB->set_h_hash()</code> must be the same as that |
| 63 | historically used to create the database or corruption can occur. |
| 64 | </p> |
| 65 | <p> |
| 66 | The <code class="methodname">DB->set_h_hash()</code> <span> |
| 67 | <span> |
| 68 | method returns a non-zero error value on failure and 0 on success. |
| 69 | </span> |
| 70 | |
| 71 | </span> |
| 72 | </p> |
| 73 | <div class="sect2" lang="en" xml:lang="en"> |
| 74 | <div class="titlepage"> |
| 75 | <div> |
| 76 | <div> |
| 77 | <h3 class="title"><a id="idp50386968"></a>Parameters</h3> |
| 78 | </div> |
| 79 | </div> |
| 80 | </div> |
| 81 | <div class="sect3" lang="en" xml:lang="en"> |
| 82 | <div class="titlepage"> |
| 83 | <div> |
| 84 | <div> |
| 85 | <h4 class="title"><a id="idp50387160"></a>h_hash_fcn</h4> |
| 86 | </div> |
| 87 | </div> |
| 88 | </div> |
| 89 | <p> |
| 90 | The <span class="bold"><strong>h_hash_fcn</strong></span> parameter is the |
| 91 | application-specified hash function. |
| 92 | </p> |
| 93 | <p> |
| 94 | Application-specified hash functions take a pointer to a byte string |
| 95 | and a length as parameters, and return a value of type <span class="bold"><strong>u_int32_t</strong></span>. The hash function must handle any |
| 96 | key values used by the application (possibly including zero-length |
| 97 | keys). |
| 98 | </p> |
| 99 | </div> |
| 100 | </div> |
| 101 | <div class="sect2" lang="en" xml:lang="en"> |
| 102 | <div class="titlepage"> |
| 103 | <div> |
| 104 | <div> |
| 105 | <h3 class="title"><a id="idp50382568"></a>Errors</h3> |
| 106 | </div> |
| 107 | </div> |
| 108 | </div> |
| 109 | <p> |
| 110 | The <code class="methodname">DB->set_h_hash()</code> <span> |
| 111 | <span> |
| 112 | method may fail and return one of the following non-zero errors: |
| 113 | </span> |
| 114 | |
| 115 | </span> |
| 116 | </p> |
| 117 | <div class="sect3" lang="en" xml:lang="en"> |
| 118 | <div class="titlepage"> |
| 119 | <div> |
| 120 | <div> |
| 121 | <h4 class="title"><a id="idp50392336"></a>EINVAL</h4> |
| 122 | </div> |
| 123 | </div> |
| 124 | </div> |
| 125 | <p> |
| 126 | If the method was called after <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> |
| 127 | was called; or if an invalid flag value or parameter was specified. |
| 128 | </p> |
| 129 | </div> |
| 130 | </div> |
| 131 | <div class="sect2" lang="en" xml:lang="en"> |
| 132 | <div class="titlepage"> |
| 133 | <div> |
| 134 | <div> |
| 135 | <h3 class="title"><a id="idp50391256"></a>Class</h3> |
| 136 | </div> |
| 137 | </div> |
| 138 | </div> |
| 139 | <p> |
| 140 | <a class="link" href="db.html" title="Chapter 2. The DB Handle">DB</a> |
| 141 | </p> |
| 142 | </div> |
| 143 | <div class="sect2" lang="en" xml:lang="en"> |
| 144 | <div class="titlepage"> |
| 145 | <div> |
| 146 | <div> |
| 147 | <h3 class="title"><a id="idp50394408"></a>See Also</h3> |
| 148 | </div> |
| 149 | </div> |
| 150 | </div> |
| 151 | <p> |
| 152 | <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> |
| 153 | </p> |
| 154 | </div> |
| 155 | </div> |
| 156 | <div class="navfooter"> |
| 157 | <hr /> |
| 158 | <table width="100%" summary="Navigation footer"> |
| 159 | <tr> |
| 160 | <td width="40%" align="left"><a accesskey="p" href="dbset_h_ffactor.html">Prev</a> </td> |
| 161 | <td width="20%" align="center"> |
| 162 | <a accesskey="u" href="db.html">Up</a> |
| 163 | </td> |
| 164 | <td width="40%" align="right"> <a accesskey="n" href="dbset_h_nelem.html">Next</a></td> |
| 165 | </tr> |
| 166 | <tr> |
| 167 | <td width="40%" align="left" valign="top">DB->set_h_ffactor() </td> |
| 168 | <td width="20%" align="center"> |
| 169 | <a accesskey="h" href="index.html">Home</a> |
| 170 | </td> |
| 171 | <td width="40%" align="right" valign="top"> DB->set_h_nelem()</td> |
| 172 | </tr> |
| 173 | </table> |
| 174 | </div> |
| 175 | </body> |
| 176 | </html> |