-- File DBStorageConcrete.mesa
-- Last edited by
--   Cattell on  7-Jul-81 10:13:24
--   MBrown on December 2, 1982 2:54 pm


  DIRECTORY
    DBCache USING[CacheHandle],
    DBCommon USING[DBPage, NullDBPage],
    DBIndex USING[RealIndexHandle, IndexKey],
    DBStorageVec USING[VecPage],
    DBStorageTID USING[TID],
    DBStorage USING[SystemTupleID, FieldHandle, FirstLast, TupleHandle];

DBStorageConcrete: DEFINITIONS = BEGIN
  -- This interface defines the concrete representations of opaque types in DBStorage..


  FieldObject: TYPE = MACHINE DEPENDENT RECORD[
    -- Concrete version of DBStorage.FieldObject.  All variants are 5 words long.
    fieldType: FieldType ← NULL,
    offset: CARDINAL ← NULL,
    nWords: CARDINAL ← NULL,
    typeDependent: SELECT OVERLAID * FROM
      regular => [fill1: LONG CARDINAL ← NULL],
      group =>   [groupID: DBStorageTID.TID ← NULL],
    ENDCASE
  ];--FieldObject

  FieldType: TYPE = MACHINE DEPENDENT
   {OneWord(1), TwoWord, NWord, VarWord, VarByte, Group, (LAST[CARDINAL])};


  GroupScanHandle: TYPE = REF GroupScanObject;
  GroupScanObject: TYPE = RECORD[
    tidFieldHandle: DBStorage.FieldHandle,
      -- field handle for Group field being scanned.  NIL => invalid handle.
    headOfGroup: DBStorage.TupleHandle,
      -- tuple on the "one" side of the group
    prevInScan: DBStorage.TupleHandle ← NIL,
      -- if prevInScan = NIL, then scan is before start of "many" side. After an insertion
      --(WriteTID), the inserted tuple is here.
    nextInScan: DBStorage.TupleHandle ← NIL,
      -- if nextInScan = NIL, then scan is after end of "many" side
    link: GroupScanHandle ← NIL
      -- used to form singly-linked list of active group scans
  ];--GroupScanObject


  IndexScanHandle: TYPE = REF IndexScanObject;

  IndexScanObject: TYPE = RECORD [
    front, back: IndexScanHandle,
    tree: DBIndex.RealIndexHandle,
    this: DBCommon.DBPage,
    index: CARDINAL,
    free: BOOLEAN,
    start: DBStorage.FirstLast,
    lowerBound, upperBound: DBIndex.IndexKey,
    includeLowerBound, includeUpperBound: BOOLEAN,
    lowerBoundInfinity, upperBoundInfinity: BOOLEAN
  ];--IndexScanObject

  SystemTuplesetObject: TYPE = RECORD[
    tuplesetID: DBStorage.SystemTupleID,
    wordsForTupleFields: CARDINAL
  ];--SystemTuplesetObject

  TuplesetScanHandle: TYPE = REF TuplesetScanObject;
  TuplesetScanObject: TYPE = RECORD[
    position: ScanPosition ← invalid,
      -- scan is either between two tuples on a page (middle), before the first page (beforeFirst),
      --or after the last page (afterLast).
    page: DBCommon.DBPage ← DBCommon.NullDBPage,
      -- if scanPosition = middle, this is current page of scan.  This page contains at least one
      --tuple from the tupleset represented by tuplesetID (below).
    slotIndex: CARDINAL ← 0,
      -- if scanPosition = middle, this means that cursor is between slots slotIndex and
      --slotIndex + 1 of page.  I.e, NextScanTupleset goes to slotIndex + 1, Prev goes to slotIndex.
    pagePtr: LONG POINTER TO DBStorageVec.VecPage ← NIL,
      -- if scanPosition = middle, this is pointer to cached version of page, locked for reading.
    pageHint: DBCache.CacheHandle ← NIL,
      -- if scanPosition = middle, this is locked cache ref to page (guarantees validity of pagePtr).
    tupleset: DBStorage.TupleHandle,
      -- tupleset whose tuples are to be returned by the scan.
    localTuplesetID: CARDINAL ← 1,
      -- if scanPosition = middle, this is index (in [1..MaxTuplesetPerPage]) of tupleset's TSDict
      --entry on this page.
    link: TuplesetScanHandle ← NIL
      -- pointer for singly-linked list of all active tupleset scans.
  ];--TuplesetScanObject

  ScanPosition: TYPE = {middle, beforeFirst, afterLast, invalid};


END.--DBStorageConcrete


CHANGE LOG

Created by Cattell on 7-Jun-81  8:59:10
-- Moved all type definitions here from:
   DBStorageConcreteField.mesa     1039 27-Feb-81 15:56:05
   DBStorageConcreteGroupScan.mesa     1323 11-Dec-80 14:19:03
   DBStorageConcreteSystemTS.mesa      662 24-Jun-80 11:16:51
   DBStorageConcreteTuplesetScan.mesa     2667 27-Feb-81 14:21:24

Changed by MBrown on 17-Jun-81 11:17:59
-- Scan handles become REFs.

Changed by Cattell on  7-Jul-81 10:13:51
-- Added IndexScan stuff.