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.barcelona.*;
23: import org.polepos.framework.*;
24:
25: import com.db4o.*;
26: import com.db4o.query.*;
27:
28: public class BarcelonaDb4o extends Db4oDriver implements
29: BarcelonaDriver {
30:
31: public void takeSeatIn(Car car, TurnSetup setup)
32: throws CarMotorFailureException {
33: Db4o.configure().objectClass(B2.class).objectField("b2")
34: .indexed(true);
35: super .takeSeatIn(car, setup);
36: }
37:
38: public void write() {
39: int count = setup().getObjectCount();
40: begin();
41: for (int i = 1; i <= count; i++) {
42: B4 b4 = new B4();
43: b4.setAll(i);
44: store(b4);
45: }
46: commit();
47: }
48:
49: public void read() {
50: readExtent(B4.class);
51: }
52:
53: public void query() {
54: int count = setup().getSelectCount();
55: for (int i = 1; i <= count; i++) {
56: Query q = db().query();
57: q.constrain(B4.class);
58: q.descend("b2").constrain(i);
59: doQuery(q);
60: }
61: }
62:
63: public void delete() {
64: begin();
65: Query q = db().query();
66: q.constrain(B4.class);
67: ObjectSet deleteSet = q.execute();
68: while (deleteSet.hasNext()) {
69: db().delete(deleteSet.next());
70: addToCheckSum(5);
71: }
72: commit();
73: }
74:
75: }
|