File: DBStoragePrintImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by:
MBrown on February 27, 1981 3:41 PM
Cattell on June 16, 1983 3:31 pm
Willie-Sue on February 15, 1985 11:29:18 am PST
Widom, September 3, 1985 5:10:59 pm PDT
Donahue, May 23, 1986 9:58:27 am PDT
DIRECTORY
IO,
DBCommon,
DBSegment,
DBStats,
DBStorageGroup,
DBStorageGroupScan,
DBStoragePage,
DBStoragePrint,
DBStorageTuple;
DBStoragePrintImpl: CEDAR PROGRAM
IMPORTS
DBCommon,
DBSegment,
DBStats,
DBStorageGroup,
DBStorageGroupScan,
DBStoragePage,
IO
EXPORTS DBStoragePrint =
BEGIN OPEN IO, DBCommon;
Assert: PROC[condition: BOOLEAN] = {IF ~condition THEN ERROR};
Print: PROC [] = {
Maximum printing with minimum keystrokes
DBSegment.CheckState[doPrinting: TRUE, printOnlyLockedPages: FALSE];
DBStorageGroupScan.CheckState[doPrinting: TRUE];
DBStats.Print[heading: "DBStorageDebugImpl.Print", out: DBCommon.GetDebugStream[]];
};
PrintPage: PUBLIC PROC[
dbPage: DBCommon.DBPage, p: LONG POINTER, fullPrint: BOOLEAN] = {
SELECT DBStoragePage.TagOfPage[LOOPHOLE[p]] FROM
DBStoragePage.Unused,
DBStoragePage.Free,
DBStoragePage.AMap,
DBStoragePage.BTree => PrintPageType[dbPage, p, fullPrint];
DBStoragePage.Tuple,
DBStoragePage.SystemTuple => PrintVecPage[dbPage, LOOPHOLE[p], fullPrint];
DBStoragePage.OverflowTuple => PrintOverflowPage[dbPage, LOOPHOLE[p], fullPrint];
ENDCASE => PrintPageUnknown[dbPage, p, fullPrint];
DBCommon.GetDebugStream[].PutF["*n"];
};--PrintPage
PrintPageType: PROC[dbPage: DBCommon.DBPage, p: LONG POINTER, fullPrint: BOOLEAN] = {
DBCommon.GetDebugStream[].PutF["%bB: a %g", card[dbPage], IO.rope[PagetagToRope[DBStoragePage.TagOfPage[LOOPHOLE[p]]]]];
};--PrintPageType
PrintPageUnknown: PROC[dbPage: DBCommon.DBPage, p: LONG POINTER, fullPrint: BOOLEAN] = {
DBCommon.GetDebugStream[].PutF["%bB: a page of type %g, an unrecognized type", card[dbPage],
card[DBStoragePage.TagOfPage[LOOPHOLE[p]]]];
};--PrintPageUnknown
PrintVecPage: PROC[
dbPage: DBCommon.DBPage, p: LONG POINTER, fullPrint: BOOLEAN] = TRUSTED {
debugS: IO.STREAM← DBCommon.GetDebugStream[];
debugS.PutF["%bB: a %g with %g words in free vec space", card[dbPage],
IO.rope[PagetagToRope[DBStoragePage.TagOfPage[p]]], card[DBStoragePage.WordsLeftOnPage[p]]];
IF ~fullPrint THEN RETURN;
debugS.PutF["*n"];
FOR slotIndex: CARDINAL IN [1 .. DBStoragePage.HighSlotIndexOfPage[p]] DO
debugS.PutF["%g: ", card[slotIndex]];
SELECT DBStoragePage.TypeOfSlot[p, slotIndex] FROM
DBStoragePage.FreeType => PrintFreeSlot[];
DBStoragePage.UnFreeType => PrintUnFreeSlot[];
DBStoragePage.TSDictType => PrintTSDict[p, slotIndex];
DBStoragePage.LStringType => PrintLString[p, slotIndex];
IN [1..DBStoragePage.MaxTuplesetPerPage] => PrintTupleVec[p, slotIndex];
ENDCASE => PrintUnimplemented[DBStoragePage.TypeOfSlot[p, slotIndex]];
ENDLOOP;
};--PrintVecPage
PrintOverflowPage: PROC[
dbPage: DBCommon.DBPage, p: LONG POINTER, fullPrint: BOOLEAN] = TRUSTED {
debugStream: IO.STREAM← DBCommon.GetDebugStream[];
debugStream.PutF["%bB: a string overflow page with %g words in free vec space",
card[dbPage], card[DBStoragePage.WordsLeftOnPage[p]]];
IF ~fullPrint THEN RETURN;
debugStream.PutF["*n"];
FOR slotIndex: CARDINAL IN [1 .. DBStoragePage.HighSlotIndexOfPage[p]] DO
debugStream.PutF["%g: ", card[slotIndex]];
SELECT DBStoragePage.TypeOfSlot[p, slotIndex] FROM
DBStoragePage.EStringType => PrintEString[p, slotIndex];
ENDCASE => PrintUnimplemented[DBStoragePage.TypeOfSlot[p, slotIndex]];
ENDLOOP;
};--PrintOverflowPage
PrintEString: PROC[
p: LONG POINTER TO DBStoragePage.VecPage, slotIndex: CARDINAL] = TRUSTED {
eString: LONG POINTER TO DBStoragePage.EString ←
LOOPHOLE[DBStoragePage.VecOfSlot[p, slotIndex]];
eStringID: TID ← eString.eStringID;
nWordsForText: CARDINAL ← eString.header.length - DBStoragePage.SizeOfNullEString;
debugStream: IO.STREAM← DBCommon.GetDebugStream[];
debugStream.PutF["External string descriptor, eStringID: %bB, nBytes: %g*n",
card[eStringID], card[2*nWordsForText]];
debugStream.PutF[" text: """];
FOR i: CARDINAL IN [0..nWordsForText*2) DO
debugStream.PutF["%g", char[eString.text[i]]];
ENDLOOP;
debugStream.PutF["""*n"];
};--PrintEString
PrintLString: PROC[
p: LONG POINTER TO DBStoragePage.VecPage, slotIndex: CARDINAL] = TRUSTED {
lString: LONG POINTER TO DBStoragePage.LString ←
LOOPHOLE[DBStoragePage.VecOfSlot[p, slotIndex]];
eStringID: TID ← lString.eStringID;
DBCommon.GetDebugStream[].PutF["Local string descriptor, bytesInRemString: %g, eStringID: %bB*n",
card[lString.bytesInRemString], card[eStringID]];
};--PrintLString
PrintTSDict: PROC[
p: LONG POINTER TO DBStoragePage.VecPage, slotIndex: CARDINAL] = TRUSTED {
pDict: LONG POINTER TO DBStoragePage.TSDict ←
LOOPHOLE[DBStoragePage.VecOfSlot[p, slotIndex]];
nEntries: CARDINAL ← DBStoragePage.NEntries[pDict];
entry: CARDINAL;
debugStream: IO.STREAM← DBCommon.GetDebugStream[];
Assert[slotIndex = DBStoragePage.TSDictSlotIndex];
debugStream.PutF["Tupleset dictionary containing %g entry(s):*n", card[nEntries]];
FOR entry IN [1..nEntries] DO
debugStream.PutF[" %g:", card[entry]];
debugStream.PutF[" TuplesetID: %bB,", card[pDict.seq[entry].tuplesetID]];
debugStream.PutF[" NextPage: %bB,", card[pDict.seq[entry].next]];
debugStream.PutF[" PrevPage: %bB*n", card[pDict.seq[entry].prev]];
ENDLOOP;
};--PrintTSDict
PrintTupleVec: PROC[
p: LONG POINTER TO DBStoragePage.VecPage, slotIndex: CARDINAL] = TRUSTED {
pTuple: LONG POINTER TO DBStoragePage.TupleBody ←
LOOPHOLE[DBStoragePage.VecOfSlot[p, slotIndex]];
nDataWords: CARDINAL ← pTuple.groupOffset - DBStoragePage.SizeOfNullTuple;
groupList: LONG DESCRIPTOR FOR DBStorageGroup.GroupList ←
DBStorageGroup.GroupListFromTupleBase[pTuple];
dataword, entry: CARDINAL;
debugStream: IO.STREAM← DBCommon.GetDebugStream[];
debugStream.PutF["Tuplevec of local type %g containing %g words fixed data, %g group list entry(s)*n",
card[DBStoragePage.TypeOfSlot[p, slotIndex]], card[nDataWords], card[LENGTH[groupList]]];
debugStream.PutF[" data:"];
FOR dataword IN [0..nDataWords) DO debugStream.PutF["%b,", card[pTuple.fields[dataword]]]; ENDLOOP;
debugStream.PutF["*n"];
FOR entry IN [0..LENGTH[groupList]) DO
debugStream.PutF[" %g:", card[entry]];
debugStream.PutF[" GroupID: %bB,", card[groupList[entry].groupID]];
debugStream.PutF[" FirstTuple: %bB,", card[groupList[entry].firstTID]];
debugStream.PutF[" LastTuple: %bB*n", card[groupList[entry].lastTID]];
ENDLOOP;
};--PrintTupleVec
PrintFreeSlot: PROC = {
DBCommon.GetDebugStream[].PutF["Free slot*n"];
};--PrintFreeSlot
PrintUnFreeSlot: PROC = {
DBCommon.GetDebugStream[].PutF["UnFree slot (this is an debugStream)*n"];
};--PrintUnFreeSlot
PrintUnimplemented: PROC[slotType: CARDINAL] = {
DBCommon.GetDebugStream[].PutF["Slot type is %g, what does THAT mean?*n", card[slotType]];
};--PrintUnimplemented
PagetagToRope: PROC [tag: CARDINAL] RETURNS [ROPE] = {
RETURN [SELECT tag FROM
DBStoragePage.Unused => "unused page",
DBStoragePage.Free => "free page",
DBStoragePage.AMap => "AMap page",
DBStoragePage.Tuple => "user tuple page",
DBStoragePage.SystemTuple => "system tuple page",
DBStoragePage.BTree => "BTree page",
ENDCASE => ERROR];
};--PagetagToString
END.--StoragePrintImpl
CHANGE LOG
Created by MBrown on May 27, 1980 11:04 AM
Changed by MBrown on May 28, 1980 9:59 AM
Still working on it...
Changed by MBrown on June 1, 1980 12:33 PM
Changed for new definition of GroupListOfTuple.
Changed by MBrown on June 18, 1980 8:19 PM
Changed for rearrangements in storage level.
Changed by MBrown on August 2, 1980 10:37 PM
Changed for change of interface: this module now is to print any type of page, not just vec
pages. Right now it does no more than print a string name for the page tag if the page has
some other type (e.g. AMap, BTree).
Changed by MBrown on August 23, 1980 10:39 AM
Types that used to be in DBStoragePrivateB have now moved to separate defs.
Changed by MBrown on August 23, 1980 12:18 PM
Added printing of LStrings and EStrings.
Changed by Cattell on 30-Dec-81 10:35:01
Changed PF format codes to IOStream format codes.
Changed by Willie-Sue on June 24, 1982 12:07 pm
IOStream => IO
Changed by Willie-Sue on June 30, 1982 4:31 pm
debugStream => DBCommon.GetDebugStream[]
Changed by Willie-Sue on February 15, 1985
made Cedar, added tioga formatting