Record collections are a Gnosis equivalent of a file.
A record collection may serve the function of many different
kinds of facilities on contemporary systems. The most common
ones are IBM files served by the access methods BSAM, QSAM,
BDAM, BPAM, ISAM, and VSAM. Record collections also serve
the function of directories.
A record collection contains a number of RECORD's. Each
record has a NAME, by which it is known, a STRING of bytes,
and perhaps a KEY. {Translation: we say "key" where others
say "capability", and we say "name" where others say "key".}
Each RC has a limit on the size of the
records it can accept. The size of a record is defined
as the sum of the lengths of the name and the string. The
largest limit available is 4057 bytes. {The reason for the
limit: the B-tree is based on a unit of a page, and there
is some space in the page used for control information.}
There is an ordering defined on names. It is the lexicographical
order on the binary bytes of the names. If two names of
unequal length match in their common number of initial characters,
the shorter one will precede the longer one.
There are two types of record collections, Name Sequenced
and Entry Sequenced. The type is declared when the record
collection is created. The calling sequences have been
kept as similar as possible to promote interchangeability
of programs and data.
Name Sequenced {NS} record collections
NS record collections are typically used for indexed
files and directories. A NAME in an NS record collection
consists of from 0 to 255 bytes. A record may have a KEY.
There are no restrictions on the contents of the name field.
In some record collections names will be variable length
upper case EBCDIC alphabetics, while in others, the names
will be fixed length binary values. Records may be added,
modified, and deleted in any time sequence within NS record
collections.
Entry Sequenced {ES} record collections
ES record collections are somewhat less general, and
similar to standard sequential and direct files in function.
A NAME is a four byte binary value. When the record is
entered into the record collection, the name is assigned
by the record collection. The value of the name will be
the sequential number of the record, beginning with 1 for
the first record entered into the collection. Records in
ES collections may not contain KEYS. The contents of an
ES record collection may be thought of as a sequence of
records in the same order as they were entered into the
record collection. Operations on ES record collections
have some restrictions designed to allow performance optimizations.
Record collections differ from the files of most other
systems in that they contain no internal information about
the last operation performed by a caller. Thus it is necessary
for each caller to specify the identity of each record desired.
The function of requesting the next record is accomplished
by presenting the name of the current record and asking
for the "succeeding" {or "preceding"} record. The positioning
cursor is thus kept in the calling domain. This tends to
simplify both domains, especially in the case of multiple
cursors referring to the same record collection.
A "user data" area, which may contain information about the
records in the record collection, is also maintained within
the record collection.
READ specific record
RC(OC,((1,LNM),(LNM,NM)); ==>
c,((1,LNM'),(LNM',NM'),(LST,ST));K)
The order code OC specifies the search criteria as follows:
8 - first record in record collection]
9 - record
with highest name less than NM] 10 - record with highest
name less than or equal to NM] 11 - record with name equal
to NM]
12 - record with lowest name greater than or equal
to NM] 13 - record with lowest name greater than NM] 14
- last record in record collection
C will be 0 or 1 if there is a record which matches
the requested search criterion. The NM', ST, and K of the
record are returned. C will be 1 if the record has a KEY
and 0 if it does not.
C will be 4 if there is no record meeting the specified criterion.
For ES record collections: If LNM = 0 then the name used
for the search is 4 bytes of zero. Otherwise, c will be
7 if LNM \= 4.
WRITE named record - NS only
RC(OC,((1,LNM),(LNM,NM),(LST,ST));K==>c,BS;K') attempts
to write a record in an NS record collection.
The order code OC specifies under what conditions the record
collection will be changed as follows:
If the new record is not to contain a KEY:
2 - Write or replace record.]
3 - Write new record.]
4
- Replace existing record.
If the new record is to contain KEY K:
5 - Write or replace record.]
6 - Write new record.]
7
- Replace existing record.
Three kinds of write operations are provided for the
convenience of programmers and for compatibility with access
methods on other systems. Most programs written for Gnosis
will probably use order codes 2 and 5 which always enter
the record into the record collection. Programs which care
whether a record is new or replaces an existing record may
utilize order codes 3, 4, 6, and 7 as appropriate.
C will be 0, 1, or 2 iff the record enters the record
collection.
If there was not already a record with name NM, c is
0.
If a record with name NM already existed, the name and string
of the replaced record will be returned in BS in the format
(1,LNM),(LNM,NM),(LST',ST').
If the old record had a key, c will be 1 and K' will
be that key.
If the record did not have a key, c will be 2 and K' will
be DK(0).
If write new is requested and the record already
exists, c will be 3. If write replace is requested and the
record does not exist, c will be 4. If the record collection
is full, c will be 5. For c>2, both BS and K' will be
null.
WRITE record - ES only
RC(OC,((1,4),(4,NM),(LST,ST));==>c,BS;) writes a record
in an entry sequenced record collection.
If NM = 0, the record will be appended to the record collection.
C will be 0 and BS will contain (1,4)(4,NM') where NM' is
the assigned name for the record. The value of NM' will
be equal to the number of records in the record collection
after the write operation completes. Thus, the first record
will be assigned NM = 1. C will be 5 and BS will be null
if there is no room for the record.
If NM \= 0, a replace operation is indicated. If a record
with name NM already existed in the record collection, c
will be 1 and the new record will replace the old one. C
will be 6 and the record collection will be unchanged if
the length of the specified record does not match the length
of the record to be replaced. In either case, BS will contain
the record which was in the record collection at the time
of the write operation. BS will be in the format (1,4),(4,NM),(LST,ST).
C will be 4 and BS will be null if there is no record
with name NM.
The order code OC specifies under what conditions the
record collection will be changed as follows:
If the new record does not contain a KEY: 2 - Write
or replace record. 3 - Write new record. {NM must be 0.}
4 - Replace existing record. {NM must not be 0.}
Three order codes are provided to allow programming
flexibility. The calling sequence matches that of write
to NS record collections for compatibility.
C will be 7 (invalid request) and BS will be null if any
of the following occur: OC is 3 and NM not equal to 0. OC
is 4 and NM equal to 0. First Byte of parameter string {length
of name} not equal to 4.
DELETE an existing record -
NS only
TRUNCATE unnamed record collection
- ES only
RC(OC,((1,4),(4,NM);==>c;) deletes the specified record
and returns c = 0. If OC = 16, the record with name NM and
all succeeding records in the record collection are deleted.
If OC = 17, only records following NM will be deleted.If
the operation is successful, c will be 0. If record NM (OC
= 16) or record NM+1 (OC = 17) does not exist, c will be
4 and no change will occur.
EMPTY a record collection
RC(1;==>c;) deletes all records in a record collection,
and returns c = 0.
Create weaker key
RC(0,((4,Restrictions));==>0,((4,OldRestrictions));RCW)
returns a new key RCW with access restrictions as specified
in the Restrictions field but limited to the restrictions
of RC. OldRestrictions will be the restrictions of RC.
The Restrictions field contains
32 bit switches defined as follows:]
BIT - MEANING IF
ON]
25 - Read user data operation is forbidden] 26
- Write user data operation is forbidden] 27 - Read
record operation is forbidden]
28 - Write new record
operation is forbidden] 29 - Update existing record operation
is forbidden] 30 - Delete record operation is forbidden]
31 - Empty, truncate and delete collection (kt+4) are
forbidden
Write user data
RC(18,(LSTR,STR);==>c,(LSTR,STR);) accepts up to 4000
bytes of user data in the string STR and returns c = 0 and
the previous value of the user data. The user data may be
used to describe the record collection in any manner desired.
{The first 4 bytes of the user data are returned in bytes
56-59 of the byte string response to a KT order code.} The
first 64 bytes of the user data are often used by the OS
simulation access methods for their own purposes. The remaining
bytes are available for exploitation.
Read user data
RC(19;==>c,(LSTR,STR);) returns c = 0 and the value
of the user data. {See (p2,rcwriteud).}
{ni}Return Segment containing
record names and string
RC(20,((1,LNM),(LNM,NM),(8,LSEG));SEG==>c;) where
c=0 and the first LSEG bytes of the segment SEG contain
the names and strings of the records beginning with record
NM in some unspecified format. If there are no records c
will be 2.
{ni}Return Segment containing
record string
RC(21,((1,LNM),(LNM,NM),(8,LSEG));SEG==>c;) works
like (p2,rcntseg) except the
segment does not contain the names.
{ni}Return Segment containing
record names
RC(22,((1,LNM),(LNM,NM),(8,LSEG));SEG==>c;) works
like (p2,rcntseg) except the
segment does not contain the strings.
RC(kt;==>c,BS;) returns x'16'
in c for Entry Sequence record collections and returns x'17'
for Name Sequence record collections. BS contains additional
information about the file in the following format:
Byte Length Value Meaning]
0 1 0 KT byte
string protocol]
1 1 0 Record collection KT
byte string format] 2 2 2 Record collection program
id] 4 2 1 Record collection program version]
6 2 0 Unused]
8 4 x0 Access restrictions
{(rc-restrict)}] 12 4 n
Number of records]
16 4 0-4095 Maximum string
length ever] 20 4 0-4095 Minimum string length ever]
24 4 0-255 Maximum name length ever]
28 4 0-255 Minimum name length ever]
32 4 mrl Record
size limit]
36 4 0 Unused]
40 8 x1
Time file last changed]
48 8 0 Unused]
56
4 x2 Embedded format indication from os simulation
x0 - See (p2,rcweaken)
x1 - Time of day clock value in standard epoch. {microseconds
since midnight, January 1, 1900}
x2 - will contain 0 if one record collection record corresponds
to one OS access method record. Several OS access methods
{such as VBS writes from Fortran I/O} produce multiple record
collection records for 1 Fortran logical record. In such
cases, x2 will contain an {as yet undefined} value indicating
the internal structure of the records. This value is communicated
to the record collection by the write user data operation
(p2,rcwriteud).
Return code summary. Values
of c {the return order code} for the various read and write
operations.
Return Code Meaning]
0 - New record added to
record collection Read operation completed successfully]
1
- A record with a key was replaced]
2 - A record without
a key was replaced]
3 - Write new, but record with specified
name exists] 4 - Write replace, but no record with name
exists] 5 - File is full.]
6 - Write replace, length
of new record does not equal length of old record]
7
- User error, invalid calling sequence]
8 - Rights of
key insufficient for the order code.] 9 - can't get enough
nodes from SB2]
10 - can't get enough pages from SB2]
12
- Attempt to add a record that exceeds the record size limit.]
11
- the request would cause the B-tree to exceed an implementation-defined
limit of 6 levels.
{nonref}See (