LB.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Doug Terry, March 6, 1986 12:03:01 pm PST
Clients of the LoganBerry data management facilities should use the LoganBerry.mesa interface. This is a non-RPC internal interface to these facilities used as a convenience for testing only.
DIRECTORY
LoganBerry, LoganBerryStructure;
LB: CEDAR DEFINITIONS
~ BEGIN
OPEN LoganBerry, LoganBerryStructure;
OpenI: PROC [dbName: ROPE] RETURNS [dbinfo: OpenDBInfo];
Initiates database activity and checks for consistency. This can be called any number of times to get a new OpenDB handle or reopen a database that has been closed.
Errors: CantOpenSchema, BadSchema, CantOpenLog, BadIndex
ReadEntryI: PROC [dbinfo: OpenDBInfo, key: AttributeType, value: AttributeValue] RETURNS [entry: Entry, others: BOOLEAN];
Returns an entry that contains the given attribute value for the given key. If the key refers to the primary index then the unique entry is returned and `others' is FALSE. If the key is secondary and several entries exist with the same value for the key, then an arbitrary entry is returned and `others' is set to TRUE; use EnumerateEntries to get all of the matching entries.
Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, BadLogEntry
EntryProc: TYPE = PROC [entry: Entry] RETURNS [continue: BOOL];
EnumerateEntriesI: PROC [dbinfo: OpenDBInfo, key: AttributeType, start: AttributeValue ← NIL, end: AttributeValue ← NIL, proc: EntryProc] RETURNS [];
Calls `proc' for each entry in the specified range of key values. The enumeration is halted when either the range of entries is exhausted or `proc' returns FALSE. A NIL value for `start' represents the least attribute value, while a NIL value for `end' represents the largest attribute value. Thus, the complete database can be enumerated by specifying start=NIL and end=NIL with `key' equal to the primary key.
WARNING: THIS ROUTINE CAN NOT BE USED ACROSS AN RPC CONNECTION; USE GenerateEntries INSTEAD.
Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, BadLogEntry
GenerateEntriesI: PROC [dbinfo: OpenDBInfo, key: AttributeType, start: AttributeValue ← NIL, end: AttributeValue ← NIL] RETURNS [cinfo: CursorInfo];
Similar to EnumerateEntries, but creates a cursor so that entries in the specified range of key values can be retrieved using NextEntry (defined below). Initially, the cursor points to the start of the sequence. A NIL value for `start' represents the least attribute value, while a NIL value for `end' represents the largest attribute value. Thus, the complete database can be enumerated by specifying start=NIL and end=NIL with `key' equal to the primary key.
Errors: BadDBHandle, NoIndex
NextEntryI: PROC [dbinfo: OpenDBInfo, cinfo: CursorInfo, dir: CursorDirection ← increasing] RETURNS [entry: Entry];
Retrieves the next entry relative to the given cursor. The cursor, and thus the sequence of desired entries, must have been previously created by a call to GenerateEntries. The cursor is automatically updated so that NextEntry may be repeatedly called to enumerate entries. NIL is returned if the cursor is at the end of the sequence and dir=increasing or at the start of the sequence and dir=decreasing.
Errors: BadCursor, DBClosed, BadIndex, BadLogEntry
EndGenerateI: PROC [dbinfo: OpenDBInfo, cinfo: CursorInfo] RETURNS [];
Releases the cursor; no further operations may be performed using the given cursor. This must be called once for every call to GenerateEntries.
WriteEntryI: PROC [dbinfo: OpenDBInfo, entry: Entry, log: LogID ← activityLog, replace: BOOLEANFALSE] RETURNS [];
Adds a new entry to the database. The entry is added to the activity log unless another log is explicitly requested. The entry must have an attribute for the primary key. The primary attribute value must be unique throughout the database unless replace=TRUE; in this case, an existing entry with the same primary attribute value is atomically replaced with the new entry.
Errors: BadDBHandle, NoPrimaryKey, ValueNotUnique, LogReadOnly, InvalidReplace, DBClosed, BadIndex
DeleteEntryI: PROC [dbinfo: OpenDBInfo, key: AttributeType, value: AttributeValue] RETURNS [];
Deletes the entry that contains the given attribute value for the given key. If the key is for a secondary index and the value is not unique then an Error[ValueNotUnique] is raised. Deletes are actually performed by logging the delete request (so that the log can be replayed at a later time) and then updating all of the indices.
Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, ValueNotUnique, LogReadOnly, BadLogEntry
CloseI: PROC [dbinfo: OpenDBInfo] RETURNS [];
Terminates database activity and closes all log and index files. Databases are always maintained consistently on disk so it doesn't hurt to leave a database open. The main reason for calling Close is to release the FS locks on the log files so they can be manually edited.
WARNING: THIS SHOULD NOT BE CALLED IF THE DATABASE IS BEING SHARED BY MULTIPLE CLIENTS.
Errors: BadDBHandle
BuildIndicesI: PROC [dbinfo: OpenDBInfo] RETURNS [];
Rebuilds the indices by scanning the logs and performing WriteEntry or DeleteEntry operations.
CompactLogsI: PROC [dbinfo: OpenDBInfo] RETURNS [];
Removes deleted entries from the logs by enumerating the primary index and writing new logs.
SetRemoteAccessI: PROC [dbinfo: OpenDBInfo, accessible: BOOLEANTRUE, why: ROPENIL] RETURNS [];
Controls access by remote clients to the database. If accessible=FALSE then the database can not be accessed through the normal LoganBerry interface, only via this interface; setting accessible=TRUE makes the database commonly available (the normal case). This operation is intended for use by administrators that wish to temporarily remove a database from service. The why parameter is returned to clients as an explanation for DBNotAvailable ERRORs.
END.
Doug Terry, December 19, 1985 2:07:58 pm PST
Taken from LoganBerry.mesa
Doug Terry, December 20, 1985 3:08:07 pm PST
changes to: ~, DIRECTORY
Doug Terry, February 26, 1986 6:32:55 pm PST
changes to: ~
Doug Terry, March 6, 1986 12:03:01 pm PST
changes to: ~