KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > polepos > teams > prevayler > bahrain > BahrainPrevaylerDriver


1 /*
2 This file is part of the PolePosition database benchmark
3 http://www.polepos.org
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
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.prevayler.bahrain;
21
22 import org.polepos.circuits.bahrain.*;
23 import org.polepos.data.*;
24 import org.polepos.framework.*;
25 import org.polepos.teams.prevayler.*;
26
27 import com.db4o.*;
28 import com.db4o.query.*;
29
30
31 public class BahrainPrevaylerDriver extends PrevaylerDriver implements BahrainDriver{
32     
33     private final BahrainSystem _bahrainSystem = (BahrainSystem)_prevayler.prevalentSystem();
34
35     public void write(){
36         int objectsToWrite= setup().getObjectCount();
37         int commitInterval= setup().getCommitInterval();
38         
39         while (objectsToWrite > 0) {
40             int objectsToWriteNow = objectsToWrite < commitInterval
41                 ? objectsToWrite
42                 : commitInterval;
43             _prevayler.execute(new ObjectCreationTransaction(objectsToWriteNow));
44             objectsToWrite -= commitInterval;
45         }
46     }
47  
48     public void query_indexed_string() {
49         int count = setup().getSelectCount();
50         for (int i = 1; i <= count; i++) {
51             Pilot p = _bahrainSystem.pilotByName("Pilot_" + i);
52             addToCheckSum(p.checkSum());
53         }
54     }
55             
56     public void query_string() {
57         int count = setup().getSelectCount();
58         for (int i = 1; i <= count; i++) {
59             Pilot p = _bahrainSystem.pilotByFirstName("Jonny_" + i);
60             addToCheckSum(p.checkSum());
61         }
62     }
63
64     public void query_indexed_int() {
65         int count = setup().getSelectCount();
66         for (int i = 1; i <= count; i++) {
67             Pilot p = _bahrainSystem.pilotByLicenseID(i);
68             addToCheckSum(p.checkSum());
69         }
70     }
71
72     public void query_int() {
73 // int count = setup().getSelectCount();
74
// for (int i = 1; i <= count; i++) {
75
// Query q = db().query();
76
// q.constrain( Pilot.class );
77
// q.descend( "mPoints" ).constrain(new Integer(i));
78
// doQuery( q );
79
// }
80
}
81
82     public void update() {
83 // int updateCount = setup().getUpdateCount();
84
// Query q = db().query();
85
// q.constrain( Pilot.class );
86
// ObjectSet set = q.execute();
87
// for (int i = 1; i <= updateCount; i++) {
88
// Pilot p = (Pilot)set.next();
89
// p.setName( p.getName().toUpperCase() );
90
// db().set(p);
91
// addToCheckSum(1);
92
// }
93
// db().commit();
94
}
95     
96     public void delete() {
97 // Query q = db().query();
98
// q.constrain( Pilot.class );
99
// ObjectSet deleteset = q.execute();
100
// while ( deleteset.hasNext() ){
101
// db().delete( deleteset.next() );
102
// addToCheckSum(1);
103
// }
104
// db().commit();
105
}
106
107     protected Object JavaDoc prevalentSystem() {
108         //return new BahrainSystem();
109
return null;
110     }
111     
112 }
113
Popular Tags