Debian Codegraph @

docs/collections/tutorial/developing.html

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Developing a DB Collections Application</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB Collections Tutorial" />
10 <link rel="up" href="intro.html" title="Chapter 1.  Introduction" />
11 <link rel="prev" href="intro.html" title="Chapter 1.  Introduction" />
12 <link rel="next" href="tutorialintroduction.html" title="Tutorial Introduction" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Developing a DB Collections Application</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 1. 
26 Introduction
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="tutorialintroduction.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="developing"></a>Developing a DB Collections Application</h2>
38 </div>
39 </div>
40 </div>
41 <p>
42 There are several important choices to make when developing an
43 application using the DB Java Collections API.
44 </p>
45 <div class="orderedlist">
46 <ol type="1">
47 <li>
48 <p>
49 Choose the Berkeley DB Environment
50 </p>
51 <p>
52 Depending on your application's concurrency and transactional
53 requirements, you may choose one of the three Berkeley DB
54 Environments: Data Store, Concurrent Data Store, or
55 Transactional Data Store. For details on creating and
56 configuring the environment, see the
57 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>
58 </p>
59 </li>
60 <li>
61 <p>
62 Choose the Berkeley DB Access Method
63 </p>
64 <p>
65 For each Berkeley DB datastore, you may choose from any of the
66 four Berkeley DB access methods — BTREE, HASH, RECNO, or
67 QUEUE
68 <span class="html">
69 (<a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#BTREE" target="_top">DatabaseType.BTREE</a>,
70 <a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#HASH" target="_top">DatabaseType.HASH</a>,
71 <a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#RECNO" target="_top">DatabaseType.RECNO</a>,
72 or
73 <a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#QUEUE" target="_top">DatabaseType.QUEUE</a>.)
74 </span>
75 — and a number of other database options. Your choice
76 depends on several factors such as whether you need ordered
77 keys, unique keys, record number access, and so forth. For more
78 information on access methods, see the
79 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
80 </p>
81 </li>
82 <li>
83 <p>
84 Choose the Format for Keys and Values
85 </p>
86 <p>
87 For each database you may choose a binding format for the keys
88 and values. For example, the tuple format is useful for keys
89 because it has a deterministic sort order. The serial format is
90 useful for values if you want to store arbitrary Java objects. In
91 some cases a custom format may be appropriate. For details on
92 choosing a binding format see
93 <a class="xref" href="collectionOverview.html#UsingDataBindings" title="Using Data Bindings">
94 Using Data Bindings
95 </a>.
96 </p>
97 </li>
98 <li>
99 <p>
100 Choose the Binding for Keys and Values
101 </p>
102 <p>
103 With the serial data format you do not have to create a binding
104 for each Java class that is stored since Java serialization is
105 used. But for other formats a binding must be defined that
106 translates between stored byte arrays and Java objects. For details
107 see
108 <a class="xref" href="collectionOverview.html#UsingDataBindings" title="Using Data Bindings">
109 Using Data Bindings
110 </a>.
111 </p>
112 </li>
113 <li>
114 <p>
115 Choose Secondary Indices
116 </p>
117 <p>
118 Any database that has unique keys may have any number of
119 secondary indices. A secondary index has keys that are derived from
120 data values in the primary database. This allows lookup and
121 iteration of objects in the database by its index keys.
122
123
124
125 For each index you must define how the index keys are derived from the data
126 values using a
127
128 <span>
129 <a class="ulink" href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>.
130 </span>
131 For details see the
132
133
134 <span>
135 <a class="ulink" href="../../java/com/sleepycat/db/SecondaryDatabase.html" target="_top">SecondaryDatabase</a>,
136 </span>
137
138
139 <a class="ulink" href="../../java/com/sleepycat/db/SecondaryConfig.html" target="_top">SecondaryConfig</a>
140
141 and
142
143 <a class="ulink" href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>
144
145 classes.
146 </p>
147 </li>
148 <li>
149 <p>
150 Choose the Collection Interface for each Database
151 </p>
152 <p>
153 The standard Java Collection interfaces are used for accessing
154 databases and secondary indices. The Map and Set interfaces may be
155 used for any type of database. The Iterator interface is used
156 through the Set interfaces. For more information on the collection
157 interfaces see
158 <a class="xref" href="UsingStoredCollections.html" title="Using Stored Collections">
159 Using Stored Collections
160 </a>.
161 </p>
162 </li>
163 </ol>
164 </div>
165 <p>
166 Any number of bindings and collections may be created for the
167 same database. This allows multiple views of the same stored data.
168 For example, a data store may be viewed as a Map of keys to values,
169 a Set of keys, or a Collection of values. String values, for
170 example, may be used with the built-in binding to the String class,
171 or with a custom binding to another class that represents the
172 string values differently.
173 </p>
174 <p>
175 It is sometimes desirable to use a Java class that encapsulates
176 both a data key and a data value. For example, a Part object might
177 contain both the part number (key) and the part name (value). Using
178 the DB Java Collections API this type of object is called an
179 "entity". An entity binding is used to translate between the Java
180 object and the stored data key and value. Entity bindings may be
181 used with all Collection types.
182 </p>
183 <p>
184 Please be aware that the provided DB Java Collections API collection classes
185 do not conform completely to the interface contracts
186 defined in the <code class="literal">java.util</code> package. For example, all
187 iterators must be explicitly closed and the <code class="methodname">size()</code>
188 method is not available. The differences between the DB Java Collections API
189 collections and the standard Java collections are
190 documented in
191 <a class="xref" href="UsingStoredCollections.html#StoredVersusStandardCollections" title="Stored Collections Versus Standard Java Collections">
192 Stored Collections Versus Standard Java Collections
193 </a>.
194 </p>
195 </div>
196 <div class="navfooter">
197 <hr />
198 <table width="100%" summary="Navigation footer">
199 <tr>
200 <td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td>
201 <td width="20%" align="center">
202 <a accesskey="u" href="intro.html">Up</a>
203 </td>
204 <td width="40%" align="right"> <a accesskey="n" href="tutorialintroduction.html">Next</a></td>
205 </tr>
206 <tr>
207 <td width="40%" align="left" valign="top">Chapter 1. 
208 Introduction
209  </td>
210 <td width="20%" align="center">
211 <a accesskey="h" href="index.html">Home</a>
212 </td>
213 <td width="40%" align="right" valign="top"> Tutorial Introduction</td>
214 </tr>
215 </table>
216 </div>
217 </body>
218 </html>