2011-09-13 17:44:24 +00:00
|
|
|
|
<?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 xmlns="" class="navheader">
|
|
|
|
|
<div class="libver">
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<p>Library Version 11.2.5.3</p>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</div>
|
|
|
|
|
<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 <db.h>
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
DB->set_partition(DB * db, u_int32_t parts, DBT *keys,
|
|
|
|
|
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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h3 class="title"><a id="idp58470008"></a>Parameters</h3>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h4 class="title"><a id="idp58489904"></a>parts</h4>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h4 class="title"><a id="idp58458096"></a>keys</h4>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h4 class="title"><a id="idp58480440"></a>db_partition_fcn</h4>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h3 class="title"><a id="idp58494264"></a>Class</h3>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|
2012-11-14 21:35:20 +00:00
|
|
|
|
<h3 class="title"><a id="idp58488664"></a>See Also</h3>
|
2011-09-13 17:44:24 +00:00
|
|
|
|
</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>
|