1<!--$Id: db_set_h_hash.so,v 10.40 2004/08/13 03:38:56 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DB->set_h_hash</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DB->set_h_hash</b> 14</td> 15<td align=right> 16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24int 25DB->set_h_hash(DB *db, 26 u_int32_t (*h_hash_fcn)(DB *, const void *bytes, u_int32_t length)); 27</pre></b> 28<hr size=1 noshade> 29<b>Description: DB->set_h_hash</b> 30<p>Set a user-defined hash function; if no hash function is specified, a 31default hash function is used. Because no hash function performs 32equally well on all possible data, the user may find that the built-in 33hash function performs poorly with a particular data set.</p> 34<p>The DB->set_h_hash method configures operations performed using the specified 35<a href="../api_c/db_class.html">DB</a> handle, not all operations performed on the underlying 36database.</p> 37<p>The DB->set_h_hash method may not be called after the <a href="../api_c/db_open.html">DB->open</a> method is called. 38If the database already exists when 39<a href="../api_c/db_open.html">DB->open</a> is called, the information specified to DB->set_h_hash must 40be the same as that historically used to create the database or 41corruption can occur.</p> 42<p>The DB->set_h_hash method 43returns a non-zero error value on failure 44and 0 on success. 45</p> 46<b>Parameters</b> <br> 47 <b>h_hash_fcn</b><ul compact><li>The <b>h_hash_fcn</b> parameter is the application-specified hash function. 48<p>Application-specified hash functions take a pointer to a byte string and 49a length as parameters, and return a value of type <b>u_int32_t</b>. 50The hash function must handle any key values used by the application 51(possibly including zero-length keys).</p></ul> 52<br> 53<br><b>Errors</b> 54<p>The DB->set_h_hash method 55may fail and return one of the following non-zero errors:</p> 56<br> 57<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_c/db_open.html">DB->open</a> was called; the 58specified hash function differs from the hash function with which the 59database was created; or if an 60invalid flag value or parameter was specified.</ul> 61<br> 62<hr size=1 noshade> 63<br><b>Class</b> 64<a href="../api_c/db_class.html">DB</a> 65<br><b>See Also</b> 66<a href="../api_c/db_list.html">Databases and Related Methods</a> 67</tt> 68<table width="100%"><tr><td><br></td><td align=right> 69<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 70</td></tr></table> 71<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 72</body> 73</html> 74