directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r908540 - in /websites/staging/directory/trunk/content: ./ mavibot/user-guide/4-btree-operations.html
Date Sat, 10 May 2014 18:13:58 GMT
Author: buildbot
Date: Sat May 10 18:13:58 2014
New Revision: 908540

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 Sat May 10 18:13:58 2014
@@ -1 +1 @@
-1593703
+1593711

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 Sat
May 10 18:13:58 2014
@@ -364,17 +364,73 @@ One can only add one single value if the
 
 
 <h2 id="47-delete-operations">4.7 Delete Operations</h2>
+<p>The <em>delete()</em> method is used to delete keys and values from
a <em>B-tree</em>. We have two methods to do that.</p>
 <h3 id="481-btreedelete-k-key">4.8.1 BTree.delete( K key )</h3>
-<p>TODO</p>
+<p>This method removes a given key and all its values from a <em>B-tree</em>.
If the key does not exist in the <em>B-tree</em>, a <em>KeyNotFoundException</em>
will be thrown.</p>
+<p>This method returns the first tuple with the given key.</p>
+<p>Here is an example :</p>
+<div class="codehilite"><pre><span class="p">...</span>
+<span class="o">//</span> <span class="n">Insert</span> <span
class="n">a</span> <span class="n">new</span> <span class="n">key</span>
<span class="n">and</span> <span class="n">value</span> <span class="n">into</span>
<span class="n">a</span> <span class="n">B</span><span class="o">-</span><span
class="n">tree</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;<span class="n">V1</span>&quot; <span class="p">);</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;<span class="n">V2</span>&quot; <span class="p">);</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;<span class="n">V3</span>&quot; <span class="p">);</span>
+<span class="o">//</span> <span class="n">At</span> <span class="n">this</span>
<span class="n">point</span><span class="p">,</span> <span class="n">the</span>
<span class="n">key</span> 1<span class="n">L</span> <span class="n">will</span>
<span class="n">be</span> <span class="n">associated</span> <span
class="n">with</span> <span class="p">{</span><span class="n">V1</span><span
class="p">,</span> <span class="n">V2</span><span class="p">,</span>
<span class="n">V3</span><span class="p">}</span>
+<span class="p">...</span>
+<span class="o">//</span> <span class="n">Now</span> <span class="n">delete</span>
1<span class="n">L</span>
+<span class="n">btree</span><span class="p">.</span><span class="n">delete</span><span
class="p">(</span> 1<span class="n">L</span> <span class="p">);</span>
+
+<span class="o">//</span> <span class="n">Check</span> <span class="n">that</span>
<span class="n">the</span> <span class="n">values</span> <span
class="n">have</span> <span class="n">been</span> <span class="n">removed</span>
+<span class="k">if</span> <span class="p">(</span> <span class="n">btree</span><span
class="p">.</span><span class="n">hasKey</span><span class="p">(</span>
1<span class="n">L</span> <span class="p">)</span> <span class="o">==</span>
<span class="n">true</span> <span class="p">)</span>
+<span class="p">{</span>
+    <span class="o">//</span> <span class="n">This</span> <span
class="n">is</span> <span class="n">an</span> <span class="n">error</span>
!
+<span class="p">}</span>
+</pre></div>
+
+
 <h3 id="472-btreedelete-k-key-v-value">4.7.2 BTree.delete( K key, V value )</h3>
-<p>TODO</p>
+<p>This method can be used to delete one specific value for a given key. If the removed
value is the last one, the key will also be removed.</p>
+<p>Here is an example :</p>
+<div class="codehilite"><pre><span class="p">...</span>
+<span class="o">//</span> <span class="n">Insert</span> <span
class="n">a</span> <span class="n">new</span> <span class="n">key</span>
<span class="n">and</span> <span class="n">value</span> <span class="n">into</span>
<span class="n">a</span> <span class="n">B</span><span class="o">-</span><span
class="n">tree</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;<span class="n">V1</span>&quot; <span class="p">);</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;<span class="n">V2</span>&quot; <span class="p">);</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;<span class="n">V3</span>&quot; <span class="p">);</span>
+<span class="o">//</span> <span class="n">At</span> <span class="n">this</span>
<span class="n">point</span><span class="p">,</span> <span class="n">the</span>
<span class="n">key</span> 1<span class="n">L</span> <span class="n">will</span>
<span class="n">be</span> <span class="n">associated</span> <span
class="n">with</span> <span class="p">{</span><span class="n">V1</span><span
class="p">,</span> <span class="n">V2</span><span class="p">,</span>
<span class="n">V3</span><span class="p">}</span>
+<span class="p">...</span>
+<span class="o">//</span> <span class="n">Now</span> <span class="n">delete</span>
<span class="o">&lt;</span>1<span class="n">L</span><span class="p">,</span>
&quot;<span class="n">V2</span>&quot;<span class="o">&gt;</span>
+<span class="n">btree</span><span class="p">.</span><span class="n">delete</span><span
class="p">(</span> 1<span class="n">L</span><span class="p">,</span>
&quot;<span class="n">V2</span>&quot; <span class="p">);</span>
+
+<span class="o">//</span> <span class="n">The</span> <span class="n">key</span>
1<span class="n">L</span> <span class="n">is</span> <span class="n">still</span>
<span class="n">associated</span> <span class="n">with</span> <span
class="p">{</span>&quot;<span class="n">V1</span>&quot;<span
class="p">,</span> &quot;<span class="n">V3</span>&quot;<span
class="p">}</span>
+<span class="n">ValueCursor</span><span class="o">&lt;</span><span
class="n">String</span><span class="o">&gt;</span> <span class="n">values</span>
<span class="p">=</span> <span class="n">dupsTree</span><span class="p">.</span><span
class="n">getValues</span><span class="p">(</span> 1<span class="n">L</span><span
class="p">);</span>
+
+<span class="k">while</span> <span class="p">(</span> <span class="n">values</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">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">value</span><span class="p">.</span><span
class="n">next</span><span class="p">()</span> <span class="p">);</span>
+<span class="p">}</span>
+<span class="p">...</span>
+</pre></div>
+
+
+<p>This will produce the following output :</p>
+<div class="codehilite"><pre><span class="n">V1</span>
+<span class="n">V3</span>
+</pre></div>
+
+
 <h2 id="48-other-b-tree-operations">4.8 Other B-tree operations</h2>
+<p>Beside those important operations we just have described, we have a few other less
critical operations you must kown about.</p>
 <h3 id="481-btreeclose">4.8.1 BTree.close()</h3>
-<p>TODO</p>
-<h3 id="482-btreeflush">4.8.2 BTree.flush()</h3>
-<p>TODO</p>
+<p>This method will cleanly close the <em>B-tree</em>. Depending on the
<em>B-tree</em> type, it will proceed differently while closing the <em>B-tree</em>.</p>
+<ul>
+<li>PersistedBTree : It will close the cache, and close all the pending read transactions.
Any write transaction will be complected.</li>
+<li>InMemoryBTree  : it will flush the memory content on disk, and close the journal,
if the <em>B-tree</em> is persistent.</li>
+</ul>
+<DIV class="note" markdown="1">
+<b>ALWAYS</B> call the <i>close()</i> method when you are done with
a <i>B-tree</i>.
+</DIV>
+
 <h3 id="483-btreegetrevision">4.8.3 BTree.getRevision()</h3>
-<p>TODO</p>
+<p>Returns the current <em>B-tree</em> revision.</p>
 
 
     <div class="nav">



Mime
View raw message