File: compression.html

package info (click to toggle)
wiredtiger 3.1.0%2Bds-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 23,708 kB
  • sloc: ansic: 103,581; python: 46,767; sh: 6,669; java: 6,055; cpp: 2,016; makefile: 1,007; xml: 176
file content (114 lines) | stat: -rw-r--r-- 14,536 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
<!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: Compressors</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.1.0</span>
   </div>
   <div id="projectbrief"><!-- 3.1.0 --></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('compression.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Compressors </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This section explains how to configure WiredTiger's builtin support for the lz4, snappy, zlib and zstd compression engines.</p>
<h1><a class="anchor" id="compression_lz4"></a>
Using LZ4 compression</h1>
<p>To use the builtin support for Yann Collet's <a href="https://github.com/Cyan4973/lz4">LZ4</a> compression, first check that LZ4 is installed in include and library directories searched by the compiler. Once LZ4 is installed, you can enable LZ4 using the <code>&ndash;enable-lz4</code> option to configure.</p>
<p>If LZ4 is installed in a location not normally searched by the compiler toolchain, you'll need to modify the <code>CPPFLAGS</code> and <code>LDFLAGS</code> to indicate these locations. For example, with the LZ4 includes and libraries installed in <code>/usr/local/include</code> and <code>/usr/local/lib</code>, you would run configure with the following additional arguments:</p>
<div class="fragment"><div class="line">--enable-lz4 CPPFLAGS=<span class="stringliteral">&quot;-I/usr/local/include&quot;</span> LDFLAGS=<span class="stringliteral">&quot;-L/usr/local/include&quot;</span></div></div><!-- fragment --><p>When opening the WiredTiger database, load the LZ4 shared library as an extension. For example, with the WiredTiger library installed in <code>/usr/local/lib</code>, you would use the following extension:</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/libwiredtiger_lz4.so]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> Finally, when creating the WiredTiger object, set <code>block_compressor</code> to <code>lz4:</code> </p>
<div class="fragment"><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb">create</a>(session,</div><div class="line">            <span class="stringliteral">&quot;table:mytable&quot;</span>,</div><div class="line">            <span class="stringliteral">&quot;block_compressor=lz4,key_format=S,value_format=S&quot;</span>));</div></div><!-- fragment --> <h1><a class="anchor" id="compression_snappy"></a>
Using snappy compression</h1>
<p>To use the builtin support for <a href="http://code.google.com/p/snappy/">Google's snappy</a> compression, first check that snappy is installed in include and library directories searched by the compiler. Once snappy is installed, you can enable snappy using the <code>&ndash;enable-snappy</code> option to configure.</p>
<p>If snappy is installed in a location not normally searched by the compiler toolchain, you'll need to modify the <code>CPPFLAGS</code> and <code>LDFLAGS</code> to indicate these locations. For example, with the snappy includes and libraries installed in <code>/usr/local/include</code> and <code>/usr/local/lib</code>, you would run configure with the following additional arguments:</p>
<div class="fragment"><div class="line">--enable-snappy CPPFLAGS=<span class="stringliteral">&quot;-I/usr/local/include&quot;</span> LDFLAGS=<span class="stringliteral">&quot;-L/usr/local/include&quot;</span></div></div><!-- fragment --><p>When opening the WiredTiger database, load the snappy shared library as an extension. For example, with the WiredTiger library installed in <code>/usr/local/lib</code>, you would use the following extension:</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/libwiredtiger_snappy.so]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> Finally, when creating the WiredTiger object, set <code>block_compressor</code> to <code>snappy:</code> </p>
<div class="fragment"><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb">create</a>(session,</div><div class="line">            <span class="stringliteral">&quot;table:mytable&quot;</span>,</div><div class="line">            <span class="stringliteral">&quot;block_compressor=snappy,key_format=S,value_format=S&quot;</span>));</div></div><!-- fragment --> <h1><a class="anchor" id="compression_zlib"></a>
Using zlib compression</h1>
<p>To use the builtin support for Greg Roelofs' and Mark Adler's <a href="http://www.zlib.net/">zlib</a> compression, first check that zlib is installed in include and library directories searched by the compiler. Once zlib is installed, you can enable zlib using the <code>&ndash;enable-zlib</code> option to configure.</p>
<p>If zlib is installed in a location not normally searched by the compiler toolchain, you'll need to modify the <code>CPPFLAGS</code> and <code>LDFLAGS</code> to indicate these locations. For example, with the zlib includes and libraries installed in <code>/usr/local/include</code> and <code>/usr/local/lib</code>, you would run configure with the following additional arguments:</p>
<div class="fragment"><div class="line">--enable-zlib CPPFLAGS=<span class="stringliteral">&quot;-I/usr/local/include&quot;</span> LDFLAGS=<span class="stringliteral">&quot;-L/usr/local/include&quot;</span></div></div><!-- fragment --><p>When opening the WiredTiger database, load the zlib shared library as an extension. For example, with the WiredTiger library installed in <code>/usr/local/lib</code>, you would use the following extension:</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/libwiredtiger_zlib.so]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> The default compression level for the zlib compression is <code>Z_DEFAULT_COMPRESSION</code> (see the zlib documentation for further information); compression can be configured to other levels using the additional configuration argument <code>compression_level</code>.</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/&quot;</span></div><div class="line">            <span class="stringliteral">&quot;libwiredtiger_zlib.so=[config=[compression_level=3]]]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> Finally, when creating the WiredTiger object, set <code>block_compressor</code> to <code>zlib:</code> </p>
<div class="fragment"><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb">create</a>(session,</div><div class="line">            <span class="stringliteral">&quot;table:mytable&quot;</span>,</div><div class="line">            <span class="stringliteral">&quot;block_compressor=zlib,key_format=S,value_format=S&quot;</span>));</div></div><!-- fragment --> <h1><a class="anchor" id="compression_zstd"></a>
Using Zstd compression</h1>
<p>To use the builtin support for Facebook's <a href="https://github.com/facebook/zstd">Zstd</a> compression, first check that Zstd is installed in include and library directories searched by the compiler. Once Zstd is installed, you can enable Zstd using the <code>&ndash;enable-zstd</code> option to configure.</p>
<p>If Zstd is installed in a location not normally searched by the compiler toolchain, you'll need to modify the <code>CPPFLAGS</code> and <code>LDFLAGS</code> to indicate these locations. For example, with the Zstd includes and libraries installed in <code>/usr/local/include</code> and <code>/usr/local/lib</code>, you would run configure with the following additional arguments:</p>
<div class="fragment"><div class="line">--enable-zstd CPPFLAGS=<span class="stringliteral">&quot;-I/usr/local/include&quot;</span> LDFLAGS=<span class="stringliteral">&quot;-L/usr/local/include&quot;</span></div></div><!-- fragment --><p>When opening the WiredTiger database, load the Zstd shared library as an extension. For example, with the WiredTiger library installed in <code>/usr/local/lib</code>, you would use the following extension:</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/libwiredtiger_zstd.so]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> The default compression level for the zstd compression is 3; compression can be configured to other levels using the additional configuration argument <code>compression_level</code>.</p>
<div class="fragment"><div class="line">        error_check(<a class="code" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813">wiredtiger_open</a>(home, NULL,</div><div class="line">            <span class="stringliteral">&quot;create,&quot;</span></div><div class="line">            <span class="stringliteral">&quot;extensions=[/usr/local/lib/&quot;</span></div><div class="line">            <span class="stringliteral">&quot;libwiredtiger_zstd.so=[config=[compression_level=9]]]&quot;</span>, &amp;conn));</div></div><!-- fragment --><p> Finally, when creating the WiredTiger object, set <code>block_compressor</code> to <code>zstd:</code> </p>
<div class="fragment"><div class="line">        error_check(session-&gt;<a class="code" href="struct_w_t___s_e_s_s_i_o_n.html#a358ca4141d59c345f401c58501276bbb">create</a>(session,</div><div class="line">            <span class="stringliteral">&quot;table:mytable&quot;</span>,</div><div class="line">            <span class="stringliteral">&quot;block_compressor=zstd,key_format=S,value_format=S&quot;</span>));</div></div><!-- fragment --> <h1><a class="anchor" id="compression_upgrading"></a>
Upgrading compression engines</h1>
<p>WiredTiger does not store information with file blocks to identify the compression engine used to compressed the block. Applications wanting to upgrade to some future compression engine (without requiring a file dump and re-load), should ensure each compressed block includes enough information to identify the compression engine used, so its compression code can correctly decompress old and new blocks.</p>
<h1><a class="anchor" id="compression_custom"></a>
Custom compression engines</h1>
<p>WiredTiger may be extended by adding custom compression engines; see <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> for more information. </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="footer">Copyright (c) 2008-2018 MongoDB, Inc.  All rights reserved.  Contact <a href="mailto:info@wiredtiger.com">info@wiredtiger.com</a> for more information.</li>
  </ul>
</div>
</body>
</html>