directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r908468 - in /websites/staging/directory/trunk/content: ./ mavibot/user-guide/4-btree-operations.html
Date Fri, 09 May 2014 15:10:05 GMT
Author: buildbot
Date: Fri May  9 15:10:05 2014
New Revision: 908468

Log:
Staging update by buildbot for directory

Modified:
    websites/staging/directory/trunk/content/   (props changed)
    websites/staging/directory/trunk/content/mavibot/user-guide/4-btree-operations.html

Propchange: websites/staging/directory/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri May  9 15:10:05 2014
@@ -1 +1 @@
-1593510
+1593558

Modified: websites/staging/directory/trunk/content/mavibot/user-guide/4-btree-operations.html
==============================================================================
--- websites/staging/directory/trunk/content/mavibot/user-guide/4-btree-operations.html (original)
+++ websites/staging/directory/trunk/content/mavibot/user-guide/4-btree-operations.html Fri
May  9 15:10:05 2014
@@ -178,23 +178,112 @@ returned).</p>
 <p>Tells if there is a next available tuple. This will always be true if we are before
the first tuple, and always false if we are on the last tuple or after the last tuple. The
following picture shows the returned value for calls in various cases :</p>
 <p><img alt="Has Next" src="images/ug-btree-has-next.png" /></p>
 <h4 id="4122-hasprev">4.1.2.2 hasPrev</h4>
-<p>Returns true if there is a tuple available before the current tuple.</p>
+<p>Returns true if there is a tuple available before the current tuple. The following
picture shows the returned value for calls in various cases :</p>
+<p><img alt="Has Next" src="images/ug-btree-has-next.png" /></p>
 <h4 id="4123-next">4.1.2.3 next</h4>
 <p>Moves to the next value of the current key or to the next key if all the values
of the current key have been processed, and return the associated tuple.</p>
 <h4 id="4124-prev">4.1.2.4 prev</h4>
 <p>Moves to the previous value of the current key or to the previous key if all the
values of the current key have been processed, and return the associated tuple.</p>
-<h4 id="4125-hasnextkey">4.1.2.5 hasNextKey</h4>
-<p>Tells if there is a key after the current key.</p>
-<h4 id="4126-hasprevkey">4.1.2.6 hasPrevKey</h4>
-<p>Tells if there is a previous key before the current key.</p>
-<h4 id="4127-nextkey">4.1.2.7 nextKey</h4>
-<p>Moves(jumps) to the next key, even if not all values of the current key are navigated.</p>
-<h4 id="4128-prevkey">4.1.2.8 prevKey</h4>
-<p>Moves(jumps) to the previous key, even if not all values of the current key are
navigated.</p>
 <h2 id="41-browse-operations">4.1 Browse Operations</h2>
