-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdata_sources.html
170 lines (170 loc) · 14 KB
/
data_sources.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!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/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>WiredTiger: Data Sources</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="wiredtiger.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><a href="http://wiredtiger.com/"><img alt="Logo" src="LogoFinal-header.png" alt="WiredTiger" /></a></td>
<td style="padding-left: 0.5em;">
<div id="projectname">
 <span id="projectnumber">Version 1.5.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="banner">
<a href="https://github.com/wiredtiger/wiredtiger">Fork me on GitHub</a>
<a class="last" href="http://groups.google.com/group/wiredtiger-users">Join my user group</a>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li><a href="community.html"><span>Community</span></a></li>
<li><a href="license.html"><span>License</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('data_sources.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">Data Sources </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>WiredTiger provides access to data from a variety of sources.</p>
<p>At the lowest level, data may be stored in a file using a tree structure. A relational schema supporting tables, indices and column groups is layered on top of file. Additional sources include LSM trees and statistics, and applications can further extend the supported types by implementing the <a class="el" href="struct_w_t___d_a_t_a___s_o_u_r_c_e.html" title="Applications can extend WiredTiger by providing new implementations of the WT_DATA_SOURCE class...">WT_DATA_SOURCE</a> interface.</p>
<p>Common operations on all data sources are performed using <a class="el" href="struct_w_t___c_u_r_s_o_r.html" title="A WT_CURSOR handle is the interface to a cursor.">WT_CURSOR</a> handles. See <a class="el" href="cursor_ops.html">Cursor operations</a> for a description of how to use cursors.</p>
<h1><a class="anchor" id="data_builtin"></a>
Builtin data sources</h1>
<p>The following are the builtin cursor types:</p>
<table class="doxtable">
<tr>
<th>URI</th><th>Type</th><th>Notes </th></tr>
<tr>
<td><code>backup:</code></td><td>hot backup cursor</td><td>See also: <a class="el" href="hot_backup.html">Hot backup</a> </td></tr>
<tr>
<td><code>colgroup:<table name>:<column group name></code></td><td>column group cursor</td><td></td></tr>
<tr>
<td><code>config:[<uri>]</code></td><td>object configuration cursor (key=config string, value=config value)</td><td></td></tr>
<tr>
<td><code>file:<file name></code></td><td>file cursor (key=file key, value=file value)</td><td></td></tr>
<tr>
<td><code>index:<table name>:<index name></code></td><td>index cursor (key=index key, value=table value)</td><td></td></tr>
<tr>
<td><code>join:<cursor1>&<cursor2>[&<cursor3>...]</code></td><td>join cursor</td><td><p class="starttd"><b>Not yet supported in WiredTiger.</b> </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td><code>lsm:<name></code></td><td>LSM cursor (key=LSM key, value=LSM value)</td><td>See also: <a class="el" href="lsm.html">Log-Structured Merge Trees</a> </td></tr>
<tr>
<td><code>statistics:[<data source URI>]</code></td><td>database or data source statistics (key=(int), value=(string)description, (string)value, (uint64_t)value)</td><td></td></tr>
<tr>
<td><code>table:<table name></code></td><td>table cursor (key=table key, value=table value)</td><td></td></tr>
</table>
<h2><a class="anchor" id="data_files"></a>
Raw Files</h2>
<p>WiredTiger's schema layer can be bypassed by opening cursors with a <code>"file:"</code> URI, using the name of the underlying file. This can be useful for seeing the contents of a column group or index without reading all of the columns from the table.</p>
<p>For example, if an index becomes inconsistent with its primary, a file cursor can read from the index without errors (even though some of the keys that are returned may not exist in the primary).</p>
<h2><a class="anchor" id="data_indices"></a>
Table Index data</h2>
<p>When an index is created for a table, records are inserted into the index whenever the table is updated. These records use a different key to the primary table, as specified when the index is created with the <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb" title="Create a table, column group, index or file.">WT_SESSION::create</a> method.</p>
<p>A cursor opened on an index has the specified index columns as its key, accessed by <a class="el" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc" title="Set the key for the next operation.">WT_CURSOR::set_key</a> and <a class="el" href="struct_w_t___c_u_r_s_o_r.html#af19f6f9d9c7fc248ab38879032620b2f" title="Get the key for the current record.">WT_CURSOR::get_key</a>. The value columns default to returning the value columns from the table, but this can be overridden by configuring a projection cursor (see <a class="el" href="cursors.html#cursor_projections">Projections</a>), which can access the table key columns or a subset of the value columns.</p>
<h2><a class="anchor" id="data_statistics"></a>
Statistics Data</h2>
<p>Statistics cursors can be used to retrieve run-time statistics about a WiredTiger database as well as statistics for individual data sources. The statistics are at two levels: per-database and per-individual data source. Database-wide statistics are retrieved with the <code>"statistics:"</code> URI; individual data source statistics are available by specifying <code>"statistics:<data source URI>"</code>.</p>
<p>The statistic key is an integer from the list of keys in <a class="el" href="group__wt.html#statistics_keys">Statistics Keys</a>. Statistics cursors return three values from the <a class="el" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01" title="Get the value for the current record.">WT_CURSOR::get_value</a> call: a printable description of the statistic, a printable version of the entry's value, and the entry's unsigned 64-bit integral value, respectively.</p>
<p>The following is an example of printing run-time statistics about the WiredTiger engine:</p>
<div class="fragment"><div class="line"> <span class="keywordflow">if</span> ((ret = session-><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d" title="Open a new cursor on a data source or duplicate an existing cursor.">open_cursor</a>(session,</div>
<div class="line"> <span class="stringliteral">"statistics:"</span>, NULL, NULL, &cursor)) != 0)</div>
<div class="line"> <span class="keywordflow">return</span> (ret);</div>
<div class="line"></div>
<div class="line"> ret = print_cursor(cursor);</div>
<div class="line"> ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b" title="Close the cursor.">close</a>(cursor);</div>
</div><!-- fragment --><p> The following is an example of printing statistics about a table:</p>
<div class="fragment"><div class="line"> <span class="keywordflow">if</span> ((ret = session-><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d" title="Open a new cursor on a data source or duplicate an existing cursor.">open_cursor</a>(session,</div>
<div class="line"> <span class="stringliteral">"statistics:table:access"</span>, NULL, NULL, &cursor)) != 0)</div>
<div class="line"> <span class="keywordflow">return</span> (ret);</div>
<div class="line"></div>
<div class="line"> ret = print_cursor(cursor);</div>
<div class="line"> ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b" title="Close the cursor.">close</a>(cursor);</div>
</div><!-- fragment --><p> Both examples can use a common display routine that iterates through the statistics until the cursor returns the end of the list.</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span></div>
<div class="line">print_cursor(<a class="code" href="struct_w_t___c_u_r_s_o_r.html" title="A WT_CURSOR handle is the interface to a cursor.">WT_CURSOR</a> *cursor)</div>
<div class="line">{</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *desc, *pvalue;</div>
<div class="line"> uint64_t value;</div>
<div class="line"> <span class="keywordtype">int</span> ret;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">while</span> ((ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a0503f16bd8f3d05aa3552f229b3a8e1b" title="Return the next record.">next</a>(cursor)) == 0 &&</div>
<div class="line"> (ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01" title="Get the value for the current record.">get_value</a>(cursor, &desc, &pvalue, &value)) == 0)</div>
<div class="line"> <span class="keywordflow">if</span> (value != 0)</div>
<div class="line"> printf(<span class="stringliteral">"%s=%s\n"</span>, desc, pvalue);</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> (ret == <a class="code" href="group__wt.html#ga3c9e1b494d95cf34404ab7a974af6bf8" title="Cursor item not found.">WT_NOTFOUND</a> ? 0 : ret);</div>
<div class="line">}</div>
</div><!-- fragment --><p> Individual statistics values can be retrieved by searching for the corresponding key, as shown in the following example:</p>
<div class="fragment"><div class="line"> <a class="code" href="struct_w_t___c_u_r_s_o_r.html" title="A WT_CURSOR handle is the interface to a cursor.">WT_CURSOR</a> *cursor;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *desc, *pvalue;</div>
<div class="line"> uint64_t value;</div>
<div class="line"> <span class="keywordtype">int</span> ret;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> ((ret = session-><a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#afb5b4a69c2c5cafe411b2b04fdc1c75d" title="Open a new cursor on a data source or duplicate an existing cursor.">open_cursor</a>(session,</div>
<div class="line"> <span class="stringliteral">"statistics:table:access"</span>, NULL, NULL, &cursor)) != 0)</div>
<div class="line"> <span class="keywordflow">return</span> (ret);</div>
<div class="line"></div>
<div class="line"> cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc" title="Set the key for the next operation.">set_key</a>(cursor, <a class="code" href="group__wt.html#ga079f2d70ac0826f54e36b8535d7194e5" title="overflow pages">WT_STAT_DSRC_BTREE_OVERFLOW</a>);</div>
<div class="line"> ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a7e25b2ced2cf3ec68bd5429bf921c79f" title="Move to the record matching the key.">search</a>(cursor);</div>
<div class="line"> ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01" title="Get the value for the current record.">get_value</a>(cursor, &desc, &pvalue, &value);</div>
<div class="line"> printf(<span class="stringliteral">"%s=%s\n"</span>, desc, pvalue);</div>
<div class="line"></div>
<div class="line"> ret = cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#aeea071f192cab12245a50fbe71c3460b" title="Close the cursor.">close</a>(cursor);</div>
</div><!-- fragment --><p> See <a class="el" href="tuning.html#tuning_statistics">Performance monitoring with statistics</a> for more examples of how statistics can be used. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="index.html">Reference Guide</a></li><li class="navelem"><a class="el" href="programming.html">Writing WiredTiger applications</a></li><li class="navelem"><a class="el" href="cursors.html">Cursors</a></li>
<li class="footer">Copyright (c) 2008-2013 WiredTiger, Inc. All rights reserved. Contact <a href="mailto:[email protected]">[email protected]</a> for more information.</li>
</ul>
</div>
</body>
</html>