-- File DBStorageTupleset.mesa
-- Last edited by MBrown on December 8, 1980  2:24 PM

  DIRECTORY
    DBCommon USING[DBPage, NullDBPage],
    DBStorageTSDict USING[TSDictEntry];

DBStorageTupleset: DEFINITIONS = BEGIN OPEN DBCommon;
  -- This interface defines the format of a tupleset object, which contains the persistent
  --information about a tupleset.

  TuplesetObject: TYPE = MACHINE DEPENDENT RECORD[
    wordsForTupleFields: CARDINAL [0..377B] ← 0,
      -- length of fixed-length data for the fields of a tuple in this set, in words.
    nVarFields: CARDINAL [0..377B] ← 0,
      -- number of VarByte or VarWord fields in a tuple in this set.
    expectedNGroups: CARDINAL [0..377B] ← 0,
      -- expected length of GroupList for a tuple of this type.  Used to infulence storage
      --allocation in CreateTuple.
    reserved: CARDINAL [0..377B] ← 0,
    searchList: DBStorageTSDict.TSDictEntry,
      -- includes tuplesetID, next, prev.  Head of doubly-linked list of all pages containing
      --tuples from this TS.  Pointers to front and back allow all types of scans.
    allocList: DBPage ← NullDBPage,
      -- a list of part-full pages that contain at least one tuple from this tupleset,
      --and may be used for creating new tuples in this tupleset. a part-full page is
      --located on exactly one tupleset's allocList, despite the fact that it may
      --contain tuples from many different tuplesets. 
    pageAllocator: PageAllocator
      -- a source of fresh pages for tuples in this tupleset
  ];--TuplesetObject
  -- This cannot be longer than DBStorage.TupleSetObjectSize

  PageAllocator:  TYPE = MACHINE DEPENDENT RECORD[
    segmentID: DBPage,
      -- name of the segment containing this tupleset (the source for new pages)
    firstPageInBlock: DBPage ← NullDBPage,
      -- block is the initial allocation for this tupleset.
    nPagesInBlock: CARDINAL ← 0,
    nFreePagesInBlock: CARDINAL ← 0,
      -- free pages are at end of block.
    nPagesPerExtent: CARDINAL ← 0,
      -- Number of pages to allocate from segment when allocator is empty.
    freeList: DBPage ← NullDBPage,
      -- singly-linked list of free blocks or pages (freed by deletions from this TS)
    nPagesOnFreeList: CARDINAL ← 0
      -- purpose is to allow pages to be freed gracefully to segment, if TS shrinks.
  ];--PageAllocator


END.--DBStorageTupleset


CHANGE LOG

Created by MBrown on February 15, 1980  11:30 PM
-- Created from former DBStoragePrivateB, with added stuff from StorageImplA on TID
--representation.  This no longer attempts to be the only internal interface for the
--storage-level implementation.

Changed by MBrown on February 16, 1980  11:14 PM
-- Changed FieldObject.n to .nWord .  Added inlines for FieldHandle access.

Changed by MBrown on February 24, 1980  4:18 PM
-- Deleted NullDBPage (it is now in DBCommon), added NullTID.  Changed definition of searchList:
--ALL pages must belong, even the ones on allocList, because of the possibility of tuple insertion/
--deletion during a tupleset scan.  We may need two TIDs in each tupleset dictionary for allocList
--links.

Changed by MBrown on February 25, 1980  4:00 PM
-- Eliminated OPEN from DecomposeTID, to get around compiler bug relating to OPEN in INLINE procs.

Changed by MBrown on February 25, 1980  7:51 PM
-- Added TuplesetFieldHandle, IndexFieldHandle.

Changed by MBrown on June 8, 1980  6:49 PM
-- Moved all field handle stuff to DBStorageFH.  Added TIDofTupleHandle.

Changed by MBrown on June 10, 1980  8:51 PM
-- Moved all tuple handle stuff to DBStorageTuple.

Changed by MBrown on July 22, 1980  1:51 PM
-- Changed definition of TuplesetObject to include pointers to both first and last pages. This
--is to facilitate two-way scanning from either end, although what this is worth in an unordered
--structure is not exactly clear.  Changed name of module from DBStoragePrivateA.

Changed by MBrown on July 31, 1980  3:12 PM
-- Added expectedNGroups to TuplesetObject.

Changed by MBrown on August 25, 1980  1:31 PM
-- Added nVarFields to TuplesetObject.

Changed by MBrown on December 8, 1980  2:24 PM
-- Added several new fields to PageAllocator, to reduce compatibility problems when new features
--are added later (wishful thinking at work).