lbry-rocksdb/tutorial/index.html

256 lines
28 KiB
HTML
Raw Normal View History

2019-04-29 15:26:12 +02:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Basic Usage of python-rocksdb &#8212; python-rocksdb 0.6.7 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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>
<script type="text/javascript" src="../_static/language_data.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Changelog" href="../changelog.html" />
<link rel="prev" title="Installing" href="../installation.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="basic-usage-of-python-rocksdb">
<h1>Basic Usage of python-rocksdb<a class="headerlink" href="#basic-usage-of-python-rocksdb" title="Permalink to this headline"></a></h1>
2019-06-20 16:21:48 +02:00
<div class="section" id="column-family">
<h2>Column Family<a class="headerlink" href="#column-family" title="Permalink to this headline"></a></h2>
<p>python-rocksdb also supports column family</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">db</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">DB</span><span class="p">()</span>
<span class="n">opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">Options</span><span class="p">()</span>
<span class="n">opts</span><span class="o">.</span><span class="n">create_if_missing</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="s1">&#39;path/to/db&#39;</span><span class="p">)</span>
<span class="c1"># create new column family</span>
<span class="n">copts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ColumnFamilyOptions</span><span class="p">()</span>
<span class="n">s</span><span class="p">,</span> <span class="n">cf</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">create_column_family</span><span class="p">(</span><span class="n">copts</span><span class="p">,</span> <span class="s2">&quot;new_cf&quot;</span><span class="p">)</span>
<span class="k">del</span> <span class="n">cf</span>
<span class="n">db</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="c1"># open db with the column families</span>
<span class="n">cfd1</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ColumnFamilyDescriptor</span><span class="p">(</span><span class="n">pyrocksdb</span><span class="o">.</span><span class="n">DefaultColumnFamilyName</span><span class="p">,</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ColumnFamilyOptions</span><span class="p">())</span>
<span class="n">cfd2</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ColumnFamilyDescriptor</span><span class="p">(</span><span class="s2">&quot;new_cf&quot;</span><span class="p">,</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ColumnFamilyOptions</span><span class="p">())</span>
<span class="n">cfds</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">VectorColumnFamilyDescriptor</span><span class="p">()</span>
<span class="n">cfds</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cfd1</span><span class="p">)</span>
<span class="n">cfds</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cfd2</span><span class="p">)</span>
<span class="n">db_opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">DBOptions</span><span class="p">()</span>
<span class="c1"># column family handles</span>
<span class="n">s</span><span class="p">,</span> <span class="n">cfhs</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">db_opts</span><span class="p">,</span> <span class="s1">&#39;path/to/db&#39;</span><span class="p">,</span> <span class="n">cfds</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="k">assert</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cfhs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_name</span><span class="p">()</span> <span class="o">==</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">DefaultColumnFamilyName</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">get_name</span><span class="p">()</span> <span class="o">==</span><span class="s1">&#39;new_cf&#39;</span><span class="p">)</span>
<span class="n">wopts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">WriteOptions</span><span class="p">()</span>
<span class="n">ropts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ReadOptions</span><span class="p">()</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">wopts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value&#39;</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">is_not_found</span><span class="p">())</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">wopts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value&#39;</span><span class="p">)</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">wopts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">is_not_found</span><span class="p">())</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">wopts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">is_not_found</span><span class="p">())</span>
<span class="c1"># write batch</span>
<span class="n">update</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">WriteBatch</span><span class="p">()</span>
<span class="n">update</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value1&#39;</span><span class="p">)</span>
<span class="n">update</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">)</span>
<span class="n">update</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;key1&#39;</span><span class="p">)</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">wopts</span><span class="p">,</span> <span class="n">update</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">is_not_found</span><span class="p">())</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ropts</span><span class="p">,</span> <span class="n">cfhs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">ok</span><span class="p">())</span>
<span class="k">assert</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">cfh</span> <span class="ow">in</span> <span class="n">cfhs</span><span class="p">:</span>
<span class="k">del</span> <span class="n">cfh</span>
<span class="n">db</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</div>
2019-04-29 15:26:12 +02:00
<div class="section" id="wrtie-batch">
<h2>Wrtie Batch<a class="headerlink" href="#wrtie-batch" title="Permalink to this headline"></a></h2>
<p>It is also possible to gather modifications and
apply them in a single operation</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">update</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">WriteBatch</span><span class="p">()</span>
<span class="c1"># collect the operations</span>
2019-05-28 15:46:50 +02:00
<span class="n">update</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value1&#39;</span><span class="p">)</span>
<span class="n">update</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">)</span>
<span class="n">update</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="n">opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">WriteOptions</span><span class="p">()</span>
<span class="c1"># Apply these operatios in a single operation</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">update</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">s</span><span class="o">.</span><span class="n">ok</span><span class="p">()</span>
<span class="n">opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ReadOptions</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">blob</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="n">blob</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">is_not_found</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">blob</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="n">blob</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">ok</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="k">assert</span> <span class="n">blob</span><span class="o">.</span><span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span>
2019-04-29 15:26:12 +02:00
<span class="n">db</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="iteration">
<h2>Iteration<a class="headerlink" href="#iteration" title="Permalink to this headline"></a></h2>
<p>Iterators behave slightly different than expected. Per default they are not
valid. So you have to call one of its seek methods first</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">WriteOptions</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">s</span> <span class="o">=</span> <span class="p">{</span><span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;value1&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;key3&#39;</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;value3&#39;</span><span class="p">}</span>
2019-04-29 15:26:12 +02:00
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">db</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
<span class="n">opts</span> <span class="o">=</span> <span class="n">pyrocksdb</span><span class="o">.</span><span class="n">ReadOptions</span><span class="p">()</span>
<span class="n">it</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">iterator</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span>
<span class="n">it</span><span class="o">.</span><span class="n">seek_to_first</span><span class="p">()</span>
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">status</span><span class="p">()</span><span class="o">.</span><span class="n">ok</span><span class="p">()</span>
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
2019-05-28 15:46:50 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">key</span><span class="p">()</span> <span class="o">==</span> <span class="n">k</span>
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">value</span><span class="p">()</span> <span class="o">==</span> <span class="n">v</span>
2019-04-29 15:26:12 +02:00
<span class="n">it</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
<span class="k">assert</span> <span class="ow">not</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">it</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key1&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">key</span><span class="p">()</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;key1&#39;</span>
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">value</span><span class="p">()</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value1&#39;</span>
<span class="n">it</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key2&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">key</span><span class="p">()</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;key2&#39;</span>
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">value</span><span class="p">()</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">&#39;value2&#39;</span>
2019-04-29 15:26:12 +02:00
2019-05-28 15:46:50 +02:00
<span class="n">it</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key4&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="ow">not</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">it</span><span class="o">.</span><span class="n">seek_for_prev</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key0&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="ow">not</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
2019-05-28 15:46:50 +02:00
<span class="n">it</span><span class="o">.</span><span class="n">seek_for_prev</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;key4&#39;</span><span class="p">)</span>
2019-04-29 15:26:12 +02:00
<span class="k">assert</span> <span class="n">it</span><span class="o">.</span><span class="n">valid</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">python-rocksdb</a></h1>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Instructions how to install</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Tutorial</a><ul>
2019-06-20 16:21:48 +02:00
<li class="toctree-l2"><a class="reference internal" href="#column-family">Column Family</a></li>
2019-04-29 15:26:12 +02:00
<li class="toctree-l2"><a class="reference internal" href="#wrtie-batch">Wrtie Batch</a></li>
<li class="toctree-l2"><a class="reference internal" href="#iteration">Iteration</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li>Previous: <a href="../installation.html" title="previous chapter">Installing</a></li>
<li>Next: <a href="../changelog.html" title="next chapter">Changelog</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2014, sh.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.0.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/tutorial/index.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>