DBCommon.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by
MBrown on December 14, 1982 2:16 pm
Cattell on November 10, 1983 2:10 am
Willie-Sue on: February 18, 1985 8:37:49 am PST
Donahue, March 3, 1986 7:47:12 am PST
Widom, September 6, 1985 6:44:23 pm PDT
DIRECTORY
AlpTransaction USING[Handle],
Atom USING [GetPropFromList],
Commander USING [Handle],
PrincOps USING [wordsPerPage],
Rope USING[ROPE],
IO USING [STREAM],
ProcessProps USING [GetPropList];
DBCommon: CEDAR DEFINITIONS
IMPORTS Atom, ProcessProps
= BEGIN
This interface contains things that don't fit anywhere else.
SegmentIndex: TYPE = INT [0 .. 512);
number to identify a segment
Segment: TYPE = ATOM;
Transaction: TYPE = AlpTransaction.Handle;
TransactionHandle: TYPE = REF TransactionObject;
TransactionObject: TYPE = RECORD[trans: Transaction, segments: SegmentList];
SegmentList: TYPE = REF SegmentListObject;
SegmentListObject: TYPE = RECORD[segment: Segment, next: SegmentList];
FirstLast: TYPE = {First, Last} ← First;
used to define which end of an enumeration to start on
TID: TYPE = LONG CARDINAL ← 0;
A pointer to a tuple in the database. Its structure is given by the procedures in DBStorageTID
TupleHandle: TYPE = REF TupleObject;
TupleObject: TYPE = RECORD[
tid: TID,
succ, pred: TupleHandle,
The tuples handles currently allocated are linked (by segment) in a list so that they can be nullified when necessary
cacheHint: CacheHandle
hint in finding the cache page for the tid
];
A CacheHandle represents an association between a database page and a core page. This association is guaranteed while the page is "locked", but may be broken at other times. Access to a page is more efficient if the CacheHandle is known in addition to the DBPage address, since hashing is avoided.
CacheHandle: TYPE = REF CacheRecord;
CacheRecord: TYPE = RECORD
[
dbPage: DBCommon.DBPage,
database page number
pagePtr: LONG POINTER,
location of the cache page in memory
lockCount: [0..7777B] ← 0,
incremented by read page, write page; decremented by unlock page. If >0, page will not move in core or leave cache.
occupied: BOOLFALSE,
true if this page contains valid data (is contained in ht).
written: BOOLFALSE,
true if this page has been written, needs to be stored back to file system.
readonly: BOOLFALSE,
true iff this page cannot be written (according to the file system).
pred: CacheHandle,
succ: CacheHandle,
Doubly-linked list of cache handles, used to maintain LRU information.
hashChain: CacheHandle
Singly-linked list of cache handles, used to resolve hash table collisions.
];
IndexKey: TYPE = LONG POINTER TO READONLY KeyBody;
KeyBody: TYPE = MACHINE DEPENDENT RECORD [
text: PACKED SEQUENCE length: CARDINAL OF CHAR ];
READONLY Index keys are accessible through the DBStorage interface
softwareCompatibilityVersion: INTEGER = 5;
Version of DB software.
When new segment are created, five indices are established for use by Cypress itself. These include indices on the names of domain, relations and attributes and indices on the types of attributes and the relations to which attributes belong.
systemIndexCount: CARDINAL = 2;
domainIndex: CARDINAL = 0; -- the index on the set of domains (by name)
relationIndex: CARDINAL = 1; -- the index on the set of relations (by name)
DBPage: TYPE = LONG CARDINAL;
"Virtual address" of a page in a database. Interpreted by the segment implementation
only. DBSegmentPrivate and DBStorageTID include definitions relevant to more
detailed interpretation.
NullDBPage: DBPage = 0;
A DBPage address that represents "no page" (NIL, used to terminate lists).
NotOnList: DBPage = LAST[LONG CARDINAL];
A DBPage address that represents "page not part of a list".
PagesPerDBPage: CARDINAL = 1;
WordsPerPage: CARDINAL = PagesPerDBPage * PrincOps.wordsPerPage;
the rest are all defined in terms of WordsPerPage
BytesPerPage: CARDINAL = 2*WordsPerPage;
LogOfWordsPerPage: CARDINAL = 8;
LogOfBytesPerPage: CARDINAL = LogOfWordsPerPage+1;
MaskOfWordsPerPage: CARDINAL = WordsPerPage-1;
MaskOfBytesPerPage: CARDINAL = BytesPerPage-1;
PagesForBytes: PROC [nBytes: LONG CARDINAL] RETURNS[CARDINAL] = INLINE {
RETURN[nBytes/BytesPerPage]};
VersionOptions: TYPE = {NewFileOnly, OldFileOnly, None};
Versions that may be specified to ObtainFile.
SegmentID: TYPE = DBPage; -- with lots of low-order zeroes.
OpenFileHandle: TYPE = REF ANY;
Common IO stream procs
GetDebugStream: PROC RETURNS [IO.STREAM] = INLINE
Gives a place to print debugging info; creates Viewer typescript on screen.
{ ch: Commander.Handle←
NARROW[Atom.GetPropFromList[ProcessProps.GetPropList[], $CommanderHandle]];
RETURN [ch.out]};
END.--DBCommon