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.prevayler.bahrain;
021:
022: import org.polepos.circuits.bahrain.*;
023: import org.polepos.data.*;
024: import org.polepos.framework.*;
025: import org.polepos.teams.prevayler.*;
026:
027: import com.db4o.*;
028: import com.db4o.query.*;
029:
030: public class BahrainPrevaylerDriver extends PrevaylerDriver implements
031: BahrainDriver {
032:
033: private final BahrainSystem _bahrainSystem = (BahrainSystem) _prevayler
034: .prevalentSystem();
035:
036: public void write() {
037: int objectsToWrite = setup().getObjectCount();
038: int commitInterval = setup().getCommitInterval();
039:
040: while (objectsToWrite > 0) {
041: int objectsToWriteNow = objectsToWrite < commitInterval ? objectsToWrite
042: : commitInterval;
043: _prevayler.execute(new ObjectCreationTransaction(
044: objectsToWriteNow));
045: objectsToWrite -= commitInterval;
046: }
047: }
048:
049: public void query_indexed_string() {
050: int count = setup().getSelectCount();
051: for (int i = 1; i <= count; i++) {
052: Pilot p = _bahrainSystem.pilotByName("Pilot_" + i);
053: addToCheckSum(p.checkSum());
054: }
055: }
056:
057: public void query_string() {
058: int count = setup().getSelectCount();
059: for (int i = 1; i <= count; i++) {
060: Pilot p = _bahrainSystem.pilotByFirstName("Jonny_" + i);
061: addToCheckSum(p.checkSum());
062: }
063: }
064:
065: public void query_indexed_int() {
066: int count = setup().getSelectCount();
067: for (int i = 1; i <= count; i++) {
068: Pilot p = _bahrainSystem.pilotByLicenseID(i);
069: addToCheckSum(p.checkSum());
070: }
071: }
072:
073: public void query_int() {
074: // int count = setup().getSelectCount();
075: // for (int i = 1; i <= count; i++) {
076: // Query q = db().query();
077: // q.constrain( Pilot.class );
078: // q.descend( "mPoints" ).constrain(new Integer(i));
079: // doQuery( q );
080: // }
081: }
082:
083: public void update() {
084: // int updateCount = setup().getUpdateCount();
085: // Query q = db().query();
086: // q.constrain( Pilot.class );
087: // ObjectSet set = q.execute();
088: // for (int i = 1; i <= updateCount; i++) {
089: // Pilot p = (Pilot)set.next();
090: // p.setName( p.getName().toUpperCase() );
091: // db().set(p);
092: // addToCheckSum(1);
093: // }
094: // db().commit();
095: }
096:
097: public void delete() {
098: // Query q = db().query();
099: // q.constrain( Pilot.class );
100: // ObjectSet deleteset = q.execute();
101: // while ( deleteset.hasNext() ){
102: // db().delete( deleteset.next() );
103: // addToCheckSum(1);
104: // }
105: // db().commit();
106: }
107:
108: protected Object prevalentSystem() {
109: //return new BahrainSystem();
110: return null;
111: }
112:
113: }
|