⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bahrainperst.java

📁 个人感觉非常不错的poleperst-acid
💻 JAVA
字号:
/* 
This file is part of the PolePosition database benchmark
http://www.polepos.org

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA  02111-1307, USA. */

package org.polepos.teams.perst;

import org.polepos.circuits.bahrain.*;
import org.polepos.framework.*;

import org.garret.perst.*;



/**
 * @author Knizhnik
 */
public class BahrainPerst extends PerstDriver implements BahrainDriver {
    Indices indices;

    static class Indices extends Persistent { 
        FieldIndex<PerstPilot> nameIndex;
        FieldIndex<PerstPilot> licenseIndex;

        Indices(Storage db) { 
            nameIndex = db.<PerstPilot>createFieldIndex(PerstPilot.class, "mName", true);
            licenseIndex = db.<PerstPilot>createFieldIndex(PerstPilot.class, "mLicenseID", true);
        }
        Indices() {}
    }
	
    protected void initialize() { 
        indices = (Indices)db.getRoot();
        if (indices == null) { 
            indices = new Indices(db);
            db.setRoot(indices);
        }
    }
	
    public void write(){
        int commitctr = 0;
        int count = setup().getObjectCount();
        int commitInterval = setup().getCommitInterval();
        for ( int i = 1; i <= count; i++ ) {
            PerstPilot pilot = new PerstPilot( "Pilot_" + i, "Jonny_" + i, i , i );
            indices.nameIndex.put(pilot);
            indices.licenseIndex.put(pilot);
            if ( commitInterval> 0  &&  ++commitctr >= commitInterval) {
                commitctr = 0;
                commit();
            }
            addToCheckSum(i);
        }
        commit();
    }
 
    public void query_indexed_string() {
        int count = setup().getSelectCount();
        for (int i = 1; i <= count; i++) {
            addToCheckSum(indices.nameIndex.get("Pilot_" + i).checkSum());
        }
    }
            
    public void query_string() {
        int count = setup().getSelectCount();
        for (int i = 1; i <= count; i++) {
            iterate(indices.nameIndex.select("mFirstName='" + "Jonny_" + i + "'"));
        }
    }

    public void query_indexed_int() {
        int count = setup().getSelectCount();
        for (int i = 1; i <= count; i++) {
            addToCheckSum(indices.licenseIndex.get(i).checkSum());
        }
    }

    public void query_int() {
        int count = setup().getSelectCount();
        for (int i = 1; i <= count; i++) {
            for (PerstPilot pilot : indices.licenseIndex) { 
                if (pilot.getPoints() == i) { 
                    addToCheckSum(pilot.checkSum());
                }
            }
        }
    }

    public void update() {
        int updateCount = setup().getUpdateCount();
        for (PerstPilot p : indices.licenseIndex) { 
            if (updateCount-- == 0) { 
                break;
            }
            indices.nameIndex.remove(p);
            p.setName( p.getName().toUpperCase() );
            indices.nameIndex.put(p);
            p.store();
            addToCheckSum(1);
        }
    	commit();
    }
	
    public void delete() {
        for (PerstPilot p : indices.licenseIndex) { 
            p.deallocate();
        }
        indices.nameIndex.clear();
        indices.licenseIndex.clear();
    	commit();
    }	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -