File: struct_w_t___c_o_m_p_r_e_s_s_o_r.html

package info (click to toggle)
wiredtiger 3.2.1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 25,456 kB
  • sloc: ansic: 102,922; python: 52,573; sh: 6,915; java: 6,130; cpp: 2,311; makefile: 1,018; xml: 176
file content (216 lines) | stat: -rw-r--r-- 30,216 bytes parent folder | download
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!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: WT_COMPRESSOR Struct Reference</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="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</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">
   &#160;<span id="projectnumber">Version 3.2.1</span>
   </div>
   <div id="projectbrief"><!-- 3.2.1 --></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.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></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('struct_w_t___c_o_m_p_r_e_s_s_o_r.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="struct_w_t___c_o_m_p_r_e_s_s_o_r-members.html">List of all members</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">WT_COMPRESSOR Struct Reference<div class="ingroups"><a class="el" href="group__wt__ext.html">WiredTiger Extension API</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>The interface implemented by applications to provide custom compression.  
 <a href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a075294c61c5d29abd55fc4603afe431f"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f">compress</a> )(<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed)</td></tr>
<tr class="memdesc:a075294c61c5d29abd55fc4603afe431f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Callback to compress a chunk of data.  <a href="#a075294c61c5d29abd55fc4603afe431f">More...</a><br /></td></tr>
<tr class="separator:a075294c61c5d29abd55fc4603afe431f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a12e35ffbbe63b041c0571fb622b7f9da"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a12e35ffbbe63b041c0571fb622b7f9da">decompress</a> )(<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp)</td></tr>
<tr class="memdesc:a12e35ffbbe63b041c0571fb622b7f9da"><td class="mdescLeft">&#160;</td><td class="mdescRight">Callback to decompress a chunk of data.  <a href="#a12e35ffbbe63b041c0571fb622b7f9da">More...</a><br /></td></tr>
<tr class="separator:a12e35ffbbe63b041c0571fb622b7f9da"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8b72f263db4faea37d8362ebc4725990"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990">pre_size</a> )(<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, size_t *result_lenp)</td></tr>
<tr class="memdesc:a8b72f263db4faea37d8362ebc4725990"><td class="mdescLeft">&#160;</td><td class="mdescRight">Callback to size a destination buffer for compression.  <a href="#a8b72f263db4faea37d8362ebc4725990">More...</a><br /></td></tr>
<tr class="separator:a8b72f263db4faea37d8362ebc4725990"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad23cc1486dc4c0cc51835cfaecb01a33"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#ad23cc1486dc4c0cc51835cfaecb01a33">terminate</a> )(<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session)</td></tr>
<tr class="memdesc:ad23cc1486dc4c0cc51835cfaecb01a33"><td class="mdescLeft">&#160;</td><td class="mdescRight">If non-NULL, a callback performed when the database is closed.  <a href="#ad23cc1486dc4c0cc51835cfaecb01a33">More...</a><br /></td></tr>
<tr class="separator:ad23cc1486dc4c0cc51835cfaecb01a33"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The interface implemented by applications to provide custom compression. </p>
<p>Compressors must implement the <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html" title="The interface implemented by applications to provide custom compression. ">WT_COMPRESSOR</a> interface: the <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a> and <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a12e35ffbbe63b041c0571fb622b7f9da" title="Callback to decompress a chunk of data. ">WT_COMPRESSOR::decompress</a> callbacks must be specified, and <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a> is optional. To build your own compressor, use one of the compressors in <code>ext/compressors</code> as a template: <code>ext/nop_compress</code> is a simple compressor that passes through data unchanged, and is a reasonable starting point.</p>
<p>Applications register their implementation with WiredTiger by calling <a class="el" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#a4f26bfa799ae5e72b536ac93d6200783" title="Add a compression function. ">WT_CONNECTION::add_compressor</a>.</p>
<div class="fragment"><div class="line"><span class="comment">/* Local compressor structure. */</span></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div><div class="line">    <a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> compressor; <span class="comment">/* Must come first */</span></div><div class="line"></div><div class="line">    <a class="code" href="struct_w_t___e_x_t_e_n_s_i_o_n___a_p_i.html">WT_EXTENSION_API</a> *wt_api; <span class="comment">/* Extension API */</span></div><div class="line"></div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> nop_calls; <span class="comment">/* Count of calls */</span></div><div class="line"></div><div class="line">} NOP_COMPRESSOR;</div></div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * wiredtiger_extension_init --</span></div><div class="line"><span class="comment"> *     A simple shared library compression example.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keywordtype">int</span></div><div class="line"><a class="code" href="group__wt__ext.html#ga5ed14c916d5dcfe0e81aea9d9ccb7fe3">wiredtiger_extension_init</a>(<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html">WT_CONNECTION</a> *connection, <a class="code" href="group__wt__ext.html#ga6fa5797cf581d18dc843e07333a497e4">WT_CONFIG_ARG</a> *config)</div><div class="line">{</div><div class="line">    NOP_COMPRESSOR *nop_compressor;</div><div class="line">    <span class="keywordtype">int</span> ret;</div><div class="line"></div><div class="line">    (void)config; <span class="comment">/* Unused parameters */</span></div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> ((nop_compressor = calloc(1, <span class="keyword">sizeof</span>(NOP_COMPRESSOR))) == NULL)</div><div class="line">        <span class="keywordflow">return</span> (errno);</div><div class="line"></div><div class="line">    <span class="comment">/*</span></div><div class="line"><span class="comment">     * Allocate a local compressor structure, with a WT_COMPRESSOR structure</span></div><div class="line"><span class="comment">     * as the first field, allowing us to treat references to either type of</span></div><div class="line"><span class="comment">     * structure as a reference to the other type.</span></div><div class="line"><span class="comment">     *</span></div><div class="line"><span class="comment">     * Heap memory (not static), because it can support multiple databases.</span></div><div class="line"><span class="comment">     */</span></div><div class="line">    nop_compressor-&gt;compressor.compress = nop_compress;</div><div class="line">    nop_compressor-&gt;compressor.decompress = nop_decompress;</div><div class="line">    nop_compressor-&gt;compressor.pre_size = nop_pre_size;</div><div class="line">    nop_compressor-&gt;compressor.terminate = nop_terminate;</div><div class="line"></div><div class="line">    nop_compressor-&gt;wt_api = connection-&gt;<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#a99df5b3a17564eb5b3e4ec076590133d">get_extension_api</a>(connection);</div><div class="line"></div><div class="line">    <span class="comment">/* Load the compressor */</span></div><div class="line">    <span class="keywordflow">if</span> ((ret = connection-&gt;<a class="code" href="struct_w_t___c_o_n_n_e_c_t_i_o_n.html#a4f26bfa799ae5e72b536ac93d6200783">add_compressor</a>(</div><div class="line">           connection, <span class="stringliteral">&quot;nop&quot;</span>, (<a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *)nop_compressor, NULL)) == 0)</div><div class="line">        <span class="keywordflow">return</span> (0);</div><div class="line"></div><div class="line">    free(nop_compressor);</div><div class="line">    <span class="keywordflow">return</span> (ret);</div><div class="line">}</div></div><!-- fragment --></div><h2 class="groupheader">Member Data Documentation</h2>
<a id="a075294c61c5d29abd55fc4603afe431f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a075294c61c5d29abd55fc4603afe431f">&#9670;&nbsp;</a></span>compress</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* WT_COMPRESSOR::compress) (<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp, int *compression_failed)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Callback to compress a chunk of data. </p>
<p><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a> takes a source buffer and a destination buffer, by default of the same size. If the callback can compress the buffer to a smaller size in the destination, it does so, sets the <code>compression_failed</code> return to 0 and returns 0. If compression does not produce a smaller result, the callback sets the <code>compression_failed</code> return to 1 and returns 0. If another error occurs, it returns an errno or WiredTiger error code.</p>
<p>On entry, <code>src</code> will point to memory, with the length of the memory in <code>src_len</code>. After successful completion, the callback should return <code>0</code> and set <code>result_lenp</code> to the number of bytes required for the compressed representation.</p>
<p>On entry, <code>dst</code> points to the destination buffer with a length of <code>dst_len</code>. If the <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a> method is specified, the destination buffer will be at least the size returned by that method; otherwise, the destination buffer will be at least as large as the length of the data to compress.</p>
<p>If compression would not shrink the data or the <code>dst</code> buffer is not large enough to hold the compressed data, the callback should set <code>compression_failed</code> to a non-zero value and return 0.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">src</td><td>the data to compress </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">src_len</td><td>the length of the data to compress </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dst</td><td>the destination buffer </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dst_len</td><td>the length of the destination buffer </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">result_lenp</td><td>the length of the compressed data </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">compression_failed</td><td>non-zero if compression did not decrease the length of the data (compression may not have completed) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success, non-zero to indicate an error.</dd></dl>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * nop_compress --</span></div><div class="line"><span class="comment"> *     A simple compression example that passes data through unchanged.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span></div><div class="line">nop_compress(<a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, <span class="keywordtype">size_t</span> src_len,</div><div class="line">  uint8_t *dst, <span class="keywordtype">size_t</span> dst_len, <span class="keywordtype">size_t</span> *result_lenp, <span class="keywordtype">int</span> *compression_failed)</div><div class="line">{</div><div class="line">    NOP_COMPRESSOR *nop_compressor = (NOP_COMPRESSOR *)compressor;</div><div class="line"></div><div class="line">    (void)session; <span class="comment">/* Unused parameters */</span></div><div class="line"></div><div class="line">    ++nop_compressor-&gt;nop_calls; <span class="comment">/* Call count */</span></div><div class="line"></div><div class="line">    *compression_failed = 0;</div><div class="line">    <span class="keywordflow">if</span> (dst_len &lt; src_len) {</div><div class="line">        *compression_failed = 1;</div><div class="line">        <span class="keywordflow">return</span> (0);</div><div class="line">    }</div><div class="line"></div><div class="line">    memcpy(dst, src, src_len);</div><div class="line">    *result_lenp = src_len;</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> (0);</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
<a id="a12e35ffbbe63b041c0571fb622b7f9da"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12e35ffbbe63b041c0571fb622b7f9da">&#9670;&nbsp;</a></span>decompress</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* WT_COMPRESSOR::decompress) (<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, size_t *result_lenp)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Callback to decompress a chunk of data. </p>
<p><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a12e35ffbbe63b041c0571fb622b7f9da" title="Callback to decompress a chunk of data. ">WT_COMPRESSOR::decompress</a> takes a source buffer and a destination buffer. The contents are switched from <code>compress:</code> the source buffer is the compressed value, and the destination buffer is sized to be the original size. If the callback successfully decompresses the source buffer to the destination buffer, it returns 0. If an error occurs, it returns an errno or WiredTiger error code. The source buffer that <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a12e35ffbbe63b041c0571fb622b7f9da" title="Callback to decompress a chunk of data. ">WT_COMPRESSOR::decompress</a> takes may have a size that is rounded up from the size originally produced by <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a>, with the remainder of the buffer set to zeroes. Most compressors do not care about this difference if the size to be decompressed can be implicitly discovered from the compressed data. If your compressor cares, you may need to allocate space for, and store, the actual size in the compressed buffer. See the source code for the included snappy compressor for an example.</p>
<p>On entry, <code>src</code> will point to memory, with the length of the memory in <code>src_len</code>. After successful completion, the callback should return <code>0</code> and set <code>result_lenp</code> to the number of bytes required for the decompressed representation.</p>
<p>If the <code>dst</code> buffer is not big enough to hold the decompressed data, the callback should return an error.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">src</td><td>the data to decompress </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">src_len</td><td>the length of the data to decompress </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dst</td><td>the destination buffer </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dst_len</td><td>the length of the destination buffer </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">result_lenp</td><td>the length of the decompressed data </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success, non-zero to indicate an error.</dd></dl>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * nop_decompress --</span></div><div class="line"><span class="comment"> *     A simple decompression example that passes data through unchanged.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span></div><div class="line">nop_decompress(<a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, <span class="keywordtype">size_t</span> src_len,</div><div class="line">  uint8_t *dst, <span class="keywordtype">size_t</span> dst_len, <span class="keywordtype">size_t</span> *result_lenp)</div><div class="line">{</div><div class="line">    NOP_COMPRESSOR *nop_compressor = (NOP_COMPRESSOR *)compressor;</div><div class="line"></div><div class="line">    (void)session; <span class="comment">/* Unused parameters */</span></div><div class="line">    (void)src_len;</div><div class="line"></div><div class="line">    ++nop_compressor-&gt;nop_calls; <span class="comment">/* Call count */</span></div><div class="line"></div><div class="line">    <span class="comment">/*</span></div><div class="line"><span class="comment">     * The destination length is the number of uncompressed bytes we&#39;re expected to return.</span></div><div class="line"><span class="comment">     */</span></div><div class="line">    memcpy(dst, src, dst_len);</div><div class="line">    *result_lenp = dst_len;</div><div class="line">    <span class="keywordflow">return</span> (0);</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
<a id="a8b72f263db4faea37d8362ebc4725990"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8b72f263db4faea37d8362ebc4725990">&#9670;&nbsp;</a></span>pre_size</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* WT_COMPRESSOR::pre_size) (<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, size_t src_len, size_t *result_lenp)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Callback to size a destination buffer for compression. </p>
<p><a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a> is an optional callback that, given the source buffer and size, produces the size of the destination buffer to be given to <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a>. This is useful for compressors that assume that the output buffer is sized for the worst case and thus no overrun checks are made. If your compressor works like this, <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a> will need to be defined. See the source code for the snappy compressor for an example. However, if your compressor detects and avoids overruns against its target buffer, you will not need to define <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a>. When <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a8b72f263db4faea37d8362ebc4725990" title="Callback to size a destination buffer for compression. ">WT_COMPRESSOR::pre_size</a> is set to NULL, the destination buffer is sized the same as the source buffer. This is always sufficient, since a compression result that is larger than the source buffer is discarded by WiredTiger.</p>
<p>If not NULL, this callback is called before each call to <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a> to determine the size of the destination buffer to provide. If the callback is NULL, the destination buffer will be the same size as the source buffer.</p>
<p>The callback should set <code>result_lenp</code> to a suitable buffer size for compression, typically the maximum length required by <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#a075294c61c5d29abd55fc4603afe431f" title="Callback to compress a chunk of data. ">WT_COMPRESSOR::compress</a>.</p>
<p>This callback function is for compressors that require an output buffer larger than the source buffer (for example, that do not check for buffer overflow during compression).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">src</td><td>the data to compress </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">src_len</td><td>the length of the data to compress </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">result_lenp</td><td>the required destination buffer size </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success, non-zero to indicate an error.</dd></dl>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * nop_pre_size --</span></div><div class="line"><span class="comment"> *     A simple pre-size example that returns the source length.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span></div><div class="line">nop_pre_size(</div><div class="line">  <a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session, uint8_t *src, <span class="keywordtype">size_t</span> src_len, <span class="keywordtype">size_t</span> *result_lenp)</div><div class="line">{</div><div class="line">    NOP_COMPRESSOR *nop_compressor = (NOP_COMPRESSOR *)compressor;</div><div class="line"></div><div class="line">    (void)session; <span class="comment">/* Unused parameters */</span></div><div class="line">    (void)src;</div><div class="line"></div><div class="line">    ++nop_compressor-&gt;nop_calls; <span class="comment">/* Call count */</span></div><div class="line"></div><div class="line">    *result_lenp = src_len;</div><div class="line">    <span class="keywordflow">return</span> (0);</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
<a id="ad23cc1486dc4c0cc51835cfaecb01a33"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad23cc1486dc4c0cc51835cfaecb01a33">&#9670;&nbsp;</a></span>terminate</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* WT_COMPRESSOR::terminate) (<a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="el" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>If non-NULL, a callback performed when the database is closed. </p>
<p>The <a class="el" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html#ad23cc1486dc4c0cc51835cfaecb01a33" title="If non-NULL, a callback performed when the database is closed. ">WT_COMPRESSOR::terminate</a> callback is intended to allow cleanup, the handle will not be subsequently accessed by WiredTiger.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * nop_terminate --</span></div><div class="line"><span class="comment"> *     WiredTiger no-op compression termination.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span></div><div class="line">nop_terminate(<a class="code" href="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a> *compressor, <a class="code" href="struct_w_t___s_e_s_s_i_o_n.html">WT_SESSION</a> *session)</div><div class="line">{</div><div class="line">    NOP_COMPRESSOR *nop_compressor = (NOP_COMPRESSOR *)compressor;</div><div class="line"></div><div class="line">    (void)session; <span class="comment">/* Unused parameters */</span></div><div class="line"></div><div class="line">    ++nop_compressor-&gt;nop_calls; <span class="comment">/* Call count */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Free the allocated memory. */</span></div><div class="line">    free(compressor);</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> (0);</div><div class="line">}</div></div><!-- fragment -->
</div>
</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="struct_w_t___c_o_m_p_r_e_s_s_o_r.html">WT_COMPRESSOR</a></li>
    <li class="footer">Copyright (c) 2008-2019 MongoDB, Inc.  All rights reserved.  Contact <a href="mailto:info@wiredtiger.com">info@wiredtiger.com</a> for more information.</li>
  </ul>
</div>
</body>
</html>