[Info-vax] Using index-sequential files from Java

Neil Rieck n.rieck at sympatico.ca
Sat Jan 9 19:54:00 EST 2010


On Jan 1, 7:04 pm, Arne Vajhøj <a... at vajhoej.dk> wrote:
> 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".

Well all I can say is many thanks. Last year one of the guys in my
shop started an equivalent project but real-world interruptions
prevented him from completing the task.

Neil Rieck
Kitchener / Waterloo / Cambridge,
Ontario, Canada.
http://www3.sympatico.ca/n.rieck/



More information about the Info-vax mailing list