[Info-vax] Using index-sequential files from Java
Arne Vajhøj
arne at vajhoej.dk
Fri Jan 1 19:04:59 EST 2010
A long time ago there were a discussion about using index-sequential
files from Java.
The answer was to use some JNI code, because HP did not
supply some library for doing it.
That got me started at doing such a library.
It took a long time due to lack of time.
But something is ready now.
Download link:
http://www.vajhoej.dk/arne/opensource/isam/
See below for a quick description of how it works.
Arne
=====================================
POJO class
import java.io.Serializable;
import dk.vajhoej.isam.KeyField;
import dk.vajhoej.record.FieldType;
import dk.vajhoej.record.Struct;
import dk.vajhoej.record.StructField;
@Struct
public class Data implements Serializable {
@KeyField(n=0)
@StructField(n=0,type=FieldType.INT4)
private int iv;
@StructField(n=1,type=FieldType.FP8)
private double xv;
@StructField(n=2,type=FieldType.FIXSTR,length=8,encoding="ISO-8859-1")
private String sv;
public int getIv() {
return iv;
}
public void setIv(int iv) {
this.iv = iv;
}
public double getXv() {
return xv;
}
public void setXv(double xv) {
this.xv = xv;
}
public String getSv() {
return sv;
}
public void setSv(String sv) {
this.sv = sv;
}
}
The class got a @Struct annotation. Each field in the class got a
@StructField annotation with an element n that determines the order of
the fields and an element type that describes the datatype in the native
struct plus some optional elements that are needed for some field types.
Each key field in the class got a @KeyField annotation with an element n
that determines the order of the key fields.
code fragments
// open
IsamSource isam = new LocalIsamSource(filename, providername, readonly);
// create record
Data obj = new Data();
...
isam.create(obj);
// read record
Data obj = isam.read(Data.class, new Key0<Integer>(123));
// update record
Data obj = new Data();
...
isam.update(obj);
// delete record
isam.delete(Data.class, new Key0<Integer>(123));
// close
isam.close();
Examples of simple CRUD operations.
The providername for OpenVMS index sequential files is
"dk.vajhoej.vms.rms.IndexSequential".
More information about the Info-vax
mailing list