KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > polepos > teams > jdo > BahrainJdo


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.jdo;
21
22 import java.util.*;
23
24 import javax.jdo.*;
25
26 import org.polepos.circuits.bahrain.*;
27 import org.polepos.teams.jdo.data.*;
28
29
30
31 public class BahrainJdo extends JdoDriver implements BahrainDriver{
32     
33     public void write(){
34         
35         begin();
36         
37         int numobjects = setup().getObjectCount();
38         int commitinterval = setup().getCommitInterval();
39         
40         int commitctr = 0;
41         for ( int i = 1; i <= numobjects; i++ ){
42             
43              
44             JdoIndexedPilot p = new JdoIndexedPilot( "Pilot_" + i, "Jonny_" + i, i , i );
45             db().makePersistent( p );
46             
47             if ( commitinterval > 0 && ++commitctr >= commitinterval ){
48                 commitctr = 0;
49                 commit();
50                 begin();
51                 Log.logger.fine( "commit while writing at " + i+1 ); //NOI18N
52
}
53             addToCheckSum(i);
54         }
55         
56         commit();
57     }
58     
59     
60  
61     public void query_indexed_string() {
62         int count = setup().getSelectCount();
63         String JavaDoc filter = "this.mName == param";
64         for (int i = 1; i <= count; i++) {
65             Query query = db().newQuery(JdoIndexedPilot.class, filter);
66             query.declareParameters("String param");
67             doQuery(query, "Pilot_" + i);
68         }
69     }
70     
71     
72             
73     public void query_string() {
74         int count = setup().getSelectCount();
75         String JavaDoc filter = "this.mFirstName == param";
76         for (int i = 1; i <= count; i++) {
77             Query query = db().newQuery(JdoIndexedPilot.class, filter);
78             query.declareParameters("String param");
79             doQuery(query, "Jonny_" + i);
80         }
81     }
82
83     public void query_indexed_int() {
84         int count = setup().getSelectCount();
85         String JavaDoc filter = "this.mLicenseID == param";
86         for (int i = 1; i <= count; i++) {
87             Query query = db().newQuery(JdoIndexedPilot.class, filter);
88             query.declareParameters("Integer param");
89             doQuery(query, new Integer JavaDoc(i));
90         }
91     }
92
93     public void query_int() {
94         int count = setup().getSelectCount();
95         String JavaDoc filter = "this.mPoints == param";
96         for (int i = 1; i <= count; i++) {
97             Query query = db().newQuery(JdoIndexedPilot.class, filter);
98             query.declareParameters("Integer param");
99             doQuery(query, new Integer JavaDoc(i));
100         }
101     }
102
103     public void update() {
104         
105         begin();
106         int updateCount = setup().getUpdateCount();
107         Extent extent = db().getExtent(JdoIndexedPilot.class, false);
108         Iterator it = extent.iterator();
109         for (int i = 1; i <= updateCount; i++) {
110             JdoIndexedPilot p = (JdoIndexedPilot)it.next();
111             p.setName( p.getName().toUpperCase() );
112             addToCheckSum(1);
113         }
114         extent.closeAll();
115         commit();
116     }
117     
118     public void delete() {
119         begin();
120         Extent extent = db().getExtent(JdoIndexedPilot.class, false);
121         Iterator it = extent.iterator();
122         while(it.hasNext()){
123             db().deletePersistent(it.next());
124             addToCheckSum(1);
125         }
126         extent.closeAll();
127         commit();
128     }
129
130 }
131
Popular Tags