/usr/share/doc/python-larch/html/index.html is in python-larch 1.20131130-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 217 218 219 220 221 | <!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>Welcome to larch’s documentation! — larch 1.20131130 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.20131130',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="larch 1.20131130 documentation" href="#" />
<link rel="next" title="Forests of trees" href="forest.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="forest.html" title="Forests of trees"
accesskey="N">next</a> |</li>
<li><a href="#">larch 1.20131130 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="welcome-to-larch-s-documentation">
<h1>Welcome to larch’s documentation!<a class="headerlink" href="#welcome-to-larch-s-documentation" title="Permalink to this headline">¶</a></h1>
<p>This is an implementation of particular kind of B-tree, based on research by
Ohad Rodeh. See “B-trees, Shadowing, and Clones” (link below) for details on
the data structure. This is the same data structure that btrfs uses.</p>
<p>The distinctive feature of these B-trees is that a node is
never modified. Instead, all updates are done by copy-on-write. Among other
things, this makes it easy to clone a tree, and modify only the clone, while
other processes access the original tree. This is utterly wonderful for my
backup application, and that’s the reason I wrote larch in the first place.</p>
<p>I have tried to keep the implementation generic and flexibile, so that you
may use it in a variety of situations. For example, the tree itself does not
decide where its nodes are stored: you provide a class that does that for it.
I have two implementations of the NodeStore class, one for in-memory and one
for on-disk storage.</p>
<ul class="simple">
<li>Homepage: <a class="reference external" href="http://liw.fi/larch/">http://liw.fi/larch/</a></li>
<li>Rodeh paper: <a class="reference external" href="http://liw.fi/larch/ohad-btrees-shadowing-clones.pdf">http://liw.fi/larch/ohad-btrees-shadowing-clones.pdf</a></li>
</ul>
</div>
<div class="section" id="classes-and-functions">
<h1>Classes and functions<a class="headerlink" href="#classes-and-functions" title="Permalink to this headline">¶</a></h1>
<p>Anything that is available as <tt class="docutils literal"><span class="pre">larch.foo.bar</span></tt> is also
available as <tt class="docutils literal"><span class="pre">larch.bar</span></tt>.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="forest.html">Forests of trees</a></li>
<li class="toctree-l1"><a class="reference internal" href="btree.html">Individual trees</a></li>
<li class="toctree-l1"><a class="reference internal" href="node.html">Individual nodes</a></li>
<li class="toctree-l1"><a class="reference internal" href="codec.html">Node codecs</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodestore.html">Node storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="refcountstore.html">Reference count storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="uploadqueue.html">Upload queue for nodes</a></li>
<li class="toctree-l1"><a class="reference internal" href="lru.html">Least recently used object cache</a></li>
<li class="toctree-l1"><a class="reference internal" href="ondisk.html">On-disk file format and data structure</a><ul>
<li class="toctree-l2"><a class="reference internal" href="ondisk.html#the-metadata-file">The metadata file</a></li>
<li class="toctree-l2"><a class="reference internal" href="ondisk.html#node-files">Node files</a></li>
<li class="toctree-l2"><a class="reference internal" href="ondisk.html#reference-counts">Reference counts</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="quick-start">
<h1>Quick start<a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h1>
<p>A <strong>forest</strong> is a collection of related <strong>trees</strong>: cloning a tree is
only possible within a forest. Thus, also, only trees in the same
forest can share nodes. All <strong>keys</strong> in a all trees in a forest
must be string of the same size. <strong>Values</strong> are strings and
are stored in <strong>nodes</strong>, and
can be of any size, almost up to half the size of a node.</p>
<p>When creating a forest, you must specify the sizes of keys and
nodes, and the directory in which everything gets stored:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">larch</span>
<span class="n">key_size</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">node_size</span> <span class="o">=</span> <span class="mi">4096</span>
<span class="n">dirname</span> <span class="o">=</span> <span class="s">'example.tree'</span>
<span class="n">forest</span> <span class="o">=</span> <span class="n">larch</span><span class="o">.</span><span class="n">open_forest</span><span class="p">(</span><span class="n">key_size</span><span class="o">=</span><span class="n">key_size</span><span class="p">,</span> <span class="n">node_size</span><span class="o">=</span><span class="n">node_size</span><span class="p">,</span>
<span class="n">dirname</span><span class="o">=</span><span class="n">dirname</span><span class="p">)</span>
</pre></div>
</div>
<p>The above will create a new forest, if necessary, or open an existing
one (which must have been created using the same key and node sizes).</p>
<p>To create a new tree:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">tree</span> <span class="o">=</span> <span class="n">forest</span><span class="o">.</span><span class="n">new_tree</span><span class="p">()</span>
</pre></div>
</div>
<p>Alternatively, to clone an existing tree if one exists:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="n">forest</span><span class="o">.</span><span class="n">trees</span><span class="p">:</span>
<span class="n">tree</span> <span class="o">=</span> <span class="n">forest</span><span class="o">.</span><span class="n">new_tree</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">trees</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">tree</span> <span class="o">=</span> <span class="n">forest</span><span class="o">.</span><span class="n">new_tree</span><span class="p">()</span>
</pre></div>
</div>
<p>To insert some data into the tree:</p>
<div class="highlight-python"><pre>for key in ['abc', 'foo', bar']:
tree.insert(key, key.upper())</pre>
</div>
<p>To look up value for one key:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span> <span class="n">tree</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s">'foo'</span><span class="p">)</span>
</pre></div>
</div>
<p>To look up a range:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tree</span><span class="o">.</span><span class="n">lookup_range</span><span class="p">(</span><span class="s">'aaa'</span><span class="p">,</span> <span class="s">'zzz'</span><span class="p">):</span>
<span class="k">print</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span>
</pre></div>
</div>
<p>To remove a key:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">tree</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s">'abc'</span><span class="p">)</span>
</pre></div>
</div>
<p>To remove a range:</p>
<blockquote>
<div>tree.remove_range(‘aaa’, ‘zzz’)</div></blockquote>
<p>You probably don’t need to worry about anything else than the
<tt class="docutils literal"><span class="pre">Forest</span></tt> and <tt class="docutils literal"><span class="pre">BTree</span></tt> classes, unless you want to provide your
own <tt class="docutils literal"><span class="pre">NodeStore</span></tt> instance.</p>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
<ul class="simple">
<li><a class="reference internal" href="genindex.html"><em>Index</em></a></li>
<li><a class="reference internal" href="py-modindex.html"><em>Module Index</em></a></li>
<li><a class="reference internal" href="search.html"><em>Search Page</em></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="#">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Welcome to larch’s documentation!</a></li>
<li><a class="reference internal" href="#classes-and-functions">Classes and functions</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#quick-start">Quick start</a></li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
</ul>
<h4>Next topic</h4>
<p class="topless"><a href="forest.html"
title="next chapter">Forests of trees</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/index.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="forest.html" title="Forests of trees"
>next</a> |</li>
<li><a href="#">larch 1.20131130 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2011, Lars Wirzenius.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b3.
</div>
</body>
</html>
|