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

📄 barcelonaperst.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.barcelona.BarcelonaDriver;
import org.polepos.framework.*;

import org.garret.perst.*;


class B0 extends Persistent {

    private int b0;
    
    public B0(){
    }
    
    public B0(int i0) {
        b0 = i0;
    }

    public void setB0(int i){
        b0 = i;
    }
    
    public int getB0(){
        return b0;
    }

}

class B1 extends B0 {    

    private int b1;
    
    public B1(){
    }
    
    public B1(int i0, int i1) {
        super(i0);
        b1 = i1;
    }

    public void setB1(int i){
        b1 = i;
    }
    
    public int getB1(){
        return b1;
    }
}

class B2 extends B1 {
    
    private int b2;  // index this one for queries
    
    public B2(){
    }
    
    public B2(int i0, int i1, int i2) {
        super(i0, i1);
        b2 = i2;
    }

    public void setB2(int i){
        b2 = i;
    }
    
    public int getB2(){
        return b2;
    }
}

class B3 extends B2 {
    
    private int b3;
    
    public B3(){
    }
    
    public B3(int i0, int i1, int i2, int i3) {
        super(i0, i1, i2);
        b3 = i3;
    }

    public void setB3(int i){
        b3 = i;
    }
    
    public int getB3(){
        return b3;
    }
}

class B4 extends B3 implements CheckSummable { 
   
    public B4(){
    }
    
    public B4(int i0, int i1, int i2, int i3, int i4){
        super(i0, i1, i2, i3);
        b4 = i4;
    }
    
    private int b4;
    
    public void setB4(int i){
        b4 = i;
    }
    
    public int getB4(){
        return b4;
    }

    public long checkSum() {
        return b4;
    }
    
    public void setAll(int i){
        setB0(i);
        setB1(i);
        setB2(i);
        setB3(i);
        setB4(i);
    }
    
    public int getBx(int x){
        if(x == 0){
            return getB0();
        }
        if(x == 1){
            return getB1();
        }
        if(x == 2){
            return getB2();
        }
        if(x == 3){
            return getB3();
        }
        if(x == 4){
            return getB4();
        }
        throw new IllegalArgumentException();
    }

}


public class BarcelonaPerst extends PerstDriver implements BarcelonaDriver{
    FieldIndex<B4> extent;

    protected void initialize() { 
        extent = (FieldIndex<B4>)db.getRoot();
        if (extent == null) { 
            extent = db.<B4>createFieldIndex(B4.class, "b2", true);
            db.setRoot(extent);
        }
    }
	
    public void write(){
        int count = setup().getObjectCount();
        for (int i = 1; i <= count; i++) {
            B4 b4 = new B4();
            b4.setAll(i);
            extent.put(b4);
        }
        commit();
    }
    
    public void read() {
        iterate(extent.iterator());
    }
    
    public void query(){
        int count = setup().getSelectCount();
        for (int i = 1; i <= count; i++) {
            addToCheckSum(extent.get(i).checkSum());
        }
    }
    
    public void delete(){
        for (B4 o : extent) { 
            o.deallocate();
            addToCheckSum(5);
        }
        extent.clear();
        commit();
    }
}

⌨️ 快捷键说明

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