001: /*
002: This file is part of the PolePosition database benchmark
003: http://www.polepos.org
004:
005: This program is free software; you can redistribute it and/or
006: modify it under the terms of the GNU General Public License
007: as published by the Free Software Foundation; either version 2
008: of the License, or (at your option) any later version.
009:
010: This program is distributed in the hope that it will be useful,
011: but WITHOUT ANY WARRANTY; without even the implied warranty of
012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: GNU General Public License for more details.
014:
015: You should have received a copy of the GNU General Public
016: License along with this program; if not, write to the Free
017: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
018: MA 02111-1307, USA. */
019:
020: package org.polepos.teams.jdo;
021:
022: import java.util.*;
023:
024: import javax.jdo.*;
025:
026: import org.polepos.circuits.bahrain.*;
027: import org.polepos.teams.jdo.data.*;
028:
029: public class BahrainJdo extends JdoDriver implements BahrainDriver {
030:
031: public void write() {
032:
033: begin();
034:
035: int numobjects = setup().getObjectCount();
036: int commitinterval = setup().getCommitInterval();
037:
038: int commitctr = 0;
039: for (int i = 1; i <= numobjects; i++) {
040:
041: JdoIndexedPilot p = new JdoIndexedPilot("Pilot_" + i,
042: "Jonny_" + i, i, i);
043: db().makePersistent(p);
044:
045: if (commitinterval > 0 && ++commitctr >= commitinterval) {
046: commitctr = 0;
047: commit();
048: begin();
049: Log.logger.fine("commit while writing at " + i + 1); //NOI18N
050: }
051: addToCheckSum(i);
052: }
053:
054: commit();
055: }
056:
057: public void query_indexed_string() {
058: int count = setup().getSelectCount();
059: String filter = "this.mName == param";
060: for (int i = 1; i <= count; i++) {
061: Query query = db().newQuery(JdoIndexedPilot.class, filter);
062: query.declareParameters("String param");
063: doQuery(query, "Pilot_" + i);
064: }
065: }
066:
067: public void query_string() {
068: int count = setup().getSelectCount();
069: String filter = "this.mFirstName == param";
070: for (int i = 1; i <= count; i++) {
071: Query query = db().newQuery(JdoIndexedPilot.class, filter);
072: query.declareParameters("String param");
073: doQuery(query, "Jonny_" + i);
074: }
075: }
076:
077: public void query_indexed_int() {
078: int count = setup().getSelectCount();
079: String filter = "this.mLicenseID == param";
080: for (int i = 1; i <= count; i++) {
081: Query query = db().newQuery(JdoIndexedPilot.class, filter);
082: query.declareParameters("Integer param");
083: doQuery(query, new Integer(i));
084: }
085: }
086:
087: public void query_int() {
088: int count = setup().getSelectCount();
089: String filter = "this.mPoints == param";
090: for (int i = 1; i <= count; i++) {
091: Query query = db().newQuery(JdoIndexedPilot.class, filter);
092: query.declareParameters("Integer param");
093: doQuery(query, new Integer(i));
094: }
095: }
096:
097: public void update() {
098:
099: begin();
100: int updateCount = setup().getUpdateCount();
101: Extent extent = db().getExtent(JdoIndexedPilot.class, false);
102: Iterator it = extent.iterator();
103: for (int i = 1; i <= updateCount; i++) {
104: JdoIndexedPilot p = (JdoIndexedPilot) it.next();
105: p.setName(p.getName().toUpperCase());
106: addToCheckSum(1);
107: }
108: extent.closeAll();
109: commit();
110: }
111:
112: public void delete() {
113: begin();
114: Extent extent = db().getExtent(JdoIndexedPilot.class, false);
115: Iterator it = extent.iterator();
116: while (it.hasNext()) {
117: db().deletePersistent(it.next());
118: addToCheckSum(1);
119: }
120: extent.closeAll();
121: commit();
122: }
123:
124: }
|