Debian Codegraph @

docs/api_reference/C/dbset_bt_prefix.html

raw symbols SCIP
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-&gt;set_bt_prefix()</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_bt_minkey.html" title="DB-&gt;set_bt_minkey()" />
12 <link rel="next" href="dbset_cachesize.html" title="DB-&gt;set_cachesize()" />
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-&gt;set_bt_prefix()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbset_bt_minkey.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_cachesize.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_bt_prefix"></a>DB-&gt;set_bt_prefix()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB-&gt;set_bt_prefix(DB *db,
45 size_t (*bt_prefix_fcn)(DB *, const *dbt1, const *dbt2)); </pre>
46 <p>
47 Set the Btree prefix function. The prefix function is used to
48 determine the amount by which keys stored on the Btree internal pages
49 can be safely truncated without losing their uniqueness. See the
50 <a href="../../programmer_reference/bt_conf.html#am_conf_bt_prefix" class="olink">Btree prefix comparison</a> section of the Berkeley DB Reference Guide for more
51 details about how this works. The usefulness of this is
52 data-dependent, but can produce significantly reduced tree sizes and
53 search times in some data sets.
54 </p>
55 <p>
56 If no prefix function or key comparison function is specified by the
57 application, a default lexical comparison function is used as the
58 prefix function. If no prefix function is specified and a key
59 comparison function is specified, no prefix function is used. It is
60 an error to specify a prefix function without also specifying a Btree
61 key comparison function.
62 </p>
63 <p>
64 The <code class="methodname">DB-&gt;set_bt_prefix()</code> method configures operations performed using
65 the specified <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> handle,
66 not all operations performed on the underlying database.
67 </p>
68 <p>
69 The <code class="methodname">DB-&gt;set_bt_prefix()</code> method may not be called after the
70 <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a> method is called. If
71 the database already exists when <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a>
72 is called, the information specified to <code class="methodname">DB-&gt;set_bt_prefix()</code> must be the same as that
73 historically used to create the database or corruption can occur.
74 </p>
75 <p>
76 The <code class="methodname">DB-&gt;set_bt_prefix()</code> <span>
77 <span>
78 method returns a non-zero error value on failure and 0 on success.
79 </span>
80
81 </span>
82 </p>
83 <div class="sect2" lang="en" xml:lang="en">
84 <div class="titlepage">
85 <div>
86 <div>
87 <h3 class="title"><a id="idp50140536"></a>Parameters</h3>
88 </div>
89 </div>
90 </div>
91 <div class="sect3" lang="en" xml:lang="en">
92 <div class="titlepage">
93 <div>
94 <div>
95 <h4 class="title"><a id="idp50156264"></a>bt_prefix_fcn</h4>
96 </div>
97 </div>
98 </div>
99 <p>
100 The <span class="bold"><strong>bt_prefix_fcn</strong></span> function is the
101 application-specific Btree prefix function. The prefix function takes
102 three parameters:
103 </p>
104 <div class="itemizedlist">
105 <ul type="disc">
106 <li>
107 <p>
108 <code class="literal">db</code>
109 </p>
110 <p>
111 The <span class="bold"><strong>db</strong></span> parameter is the enclosing
112 database handle.
113 </p>
114 </li>
115 <li>
116 <p>
117 <code class="literal">dbt1</code>
118 </p>
119 <p>
120 The <span class="bold"><strong>dbt1</strong></span> parameter is a
121 <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> representing a database key.
122 </p>
123 </li>
124 <li>
125 <p>
126 <code class="literal">dbt2</code>
127 </p>
128 <p>
129 The <span class="bold"><strong>dbt2</strong></span> parameter is a
130 <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> representing a database key.
131 </p>
132 </li>
133 </ul>
134 </div>
135 <p>
136 The <span class="bold"><strong>bt_prefix_fcn</strong></span> function must return the
137 number of bytes of the second key parameter that would be required by the Btree
138 key comparison function to determine the second key parameter's ordering
139 relationship with respect to the first key parameter. If the two keys are equal,
140 the key length should be returned. The prefix function must correctly handle any
141 key values used by the application (possibly including zero-length keys). The
142 <span class="bold"><strong>data</strong></span> and <span class="bold"><strong>size</strong></span>
143 fields of the <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> are the only fields
144 that may be used for the purposes of this determination, and no particular
145 alignment of the memory to which the <span class="bold"><strong>data</strong></span> field
146 refers may be assumed.
147 </p>
148 </div>
149 </div>
150 <div class="sect2" lang="en" xml:lang="en">
151 <div class="titlepage">
152 <div>
153 <div>
154 <h3 class="title"><a id="idp50160400"></a>Errors</h3>
155 </div>
156 </div>
157 </div>
158 <p>
159 The <code class="methodname">DB-&gt;set_bt_prefix()</code> <span>
160 <span>
161 method may fail and return one of the following non-zero errors:
162 </span>
163
164 </span>
165 </p>
166 <div class="sect3" lang="en" xml:lang="en">
167 <div class="titlepage">
168 <div>
169 <div>
170 <h4 class="title"><a id="idp50120048"></a>EINVAL</h4>
171 </div>
172 </div>
173 </div>
174 <p>
175 If the method was called after <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a>
176 was called; or if an invalid flag value or parameter was specified.
177 </p>
178 </div>
179 </div>
180 <div class="sect2" lang="en" xml:lang="en">
181 <div class="titlepage">
182 <div>
183 <div>
184 <h3 class="title"><a id="idp50173496"></a>Class</h3>
185 </div>
186 </div>
187 </div>
188 <p>
189 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a>
190 </p>
191 </div>
192 <div class="sect2" lang="en" xml:lang="en">
193 <div class="titlepage">
194 <div>
195 <div>
196 <h3 class="title"><a id="idp50169264"></a>See Also</h3>
197 </div>
198 </div>
199 </div>
200 <p>
201 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
202 </p>
203 </div>
204 </div>
205 <div class="navfooter">
206 <hr />
207 <table width="100%" summary="Navigation footer">
208 <tr>
209 <td width="40%" align="left"><a accesskey="p" href="dbset_bt_minkey.html">Prev</a> </td>
210 <td width="20%" align="center">
211 <a accesskey="u" href="db.html">Up</a>
212 </td>
213 <td width="40%" align="right"> <a accesskey="n" href="dbset_cachesize.html">Next</a></td>
214 </tr>
215 <tr>
216 <td width="40%" align="left" valign="top">DB-&gt;set_bt_minkey() </td>
217 <td width="20%" align="center">
218 <a accesskey="h" href="index.html">Home</a>
219 </td>
220 <td width="40%" align="right" valign="top"> DB-&gt;set_cachesize()</td>
221 </tr>
222 </table>
223 </div>
224 </body>
225 </html>