Data storage

This section explains how information can be entered into database and how to retrieve or delete information.

Under HEPDB the user can store data structures created under the ZEBRA system in the database. These ZEBRA data structures can range from a single ZEBRA bank through to a complex ZEBRA data structure. When data is submitted for inclusion to the database the pathname of the directory where the data is to reside and the key vector must also be supplied.

HEPDB also provides facilities for the storage of other data types. Note that the data is always converting into ZEBRA banks, but that this conversion is automatic and transparent to the user. These facilities include the routines CDTEXT, CDCHAR and CDVECT which allow the storage of text files , character data and vectors respectively.

Storing a ZEBRA data structure

Providing the directory in which the data is to reside in has already been created and the data structure is already in memory the user can store the data in memory to disk by use of the routine CDSTOR. A demonstration of this routine is shown in the above program to convert an existing RZ database.

The storage of text file data

Whilst discussing HEPDB's storage facilities we shall examine briefly how the routine CDTEXT allows us to store text files under HEPDB. It achieves this by converting a text file to or from a ZEBRA structure suitable for storage under HEPDB.

Suppose we had a file (for this examples sake residing on VM) that we wished to store under HEPDB. Assuming the name of the file was TEST TEXT A1 we could use a call similar to the following to retrieve the file from disk and to return the address of the ZEBRA bank now containing it ready for insertion to the database.

               Storage of a text file - example call
                                  

*
*     LUN for textfile access
*
      TXLUN=10
*
      CALL CDTEXT(TXLUN,'TEST.TEXT.A1',PATH,LBANK,'R',IRC)

The character option 'R' intructs the CDTEXT routine to read the file from disk. In this case the bank address will be returned in LBANK.

Storage of character based data

The storage of character based data is performed by the routine CDCHAR which has similar functionality to the previously described CDTEXT routine, except that the data is moved from and to character arrays rather than text files.

Storage of vector based data

Once again the storage of vector data is allowed by converting vectors to the ZEBRA bank format before committing that bank to the database. The routine available for this operation is CDVECT.

To demonstrate this imagine that one of the example databases we wish to convert from the RZ format currently consists not of ZEBRA banks but of FORTRAN integer vectors.

The conversion program must now read in the vectors and convert them to a HEPDB format before they can be stored in the database. The code shown below offers a suggestion of how the previous conversion program could be modified to handle this storage of vectors.

              Example of data conversion using CDVECT
                                  

                  .
                  . other code
                  .
c|
c|       Zero temporary vector, then fill with next object
c|
         CALL VZERO(ITEMPVECT,80000)
         CALL RZVIN(ITEMPVECT,80000,NFILE,RZKYTOGET,ICYCLE,' ')
         IF(IQUEST(1).NE.0) THEN
              PRINT *,' Error! RZVIN gives ',IQUEST(1)
              STOP
         ENDIF
         PRINT *,' No. of elements in RZ vector :',NFILE
                  .
                  . other code
                  .
c|
c|       Convert the array to a ZEBRA data structure
c|
         CALL CDVECT(' ',ITEMPVECT,NFILE,LADDR,'PI',IRC)
         IF(IRC.NE.0) THEN
              PRINT *,' Error! CDVECT IRC=',IRC
              STOP
         ENDIF
c|
c|       Now store bank at LADDR under HEPDB
c|
         DEST='//CDAU/AUX/'//CHDIR(9:LDIR)
         PRINT*,' Destination path : ',DEST
         CALL CDSTOR(DEST,LADDR,LKYBK,IDIV,HDBKEYS,'H',IRC)
         IF (IRC.NE.0) THEN
              PRINT *,' Error! CDSTOR IRC=',IRC
              STOP
         ENDIF
                  .
                  . other code
                  .
      CALL CDSTSV(' ',0,IRC)
      CALL RZCDIR(CHSAVE(1:LDIR),' ')
      PRINT *,' '
      END