-- File DBStorageGroup.mesa
-- Last edited by MBrown on August 13, 1980  11:55 AM


  DIRECTORY
    DBCache USING[CacheHandle],
    DBStorage USING[TupleHandle, FieldHandle],
    DBStorageExtTuple USING[TupleBody],
    DBStorageTID USING[TID];

DBStorageGroup: DEFINITIONS = BEGIN OPEN DBStorageTID;
  -- This interface contains the internal storage level definitions that relate to the
  --representation of groups.


  -- Types

  TIDFieldBody: TYPE = MACHINE DEPENDENT RECORD[
    headTID: TID,
    prevTID: TID,
    nextTID: TID
  ];--TIDFieldBody

  TIDFieldPart: TYPE = {headTID, prevTID, nextTID};
    -- Allows parts of a TIDFieldBody to be addressed (see ReadGroupField below).

  GroupList: TYPE = ARRAY [0..0) OF GroupListEntry;

  GroupListEntry: TYPE = MACHINE DEPENDENT RECORD[
    groupID: TID,
    firstTID: TID,
    lastTID: TID
  ];--GroupListEntry

  HeadFieldPart: TYPE = {firstTID, lastTID};
    -- Allows parts of a GroupListEntry to be addressed (see ReadHeadField below).


  -- Procs

  GroupListFromTuple: PROC[DBStorage.TupleHandle]
   RETURNS[LONG DESCRIPTOR FOR GroupList, DBCache.CacheHandle];
    -- Returns the BASE and LENGTH of the tuple's GroupList.  The BASE is a LONG POINTER to a locked
    --readonly cache page, and the second result is the cache handle to be used for unlocking it.

  ReadGroupField: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle, part: TIDFieldPart]
   RETURNS[DBStorage.TupleHandle];
    -- Returns the indicated part of x's group field f.

  WriteGroupField: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle, part: TIDFieldPart,
   val: DBStorage.TupleHandle];
    -- Writes val into the indicated part of x's group field f.

  ReadHeadField: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle, part: HeadFieldPart]
   RETURNS[DBStorage.TupleHandle];
    -- returns the indicated part of x's GroupListEntry for group field f.
    -- error if no such entry.  result is never NIL.

  WriteHeadField: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle, part: HeadFieldPart,
   val: DBStorage.TupleHandle];
    -- writes val's tid into the indicated part of x's GroupListEntry for group field f.
    -- error if no such entry.  val is never NIL.

  CreateHeadEntry: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle];
    -- creates a group list entry in tuple x for group field f.
    -- error if already such an entry

  DestroyHeadEntry: PROC[x: DBStorage.TupleHandle, f: DBStorage.FieldHandle];
    -- removes the group list entry in tuple x for group field f.
    -- error if no such entry


  GroupListFromTupleBase: PROC[LONG POINTER TO DBStorageExtTuple.TupleBody]
   RETURNS[LONG DESCRIPTOR FOR GroupList];
    -- Returns the BASE and LENGTH of the tuple's GroupList, given a LONG POINTER
    --to the tuple's body (presumably in a cache page).


END.--DBStorageGroup


CHANGE LOG

Created by MBrown on June 17, 1980  10:15 AM
-- Moved here from DBStoragePrivateB.  This allows the implementation of group scans to be split from
--the implementation of group field reading/writing.

Changed by MBrown on June 18, 1980  8:16 PM
-- Added GroupListFromTupleBase, to satisfy StoragePrintImpl.

Changed by MBrown on August 13, 1980  11:56 AM
-- DBStoragePrivateB.TupleBody became DBStorageExtTuple.TupleBody.