01: /*
02: This file is part of the PolePosition database benchmark
03: http://www.polepos.org
04:
05: This program is free software; you can redistribute it and/or
06: modify it under the terms of the GNU General Public License
07: as published by the Free Software Foundation; either version 2
08: of the License, or (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public
16: License along with this program; if not, write to the Free
17: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18: MA 02111-1307, USA. */
19:
20: package org.polepos.teams.db4o;
21:
22: import org.polepos.circuits.melbourne.*;
23: import org.polepos.data.*;
24:
25: import com.db4o.*;
26: import com.db4o.query.*;
27:
28: /**
29: * @author Herkules
30: */
31: public class MelbourneDb4o extends Db4oDriver implements
32: MelbourneDriver {
33:
34: public void write() {
35:
36: int numobjects = setup().getObjectCount();
37: int commitinterval = setup().getCommitInterval();
38: int commitctr = 0;
39:
40: begin();
41: for (int i = 1; i <= numobjects; i++) {
42:
43: Pilot p = new Pilot("Pilot_" + i, "Herkules", i, i);
44: store(p);
45:
46: if (commitinterval > 0 && ++commitctr >= commitinterval) {
47: commitctr = 0;
48: commit();
49: begin();
50: }
51:
52: addToCheckSum(i);
53: }
54:
55: commit();
56: }
57:
58: public void read() {
59: readExtent(Pilot.class);
60: }
61:
62: public void read_hot() {
63: read();
64: }
65:
66: public void delete() {
67:
68: begin();
69:
70: int numobjects = setup().getObjectCount();
71: int commitintervall = setup().getCommitInterval();
72:
73: int commitctr = 0;
74:
75: // By setting an activation depth of zero, we can
76: // prevent instantiating the Pilot objects.
77: db().configure().activationDepth(0);
78:
79: Query allpilots = db().query();
80: allpilots.constrain(Pilot.class);
81: ObjectSet deleteset = allpilots.execute();
82:
83: for (int i = 0; i < numobjects; i++) {
84:
85: Object o = deleteset.next();
86:
87: db().delete(o);
88:
89: if (commitintervall > 0 && ++commitctr >= commitintervall) {
90: commitctr = 0;
91: commit();
92: begin();
93: }
94: }
95:
96: commit();
97: }
98:
99: }
|