<> <> <> <> <> <> <> <> 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 [] = { <> 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 <> Changed by MBrown on June 1, 1980 12:33 PM <> Changed by MBrown on June 18, 1980 8:19 PM <> Changed by MBrown on August 2, 1980 10:37 PM <> <> <> Changed by MBrown on August 23, 1980 10:39 AM <> Changed by MBrown on August 23, 1980 12:18 PM <> Changed by Cattell on 30-Dec-81 10:35:01 <> Changed by Willie-Sue on June 24, 1982 12:07 pm < IO>> Changed by Willie-Sue on June 30, 1982 4:31 pm < DBCommon.GetDebugStream[]>> <<>> Changed by Willie-Sue on February 15, 1985 <>