-- File: DBStorageInternal.mesa
-- Last edited by MBrown on 17-Jun-81 10:35:42


  DIRECTORY
    DBCommon USING[DBPage],
    DBCache USING[CacheHandle],
    DBStorage USING[TupleHandle];

DBStorageInternal: DEFINITIONS = BEGIN
  -- This interface contains all storage level private types and procedures that are
  --used in implementing the index section of the storage level.
  -- By using this interface, the index section avoids the need to import DBStorage.


  TupleTree: TYPE = POINTER TO TupleTreeRecord;

  TupleTreeRecord: TYPE = MACHINE DEPENDENT RECORD[
    -- This is the part of DBBTree.Tree that is permanently stored in the database.
    rootPA: DBCommon.DBPage,
      -- B-Tree root page address
    depth: CARDINAL,
      -- B-Tree depth 
    tid: TID,
      -- TID of tuple that holds permanent copy of this object
    segment: DBCommon.DBPage
      -- Segment containing this B-Tree (source of pages)
  ];--TupleTreeRecord


  ReadIndexObject: PROCEDURE[t: DBStorage.TupleHandle, result: TupleTree];
    -- PARAMETERS: t is an index tuple, i.e. a tuple whose first field is an index object;
    --result points to a TupleTreeRecord that may be overwritten.
    -- EFFECTS: the index object contained in tuple t is written into result.

  WriteIndexObject: PROCEDURE[t: DBStorage.TupleHandle, val: TupleTree];
    -- PARAMETERS: an index tuple, i.e. a tuple whose first field is an index object,
    --and a value for such and object.
    -- EFFECTS: writes the value val into the index object field of tuple t.
    --Does NOT deallocate val.


  TID: TYPE = LONG CARDINAL;

  SegmentIDOfTuple: PROCEDURE[t: DBStorage.TupleHandle] RETURNS[--segmentID--DBCommon.DBPage];
    -- RESULTS: the "segment ID" of the segment that contains tuple t.

  TIDOfTuple: PROCEDURE[t: DBStorage.TupleHandle] RETURNS[TID];
    -- RESULTS: the TID of tuple t (suitable for storing in an index).

  MakeTupleHandle: PROCEDURE[tid: TID, cacheHint: DBCache.CacheHandle ← NIL]
   RETURNS[DBStorage.TupleHandle];
    -- RESULTS: a tuple handle that contains the given TID and CacheHandle.

  ReleaseTupleHandle: PROCEDURE[t: DBStorage.TupleHandle] = INLINE { };


END.--DBStorageInternal


CHANGE LOG

Created by MBrown on May 2, 1980  9:54 AM
-- Created to narrow the interface between storage index implementation and the rest
--of the storage level implementation.

Changed by MBrown on May 8, 1980  10:09 AM
-- Added TupleTree type, and ReleaseTupleHandle, after reading by Nori.

Changed by MBrown on May 8, 1980  1:15 PM
-- Made TupleTree MACHINE DEPENDENT, and eliminated entries and IsFirstEqual fields.

Changed by Suzuki on May 8, 1980  1:35 PM
-- DeallocateIndexObject is removed.  Caller of ReadIndexObject supplies the location where the result record is stored.

Changed by MBrown on May 9, 1980  10:06 AM
-- Clarified specification of ReadIndexObject.

Changed by Suzuki on August 17, 1980  11:10 AM
-- Deleted cacheMaxSize from TupleTreeRecord.

Changed by MBrown on 17-Jun-81 10:35:17
-- ReleaseTupleHandle is now a no-op.