Debian Codegraph @

docs/api_reference/CXX/dbkey_range.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::key_range()</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="dbjoin.html" title="Db::join()" />
12 <link rel="next" href="dbopen.html" title="Db::open()" />
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::key_range()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbjoin.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="dbopen.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="dbkey_range"></a>Db::key_range()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 Db::key_range(DbTxn *txnid
45 Dbt *key, DB_KEY_RANGE *key_range, u_int32_t flags);</pre>
46 <p>
47 The <code class="methodname">Db::key_range()</code> method returns an estimate of the proportion of
48 keys that are less than, equal to, and greater than the specified key.
49 The underlying database must be of type Btree.
50 </p>
51 <p>
52 The <code class="methodname">Db::key_range()</code> method fills in a structure of type DB_KEY_RANGE.
53 The following data fields are available from the DB_KEY_RANGE
54 structure:
55 </p>
56 <div class="itemizedlist">
57 <ul type="disc">
58 <li>
59 <p>
60 <span class="bold"><strong>double less;</strong></span>
61 </p>
62 <p>
63 A value between 0 and 1, the proportion of keys less than the
64 specified key.
65 </p>
66 </li>
67 <li>
68 <p>
69 <span class="bold"><strong>double equal;</strong></span>
70 </p>
71 <p>
72 A value between 0 and 1, the proportion of keys equal to the specified
73 key.
74 </p>
75 </li>
76 <li>
77 <p>
78 <span class="bold"><strong>double greater;</strong></span>
79 </p>
80 <p>
81 A value between 0 and 1, the proportion of keys greater than the
82 specified key.
83 </p>
84 </li>
85 </ul>
86 </div>
87 <p>
88 Values are in the range of 0 to 1; for example, if the field <span class="bold"><strong>less</strong></span> is 0.05, 5% of the keys in the database
89 are less than the <span class="bold"><strong>key</strong></span> parameter. The
90 value for <span class="bold"><strong>equal</strong></span> will be zero if there
91 is no matching key, and will be non-zero otherwise.
92 </p>
93 <p>
94 The <code class="methodname">Db::key_range()</code> <span>
95
96 <span>
97 method either returns a non-zero error value or throws an
98 exception that encapsulates a non-zero error value on
99 failure, and returns 0 on success.
100 </span>
101 </span>
102 </p>
103 <div class="sect2" lang="en" xml:lang="en">
104 <div class="titlepage">
105 <div>
106 <div>
107 <h3 class="title"><a id="idp4348880"></a>Parameters</h3>
108 </div>
109 </div>
110 </div>
111 <div class="sect3" lang="en" xml:lang="en">
112 <div class="titlepage">
113 <div>
114 <div>
115 <h4 class="title"><a id="idp4181136"></a>txnid</h4>
116 </div>
117 </div>
118 </div>
119 <p>
120 If the operation is part of an application-specified transaction, the
121 <span class="bold"><strong>txnid</strong></span> parameter is a transaction
122 handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>;
123 if the operation is part of a Berkeley DB Concurrent Data Store group, the
124 <span class="bold"><strong>txnid</strong></span> parameter is a handle returned
125 from <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a>;
126 otherwise NULL. If no transaction handle is specified, but the
127 operation occurs in a transactional database, the operation will be
128 implicitly transaction protected. The <code class="methodname">Db::key_range()</code> method does not
129 retain the locks it acquires for the life of the transaction, so
130 estimates may not be repeatable.
131 </p>
132 </div>
133 <div class="sect3" lang="en" xml:lang="en">
134 <div class="titlepage">
135 <div>
136 <div>
137 <h4 class="title"><a id="idp2325976"></a>key</h4>
138 </div>
139 </div>
140 </div>
141 <p>
142 The key <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> operated on.
143 </p>
144 </div>
145 <div class="sect3" lang="en" xml:lang="en">
146 <div class="titlepage">
147 <div>
148 <div>
149 <h4 class="title"><a id="idp954240"></a>key_range</h4>
150 </div>
151 </div>
152 </div>
153 <p>
154 The estimates are returned in the <span class="bold"><strong>key_range</strong></span> parameter, which contains three
155 elements of type double: <span class="bold"><strong>less</strong></span>,
156 <span class="bold"><strong>equal</strong></span>, and <span class="bold"><strong>greater</strong></span>. Values are in the range of 0 to 1;
157 for example, if the field <span class="bold"><strong>less</strong></span> is
158 0.05, 5% of the keys in the database are less than the <span class="bold"><strong>key</strong></span> parameter. The value for <span class="bold"><strong>equal</strong></span> will be zero if there is no matching key,
159 and will be non-zero otherwise.
160 </p>
161 </div>
162 <div class="sect3" lang="en" xml:lang="en">
163 <div class="titlepage">
164 <div>
165 <div>
166 <h4 class="title"><a id="idp3709320"></a>flags</h4>
167 </div>
168 </div>
169 </div>
170 <p>
171 The <span class="bold"><strong>flags</strong></span> parameter is currently
172 unused, and must be set to 0.
173 </p>
174 </div>
175 </div>
176 <div class="sect2" lang="en" xml:lang="en">
177 <div class="titlepage">
178 <div>
179 <div>
180 <h3 class="title"><a id="idp1564392"></a>Errors</h3>
181 </div>
182 </div>
183 </div>
184 <p>
185 The <code class="methodname">Db::key_range()</code> <span>
186
187 <span>
188 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
189 exception, encapsulating one of the following non-zero errors, or return one
190 of the following non-zero errors:
191 </span>
192 </span>
193 </p>
194 <div class="sect3" lang="en" xml:lang="en">
195 <div class="titlepage">
196 <div>
197 <div>
198 <h4 class="title"><a id="idm181264"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
199 </div>
200 </div>
201 </div>
202 <p>
203 A transactional database environment operation was selected to resolve
204 a deadlock.
205 </p>
206 <p>
207 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
208 your Berkeley DB API is configured to throw exceptions.
209 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
210 </p>
211 </div>
212 <div class="sect3" lang="en" xml:lang="en">
213 <div class="titlepage">
214 <div>
215 <div>
216 <h4 class="title"><a id="idm1852320"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
217 </div>
218 </div>
219 </div>
220 <p>
221 A Berkeley DB Concurrent Data Store database environment configured
222 for lock timeouts was unable to grant a lock in the allowed time.
223 </p>
224 <p>
225 You attempted to open a database handle that is configured
226 for no waiting exclusive locking, but the exclusive lock could not be
227 immediately obtained. See
228 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
229 for more information.
230 </p>
231 <p>
232 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
233 your Berkeley DB API is configured to throw exceptions.
234 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
235 </p>
236 </div>
237 <div class="sect3" lang="en" xml:lang="en">
238 <div class="titlepage">
239 <div>
240 <div>
241 <h4 class="title"><a id="idp3420832"></a> <span>DbRepHandleDeadException or</span> DB_REP_HANDLE_DEAD</h4>
242 </div>
243 </div>
244 </div>
245 <p>
246 When a client synchronizes with the master, it is possible for committed
247 transactions to be rolled back. This invalidates all the database and cursor
248 handles opened in the replication environment. Once this occurs, an attempt to use
249 such a handle will
250 <span>
251 throw a <a class="xref" href="dbrephandledead.html" title="DbRepHandleDeadException">DbRepHandleDeadException</a> (if
252 your application is configured to throw exceptions), or
253 </span>
254 return <code class="literal">DB_REP_HANDLE_DEAD</code>.
255 The application will need to discard the handle and open a new one in order to
256 continue processing.
257 </p>
258 </div>
259 <div class="sect3" lang="en" xml:lang="en">
260 <div class="titlepage">
261 <div>
262 <div>
263 <h4 class="title"><a id="idp1167312"></a><span>DbDeadlockException or </span>DB_REP_LOCKOUT</h4>
264 </div>
265 </div>
266 </div>
267 <p>
268 The operation was blocked by client/master synchronization.
269 </p>
270 <p>
271 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
272 your Berkeley DB API is configured to throw exceptions.
273 Otherwise, <code class="literal">DB_REP_LOCKOUT</code> is returned.
274 </p>
275 </div>
276 <div class="sect3" lang="en" xml:lang="en">
277 <div class="titlepage">
278 <div>
279 <div>
280 <h4 class="title"><a id="idm607752"></a>EINVAL</h4>
281 </div>
282 </div>
283 </div>
284 <p>
285 If the underlying database was not of type Btree; or if an invalid
286 flag value or parameter was specified.
287 </p>
288 </div>
289 </div>
290 <div class="sect2" lang="en" xml:lang="en">
291 <div class="titlepage">
292 <div>
293 <div>
294 <h3 class="title"><a id="idp4214024"></a>Class</h3>
295 </div>
296 </div>
297 </div>
298 <p>
299 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
300 </p>
301 </div>
302 <div class="sect2" lang="en" xml:lang="en">
303 <div class="titlepage">
304 <div>
305 <div>
306 <h3 class="title"><a id="idp1259904"></a>See Also</h3>
307 </div>
308 </div>
309 </div>
310 <p>
311 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
312 </p>
313 </div>
314 </div>
315 <div class="navfooter">
316 <hr />
317 <table width="100%" summary="Navigation footer">
318 <tr>
319 <td width="40%" align="left"><a accesskey="p" href="dbjoin.html">Prev</a> </td>
320 <td width="20%" align="center">
321 <a accesskey="u" href="db.html">Up</a>
322 </td>
323 <td width="40%" align="right"> <a accesskey="n" href="dbopen.html">Next</a></td>
324 </tr>
325 <tr>
326 <td width="40%" align="left" valign="top">Db::join() </td>
327 <td width="20%" align="center">
328 <a accesskey="h" href="index.html">Home</a>
329 </td>
330 <td width="40%" align="right" valign="top"> Db::open()</td>
331 </tr>
332 </table>
333 </div>
334 </body>
335 </html>