~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/docs/ref/am_conf/bt_recnum.html

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!--$Id$-->
2
 
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
 
<!--All rights reserved.-->
4
 
<!--See the file LICENSE for redistribution information.-->
5
 
<html>
6
 
<head>
7
 
<title>Berkeley DB Reference Guide: Retrieving Btree records by logical record number</title>
8
 
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
 
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
10
 
</head>
11
 
<body bgcolor=white>
12
 
<a name="2"><!--meow--></a><a name="3"><!--meow--></a>
13
 
<table width="100%"><tr valign=top>
14
 
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Access Methods</dl></h3></td>
15
 
<td align=right><a href="../../ref/am_conf/bt_minkey.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/am_conf/h_ffactor.html"><img src="../../images/next.gif" alt="Next"></a>
16
 
</td></tr></table>
17
 
<p>
18
 
<h1 align=center>Retrieving Btree records by logical record number</h1>
19
 
<p>The Btree access method optionally supports retrieval by logical record
20
 
numbers.  To configure a Btree to support record numbers, call the
21
 
<a href="../../api_c/db_set_flags.html">DB-&gt;set_flags</a> method with the <a href="../../api_c/db_set_flags.html#DB_RECNUM">DB_RECNUM</a> flag.
22
 
<p>Configuring a Btree for record numbers should not be done lightly.
23
 
While often useful, it may significantly slow down the speed at which
24
 
items can be stored into the database, and can severely impact
25
 
application throughput.  Generally it should be avoided in trees with
26
 
a need for high write concurrency.
27
 
<p>To retrieve by record number, use the <a href="../../api_c/db_get.html#DB_SET_RECNO">DB_SET_RECNO</a> flag to the
28
 
<a href="../../api_c/db_get.html">DB-&gt;get</a> and <a href="../../api_c/dbc_get.html">DBcursor-&gt;c_get</a> methods.  The following is an example of
29
 
a routine that displays the data item for a Btree database created with
30
 
the <a href="../../api_c/db_set_flags.html#DB_RECNUM">DB_RECNUM</a> option.
31
 
<p><blockquote><pre>int
32
 
rec_display(dbp, recno)
33
 
        DB *dbp;
34
 
        db_recno_t recno;
35
 
{
36
 
        DBT key, data;
37
 
        int ret;
38
 
<p>
39
 
        memset(&key, 0, sizeof(key));
40
 
        key.data = &recno;
41
 
        key.size = sizeof(recno);
42
 
        memset(&data, 0, sizeof(data));
43
 
<p>
44
 
        if ((ret = dbp-&gt;get(dbp, NULL, &key, &data, DB_SET_RECNO)) != 0)
45
 
                return (ret);
46
 
        printf("data for %lu: %.*s\n",
47
 
            (u_long)recno, (int)data.size, (char *)data.data);
48
 
        return (0);
49
 
}</pre></blockquote>
50
 
<p>To determine a key's record number, use the <a href="../../api_c/dbc_get.html#DB_GET_RECNO">DB_GET_RECNO</a> flag
51
 
to the <a href="../../api_c/dbc_get.html">DBcursor-&gt;c_get</a> method.  The following is an example of a routine that
52
 
displays the record number associated with a specific key.
53
 
<p><blockquote><pre>int
54
 
recno_display(dbp, keyvalue)
55
 
        DB *dbp;
56
 
        char *keyvalue;
57
 
{
58
 
        DBC *dbcp;
59
 
        DBT key, data;
60
 
        db_recno_t recno;
61
 
        int ret, t_ret;
62
 
<p>
63
 
        /* Acquire a cursor for the database. */
64
 
        if ((ret = dbp-&gt;cursor(dbp, NULL, &dbcp, 0)) != 0) {
65
 
                dbp-&gt;err(dbp, ret, "DB-&gt;cursor");
66
 
                goto err;
67
 
        }
68
 
<p>
69
 
        /* Position the cursor. */
70
 
        memset(&key, 0, sizeof(key));
71
 
        key.data = keyvalue;
72
 
        key.size = strlen(keyvalue);
73
 
        memset(&data, 0, sizeof(data));
74
 
        if ((ret = dbcp-&gt;c_get(dbcp, &key, &data, DB_SET)) != 0) {
75
 
                dbp-&gt;err(dbp, ret, "DBC-&gt;c_get(DB_SET): %s", keyvalue);
76
 
                goto err;
77
 
        }
78
 
<p>
79
 
        /*
80
 
         * Request the record number, and store it into appropriately
81
 
         * sized and aligned local memory.
82
 
         */
83
 
        memset(&data, 0, sizeof(data));
84
 
        data.data = &recno;
85
 
        data.ulen = sizeof(recno);
86
 
        data.flags = DB_DBT_USERMEM;
87
 
        if ((ret = dbcp-&gt;c_get(dbcp, &key, &data, DB_GET_RECNO)) != 0) {
88
 
                dbp-&gt;err(dbp, ret, "DBC-&gt;c_get(DB_GET_RECNO)");
89
 
                goto err;
90
 
        }
91
 
<p>
92
 
        printf("key for requested key was %lu\n", (u_long)recno);
93
 
<p>
94
 
err:    /* Close the cursor. */
95
 
        if ((t_ret = dbcp-&gt;c_close(dbcp)) != 0) {
96
 
                if (ret == 0)
97
 
                        ret = t_ret;
98
 
                dbp-&gt;err(dbp, ret, "DBC-&gt;close");
99
 
        }
100
 
        return (ret);
101
 
}</pre></blockquote>
102
 
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/am_conf/bt_minkey.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/am_conf/h_ffactor.html"><img src="../../images/next.gif" alt="Next"></a>
103
 
</td></tr></table>
104
 
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
105
 
</body>
106
 
</html>