-<p>Now that we know what a <em>Cursor</em> is about, we can describe the
various <em>browse</em> operations.</p>
-<h3 id="411-browse">4.1.1 browse()</h3>
-<p>This method returns a cursor with the position set before the first key of the <strong>B-tree</strong>.
</p>
+<p>Now that we know what a <em>Cursor</em> is about, we can describe the
various <em>browse</em> operations that can be applied on a <em>BTree</em>.</p>
+<h3 id="411-btreebrowse">4.1.1 BTree.browse()</h3>
+<p>This method returns a cursor with the position set before the first element of the
<strong>B-tree</strong>, for the current revision. It returns a <em>TupleCursor</em>
that contain the tuples <key,value> present in the <em>Btree</em>.</p>
+<p>Assuming you have an existing <em>BTree</em>, using this method is quite
straigthforward. Here is an example with a persisted <em>BTree</em>  :</p>
+<div class="codehilite"><pre>    <span class="o">//</span> <span
class="n">Create</span> <span class="n">a</span> <span class="n">RecordManager</span>
<span class="n">that</span> <span class="n">will</span> <span class="n">contain</span>
<span class="n">the</span> <span class="n">BTree</span>
+    <span class="n">RecordManager</span> <span class="n">recordManager</span>
<span class="p">=</span> <span class="n">new</span> <span class="n">RecordManager</span><span
class="p">(</span> &quot;<span class="n">Test</span><span class="p">.</span><span
class="n">db</span>&quot; <span class="p">);</span>
+
+    <span class="o">//</span> <span class="n">Create</span> <span
class="n">a</span> <span class="n">BTree</span> <span class="n">to</span>
<span class="n">play</span> <span class="n">with</span>
+    <span class="n">BTree</span><span class="o">&lt;</span><span
class="n">Long</span><span class="p">,</span> <span class="n">String</span><span
class="o">&gt;</span> <span class="n">btree</span> <span class="p">=</span>
<span class="n">recordManager</span><span class="p">.</span><span
class="n">addBTree</span><span class="p">(</span> &quot;<span
class="n">test</span>&quot;<span class="p">,</span> <span class="n">LongSerializer</span><span
class="p">.</span><span class="n">INSTANCE</span><span class="p">,</span>
<span class="n">StringSerializer</span><span class="p">.</span><span
class="n">INSTANCE</span><span class="p">,</span> <span class="n">true</span>
<span class="p">);</span>
+
+    <span class="o">//</span> <span class="n">Inject</span> <span
class="n">some</span> <span class="n">data</span>
+    <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> 1<span class="n">L</span><span
class="p">,</span> &quot;1&quot; <span class="p">);</span>
+    <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> 4<span class="n">L</span><span
class="p">,</span> &quot;4&quot; <span class="p">);</span>
+    <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> 2<span class="n">L</span><span
class="p">,</span> &quot;2&quot; <span class="p">);</span>
+    <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> 3<span class="n">L</span><span
class="p">,</span> &quot;3&quot; <span class="p">);</span>
+    <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> 5<span class="n">L</span><span
class="p">,</span> &quot;5&quot; <span class="p">);</span>
+
+    <span class="o">//</span> <span class="n">Create</span> <span
class="n">the</span> <span class="n">cursor</span>
+    <span class="n">TupleCursor</span><span class="o">&lt;</span><span
class="n">Long</span><span class="p">,</span> <span class="n">String</span><span
class="o">&gt;</span> <span class="n">cursor</span> <span class="p">=</span>
<span class="n">btree</span><span class="p">.</span><span class="n">browse</span><span
class="p">();</span>
+
+    <span class="o">//</span> <span class="n">Set</span> <span
class="n">the</span> <span class="n">cursor</span> <span class="n">at</span>
<span class="n">the</span> <span class="n">beginning</span> <span
class="n">of</span> <span class="n">the</span> <span class="n">BTree</span>
+    <span class="n">cursor</span><span class="p">.</span><span
class="n">beforeFirst</span><span class="p">();</span>
+
+    <span class="o">//</span> <span class="n">Get</span> <span
class="n">the</span> <span class="n">tuples</span>
+    <span class="o">//</span> <span class="n">Create</span> <span
class="n">the</span> <span class="n">cursor</span>
+    <span class="n">TupleCursor</span><span class="o">&lt;</span><span
class="n">Long</span><span class="p">,</span> <span class="n">String</span><span
class="o">&gt;</span> <span class="n">cursor</span> <span class="p">=</span>
<span class="n">btree</span><span class="p">.</span><span class="n">browse</span><span
class="p">();</span>
+
+    <span class="o">//</span> <span class="n">Move</span> <span
class="n">forward</span>
+    <span class="k">while</span> <span class="p">(</span> <span
class="n">cursor</span><span class="p">.</span><span class="n">hasNext</span><span
class="p">()</span> <span class="p">)</span>
+    <span class="p">{</span>
+        <span class="n">Tuple</span><span class="o">&lt;</span><span
class="n">Long</span><span class="p">,</span> <span class="n">String</span><span
class="o">&gt;</span> <span class="n">tuple</span> <span class="p">=</span>
<span class="n">cursor</span><span class="p">.</span><span class="n">next</span><span
class="p">();</span>
+        <span class="n">System</span><span class="p">.</span><span
class="n">out</span><span class="p">.</span><span class="n">println</span><span
class="p">(</span> <span class="n">tuple</span> <span class="p">);</span>
+    <span class="p">}</span>
+
+    <span class="p">...</span>
+</pre></div>
+
+
+<p>will produce this output :</p>
+<div class="codehilite"><pre><span class="o">&lt;</span>1<span
class="p">,</span>1<span class="o">&gt;</span>
+<span class="o">&lt;</span>2<span class="p">,</span>2<span
class="o">&gt;</span>
+<span class="o">&lt;</span>3<span class="p">,</span>3<span
class="o">&gt;</span>
+<span class="o">&lt;</span>4<span class="p">,</span>4<span
class="o">&gt;</span>
+<span class="o">&lt;</span>5<span class="p">,</span>5<span
class="o">&gt;</span>
+</pre></div>
+
+
+<h3 id="412-btreebrowse-long">4.1.2 BTree.browse( long )</h3>
+<p>This method returns a cursor with the position set before the first element of the
<strong>B-tree</strong>, for the given revision. </p>
+<p>Here, the big difference is that you can fetch some data from an older revision
- assuming this revision is still present, of course -.</p>
+<p>It returns a <em>TupleCursor</em> that contain the tuples <key,value>
present in the <em>Btree</em>.</p>
+<p>You can use the exact same code than for the <em>browse()</em> method,
except that you have to pass the version you want to browse.</p>
+<h3 id="413-btreebrowsefrom-k-key">4.1.3 BTree.browseFrom( K key )</h3>
+<p>This method returns a cursor with the position set before the given key of the <strong>B-tree</strong>.
If the key does not exist, the cursor will be set to the closest lower value (or upper value
if it's lower than the lowest value)</p>
+<p>It returns a <em>TupleCursor</em> that contain the tuples <key,value>
present in the <em>Btree</em>.</p>
+<p>You can use the exact same code than for the <em>browse()</em> method.
Here is an example, where we start after the latest present key :</p>
+<div class="codehilite"><pre>    <span class="o">//</span> <span
class="n">Inject</span> <span class="n">some</span> <span class="n">data</span>
+    <span class="k">for</span> <span class="p">(</span> <span
class="n">long</span> <span class="nb">i</span> <span class="p">=</span>
0<span class="p">;</span> <span class="nb">i</span> <span class="o">&lt;</span><span
class="p">=</span> 1000<span class="n">L</span><span class="p">;</span>
<span class="nb">i</span> <span class="o">+</span><span class="p">=</span>
2 <span class="p">)</span>
+    <span class="p">{</span>
+        <span class="n">btree</span><span class="p">.</span><span
class="n">insert</span><span class="p">(</span> <span class="nb">i</span><span
class="p">,</span> <span class="n">Long</span><span class="p">.</span><span
class="n">toString</span><span class="p">(</span> <span class="nb">i</span>
<span class="p">)</span> <span class="p">);</span>
+    <span class="p">}</span>
+
+    <span class="o">//</span> <span class="n">Create</span> <span
class="n">the</span> <span class="n">cursor</span>
+    <span class="n">TupleCursor</span><span class="o">&lt;</span><span
class="n">Long</span><span class="p">,</span> <span class="n">String</span><span
class="o">&gt;</span> <span class="n">cursor</span> <span class="p">=</span>
<span class="n">btree</span><span class="p">.</span><span class="n">browseFrom</span><span
class="p">(</span> 1500<span class="n">L</span> <span class="p">);</span>
+
+    <span class="n">assertFalse</span><span class="p">(</span> <span
class="n">cursor</span><span class="p">.</span><span class="n">hasNext</span><span
class="p">()</span> <span class="p">);</span>
+    <span class="n">assertTrue</span><span class="p">(</span> <span
class="n">cursor</span><span class="p">.</span><span class="n">hasPrev</span><span
class="p">()</span> <span class="p">);</span>
+    <span class="n">assertEquals</span><span class="p">(</span> 1000<span
class="n">L</span><span class="p">,</span> <span class="n">cursor</span><span
class="p">.</span><span class="n">prev</span><span class="p">().</span><span
class="n">getKey</span><span class="p">().</span><span class="n">longValue</span><span
class="p">()</span> <span class="p">);</span>
+</pre></div>
+
+
+<h3 id="414-btreebrowsefrom-long-revision-k-key">4.1.4 BTree.browseFrom( long revision,
K key )</h3>
+<p>TODO</p>
+<h3 id="415-btreeclose">4.1.5 BTree.close()</h3>
+<p>TODO</p>
+<h3 id="416-btreecontains-k-key-v-value">4.1.6 BTree.contains( K key, V value )</h3>
+<p>TODO</p>
+<h3 id="417-btreecontains-long-revision-k-key-v-value">4.1.7 BTree.contains( long revision,
K key, V value )</h3>
+<p>TODO</p>
+<h3 id="418-btreedelete-k-key">4.1.8 BTree.delete( K key )</h3>
+<p>TODO</p>
+<h3 id="419-btreedelete-k-key-v-value">4.1.9 BTree.delete( K key, V value )</h3>
+<p>TODO</p>
+<h3 id="4110-btreeflush">4.1.10 BTree.flush()</h3>
+<p>TODO</p>
+<h3 id="4111-btreeget-k-key">4.1.11 BTree.get( K key )</h3>
+<p>TODO</p>
+<h3 id="4112-btreeget-long-revision-k-key">4.1.12 BTree.get( long revision, K key )</h3>
+<p>TODO</p>
+<h3 id="4113-btreegetrevision">4.1.13 BTree.getRevision()</h3>
+<p>TODO</p>
+<h3 id="4114-btreegetvalues-k-key">4.1.14 BTree.getValues( K key )</h3>
+<p>TODO</p>
+<h3 id="4115-btreehaskey-k-key">4.1.15 BTree.hasKey( K key )</h3>
+<p>TODO</p>
+<h3 id="4116-btreehaskey-long-revision-k-key">4.1.16 BTree.hasKey( long revision, K
key )</h3>
+<p>TODO</p>
+<h3 id="4117-btreeinsert-k-key-v-value">4.1.17 BTree.insert( K key, V value )</h3>
+<p>TODO</p>
 
 
     <div class="nav">



Mime
View raw message