<> <> <> <> <> <> <> <> DIRECTORY AlpTransaction USING[Handle], Atom USING [GetPropFromList], Basics, Commander USING [Handle], PrincOps USING [wordsPerPage], PrincOpsUtils, Rope USING[ROPE], IO USING [STREAM], ProcessProps USING [GetPropList]; DBCommon: CEDAR DEFINITIONS IMPORTS Atom, ProcessProps, PrincOpsUtils = BEGIN <<>> <> InternalError: ERROR; SegmentIndex: TYPE = INT [0 .. 512); <> 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; <> TID: TYPE = LONG CARDINAL _ 0; <> <> DBPageIncrement: CARDINAL = 100B; TIDSlotMask: CARDINAL = DBPageIncrement - 1; --000077B TIDLowPageMask: CARDINAL = LAST[CARDINAL] - TIDSlotMask; --177700B DecomposeTID: PROCEDURE[tid: TID] RETURNS[page: DBPage, slot: CARDINAL] = INLINE BEGIN <> slotIndex: CARDINAL; TRUSTED { slotIndex _ PrincOpsUtils.BITAND[LOOPHOLE[tid, num Basics.LongNumber].lowbits, TIDSlotMask]; LOOPHOLE[tid, num Basics.LongNumber].lowbits _ PrincOpsUtils.BITAND[LOOPHOLE[tid, num Basics.LongNumber].lowbits, TIDLowPageMask]; }; RETURN[tid, slotIndex]; END;--DecomposeTID ConsTID: PROCEDURE[p: DBPage, slotIndex: CARDINAL] RETURNS[tid: TID] = INLINE BEGIN <> IF slotIndex > TIDSlotMask THEN ERROR InternalError; -- BadSlotIndex RETURN[p + slotIndex]; END;--ConsTID NullTID: TID = 0; TupleHandle: TYPE = REF TupleObject; TupleObject: TYPE = RECORD[ tid: TID, succ, pred: TupleHandle, <> cacheHint: CacheHandle <> ]; <> <<>> CacheHandle: TYPE = REF CacheRecord; CacheRecord: TYPE = RECORD [ dbPage: DBCommon.DBPage, <> pagePtr: LONG POINTER, <> lockCount: [0..7777B] _ 0, <0, page will not move in core or leave cache.>> occupied: BOOL _ FALSE, <> written: BOOL _ FALSE, <> readonly: BOOL _ FALSE, <> pred: CacheHandle, succ: CacheHandle, <> hashChain: CacheHandle <> ]; IndexKey: TYPE = LONG POINTER TO READONLY KeyBody; KeyBody: TYPE = MACHINE DEPENDENT RECORD [ text: PACKED SEQUENCE length: CARDINAL OF CHAR ]; <> softwareCompatibilityVersion: INTEGER = 5; <> <> 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>> <> <> NullDBPage: DBPage = 0; <> NotOnList: DBPage = LAST[LONG CARDINAL]; <> PagesPerDBPage: CARDINAL = 1; WordsPerPage: CARDINAL = PagesPerDBPage * PrincOps.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}; <> SegmentID: TYPE = DBPage; -- with lots of low-order zeroes. OpenFileHandle: TYPE = REF ANY; <> GetDebugStream: PROC RETURNS [IO.STREAM] = INLINE <> { ch: Commander.Handle_ NARROW[Atom.GetPropFromList[ProcessProps.GetPropList[], $CommanderHandle]]; RETURN [ch.out]}; END.--DBCommon