Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > a00abf5f94bf470fd4cc9e10b2d135e0 > files > 503

lib64db4.8-devel-4.8.26-1mdv2010.1.x86_64.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Db::set_partition()</title>
    <link rel="stylesheet" href="apiReference.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
    <link rel="up" href="db.html" title="Chapter 2.  The Db Handle" />
    <link rel="prev" href="dbset_pagesize.html" title="Db::set_pagesize()" />
    <link rel="next" href="dbset_partition_dirs.html" title="Db::set_partition_dirs()" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Db::set_partition()</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dbset_pagesize.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 2. 
                The Db Handle
        </th>
          <td width="20%" align="right"> <a accesskey="n" href="dbset_partition_dirs.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="dbset_partition"></a>Db::set_partition()</h2>
          </div>
        </div>
      </div>
      <pre class="programlisting">#include &lt;db_cxx.h&gt;
 
int
Db::set_partition(u_int32_t parts, DBT *kyes,
	u_int32_t (*db_partition_fcn) (Db *db, DBT *key));</pre>
      <p>
		Set up partitioning for a database.  Partitioning may be used on either BTREE or HASH databases.
		Partitions may be specified by either a set of keys specifying a range of values in each partition
		or with a callback function that returns the number of the partition to put a specific key.
		Partition range keys may only be specified for BTREE databases.
	</p>
      <p>
		Partitions are implimented as separate database files and can help reduce contention within a logical
		database.  Contention can come from multiple threads of control accessing database pages simultaniously.
		Typically these pages are the root of a btree and the metadata page which contains allocation information
		in both BTREE and HASH databases.  Each partition has its own metadata and root pages.
	</p>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="id1649821"></a>Parameters</h3>
            </div>
          </div>
        </div>
        <p>
                Exactly one of the parameters 
                <span class="bold"><strong>keys</strong></span> and 
                <span class="bold"><strong>partition_fcn</strong></span> must be NULL.
            </p>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="id1649959"></a>parts</h4>
              </div>
            </div>
          </div>
          <p>
                The <span class="bold"><strong>parts</strong></span> parameter is the number of partitions to create.
		The value must be 2 or greater.
	    </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="id1649956"></a>keys</h4>
              </div>
            </div>
          </div>
          <p>
                The <span class="bold"><strong>keys</strong></span> parameter is an
                array of DBT structures containing the keys that specify
                the range of key values to be stored in each partition.
                Each key specifies the minimum value that may be stored in
                the corresponding partition.  The number of keys must be
                one less than the number of partitions specified by the
                <span class="bold"><strong>parts</strong></span> parameter since the
                first partition will hold any key less than the first key
                in the array.
	    </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <div class="titlepage">
            <div>
              <div>
                <h4 class="title"><a id="id1650185"></a>db_partition_fcn</h4>
              </div>
            </div>
          </div>
          <p>
                The <span class="bold"><strong>db_partition_fcn</strong></span>
                parameter is the application-specified partitioning
                function.  The function returns an integer which will be
                used modulo the number of partitions specified by the 
                <span class="bold"><strong>parts</strong></span> parameter.  
                The function will be called with two parameters:
            </p>
          <div class="itemizedlist">
            <ul type="disc">
              <li>
                <p>
                        <code class="literal">db</code>
                    </p>
                <p>
                         The <span class="bold"><strong>db</strong></span> parameter is the database handle.
                    </p>
              </li>
              <li>
                <p>
                        <code class="literal">key</code>
                    </p>
                <p>
                         The <span class="bold"><strong>key</strong></span> parameter
                         is the key for which a partition number should be
                         returned.
                    </p>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="id1650473"></a>Class</h3>
            </div>
          </div>
        </div>
        <p>
                <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>  
            </p>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="id1650482"></a>See Also</h3>
            </div>
          </div>
        </div>
        <p>
                     <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
                </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dbset_pagesize.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="db.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="dbset_partition_dirs.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Db::set_pagesize() </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Db::set_partition_dirs()</td>
        </tr>
      </table>
    </div>
  </body>
</html>