Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 703

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Collections</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Collections</h1>
<p><a href="../translators.html" class="wikiLink">Translators</a> chapter of the documentation explains why translators are necessary to store and retrieve some types of classes. Db4o uses translators internally to manage storing and retrieving of collections.</p>
<p>Java collections were first implemented in JDK 1.2. Before that Vector implementation was used to store growable arrays of objects. Under the hood, when collection object is stored to the database different actions are taken for different versions of java:</p>
<ol>
<li>before JDK1.2: collection class is translated with TVector class;</li>
<li>after: collection is translated with TCollection, TMap, THashtable translators.</li></ol>
<p>In fact, the functionality of those translators is pretty much the same. On storing collection is transferred to an array of objects ( Object[] ) and that array gets stored to the database file. </p>
<p>Map (Java), HashTable and SortedList for .NET objects are stored as an array of objects of special type:</p>
<p><code>public class Entry<br>{<br>public Object key;<br>public Object value;<br>. . .<br>}</code>&nbsp;</p>
<p><i>OnInstantiate</i> method of collection translators creates a new instance of respective collection or map and restores its values from the saved object array.</p>
<p>Unfortunately this implementation is not very efficient for searches/updates of a certain value in a collection, as the whole collection should be instantiated to access any of its elements.</p>
<p><div class="childTopicList">More Reading:<ul>
<li><p><a href="collections/built-in_db4o_collections.html" class="wikiLink">Built-in db4o collections</a></p></li>
<li><p><a href="collections/fast_collections.html" class="wikiLink">Fast collections</a></p></li>
<li><p><a href="collections/collections_or_arrays.html" class="wikiLink">Collections Or Arrays</a></p></li>
</ul></div>
</p></div>
    </div>
    <div id="footer">
					This revision (11) was last Modified 2007-05-07T09:29:51 by Tetyana.
				</div>
  </body>
</html>