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.Iterator;
023: import javax.jdo.Extent;
024:
025: import org.polepos.circuits.melbourne.*;
026: import org.polepos.teams.jdo.data.*;
027:
028: /**
029: * @author Herkules
030: */
031: public class MelbourneJdo extends JdoDriver implements MelbourneDriver {
032:
033: public void write() {
034:
035: begin();
036:
037: int numobjects = setup().getObjectCount();
038: int commitinterval = setup().getCommitInterval();
039:
040: int commitctr = 0;
041: for (int i = 1; i <= numobjects; i++) {
042:
043: JdoPilot p = new JdoPilot("Pilot_" + i, i);
044: db().makePersistent(p);
045:
046: if (commitinterval > 0 && ++commitctr >= commitinterval) {
047: commitctr = 0;
048: commit();
049: begin();
050: Log.logger.fine("commit while writing at " + i + 1); //NOI18N
051: }
052: addToCheckSum(i);
053: }
054:
055: commit();
056: }
057:
058: public void read() {
059: readExtent(JdoPilot.class);
060: }
061:
062: public void read_hot() {
063: read();
064: }
065:
066: public void delete() {
067:
068: int numobjects = setup().getObjectCount();
069: int commitinterval = setup().getCommitInterval();
070:
071: begin();
072:
073: Extent extent = db().getExtent(JdoPilot.class, false);
074: Iterator itr = extent.iterator();
075: int commitctr = 0;
076: for (int i = 0; i < numobjects; i++) {
077:
078: JdoPilot p = (JdoPilot) itr.next();
079: db().deletePersistent(p);
080:
081: if (commitinterval > 0 && ++commitctr >= commitinterval) {
082: commitctr = 0;
083:
084: // Debugging VOA: commit() seems to close the extent anyway
085: // so we can do it here
086: extent.closeAll();
087:
088: commit();
089: begin();
090: Log.logger.fine("commit while deleting at " + i + 1); //NOI18N
091:
092: // Debugging VOA: If we close the extent, we have to open it
093: // again of course.
094: extent = db().getExtent(JdoPilot.class, false);
095: itr = extent.iterator();
096: }
097: }
098:
099: commit();
100:
101: extent.closeAll();
102: }
103: }
|