-- Copyright (C) 1984, 1985 by Xerox Corporation. All rights reserved. -- BTreeDefs , HGM, 15-Sep-85 4:53:42 -- last edited by Hankins, 11-Jun-84 15:31:41 -- Klamath update (remove Bravo formatting) DIRECTORY BTreeSupportDefs USING [FileHandle]; BTreeDefs: DEFINITIONS = BEGIN Desc: TYPE = LONG DESCRIPTOR FOR ARRAY OF WORD; BTreeHandle: TYPE [SIZE [LONG POINTER]]; Call: TYPE = PROCEDURE [k: Desc, v: Desc] RETURNS [more, dirty: BOOLEAN]; TestKeys: TYPE = PROCEDURE [a, b: Desc] RETURNS [BOOLEAN]; NullProc: TestKeys; CreateAndInitializeBTree: PROCEDURE [ fileH: BTreeSupportDefs.FileHandle, initializeFile, useDefaultOrderingRoutines: BOOLEAN, isFirstGreaterOrEqual, areTheyEqual: TestKeys] RETURNS [bh: BTreeHandle]; Insert: PROCEDURE [bh: BTreeHandle, key: Desc, value: Desc]; Lookup: PROCEDURE [bh: BTreeHandle, key, value: Desc] RETURNS [lengthValue: CARDINAL]; KeyNotFound: CARDINAL = 177777B; -- for not found at Lookup. Delete: PROCEDURE [bh: BTreeHandle, key: Desc]; EnumerateFrom: PROCEDURE [bh: BTreeHandle, key: Desc, c: Call]; << If you use the default ordering routines, the key to start the enumeration at the lowest point is: SmallestKey: Desc = DESCRIPTOR[SmallArray]; where SmallArray: ARRAY [0..1) OF WORD = [0]; >> ReleaseBTree: PROCEDURE [bh: BTreeHandle] RETURNS [fileH: BTreeSupportDefs.FileHandle]; -- no longer does a close. Updates info in special page 0. -- Releases btree storage. ShutDownBTree: PROCEDURE [bh: BTreeHandle] RETURNS [fileH: BTreeSupportDefs.FileHandle]; -- this is the routine, rather than ReleaseBTree, -- to call after an unwind has been seen, to "release" the btree storage. InvalidTree: ERROR; -- Somebody (other than ShutDownBTree) tried to touch a tree after an unwind, or ShutDownBTree was called for a valid tree. PushBTreeToDisk: PROCEDURE [bh: BTreeHandle]; -- guarantees disk is up to date. (Need not be called unless you deliberately try to read special page 0 directly from the disk before the btree has been released.) PruneBTree: PROCEDURE [bh: BTreeHandle] RETURNS [storageFreed: BOOLEAN]; -- currently a noop. When implemented will pack the tree (by pages only) and then truncate the file. AskDepthOfTree: PROCEDURE [bh: BTreeHandle] RETURNS [nLevels: CARDINAL]; AskNumberOfEntriesInTree: PROCEDURE [bh: BTreeHandle] RETURNS [nEntries: CARDINAL]; CheckTree: PROCEDURE [bh: BTreeHandle]; -- syntax check. END. <>