-- File DBStorageTuple.mesa
-- Last edited by
--   MBrown on December 3, 1982 9:14 pm


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

DBStorageTuple: DEFINITIONS = BEGIN
  -- This interface defines a collection of operations on DBStorage.TupleObjects that
  --may be used by storage-level modules that don't export DBStorage.TupleObject.
  -- Some modules export DBStorage.TupleObject simply to get read access to the TID without
  --the cost of a procedure call, and use these procedures for other accesses.

  Init: PROC [z: ZONE, freeTuples: NAT];
    -- Called from DBStorage.Initialize.  Use z for structures other than tuple objects.
    --Allocate a free pool of freeTuples tuples.

  ConsTupleObject: PROC [tid: DBStorageTID.TID, cacheHint: DBCache.CacheHandle ← NIL]
   RETURNS [DBStorage.TupleHandle];
    -- Returns a handle for a new tuple object with the given tid and cacheHint.

  TIDOfTuple: PROC [x: DBStorage.TupleHandle] RETURNS [DBStorageTID.TID];
    -- Returns the TID of x.

  EqualTuple: PROC [x, y: DBStorage.TupleHandle] RETURNS [BOOLEAN];
    -- Returns TIDOfTuple[x] = TIDOfTuple[y].
    
  NullTupleHandle: PROC [] RETURNS [DBStorage.TupleHandle];
    -- Returns a TupleHandle x such that TIDOfTuple[x] = NullTID.
    -- No caller should modify the contents of this TupleObject in any way!!!

  InvalidateMatchingTuples: PROC [x: DBStorage.TupleHandle];
    -- For all tuple handles y on active list such that y.tid = x.tid, makes y.tid=NullTID.

  IsValidTuple: PROC [x: DBStorage.TupleHandle] RETURNS [valid: BOOL];
    -- IF DBSegment.IsValidTID[x.tid] THEN RETURN [valid: TRUE]
    -- ELSE { x.tid ← NullTID;  RETURN [valid: FALSE] }

  InvalidateTuple: PROC [x: DBStorage.TupleHandle];
    -- x.tid ← NullTID

  CallAfterFinishTransaction: PROC [];
    -- Invalidates (by setting tid = NullTID, cacheHint = NIL) all TupleObjects on the active
    --list that reference segments that are no longer addressible (because transaction went away).

  PrintTupleObject: PROC [t: DBStorage.TupleHandle];
    -- Prints t to debug stream, without a terminating CR.

  CheckState: PROC [doPrinting: BOOLEAN ← FALSE];
    -- Checks internal state of tuple manager;  if doPrinting, also prints contents
    --of tuple manager to debug stream.

END.--DBStorageTuple


CHANGE LOG

Created by MBrown on June 10, 1980  8:14 PM
-- Moved TIDOfTupleHandle here from DBStoragePrivateA, defined other apparently useful procs.

Changed by MBrown on July 9, 1980  4:32 PM
-- Added Invalidate, for use by tuple deletion.

Changed by MBrown on August 4, 1980  10:25 PM
-- Added ReInitialize, for use by CloseDatabase.

Changed by MBrown on August 14, 1980  2:34 PM
-- Added CheckState, for debugging convenience.

Changed by MBrown on August 20, 1980  8:58 PM
-- Added PrintTupleObject.

Changed by MBrown on September 12, 1980  2:32 PM
-- Added Finalize.

Changed by MBrown on 9-Jun-81 16:20:30
-- Conversion to collectable storage: flushed CopyTupleObject, FreeTupleObject,
--Finalize.  Added NullTupleHandle.  Fixed comments about function of ReInitialize.

Changed by MBrown on December 2, 1982 2:44 pm
-- Added CallAfterFinishTransaction; flushed ReInitialize.