DIRECTORY BTreeSimple USING [PathStk, Tree], IO USING [STREAM], RefTab USING [Ref], Rope USING [ROPE], LoganBerry ; LoganBerryStructure: CEDAR DEFINITIONS ~ BEGIN OPEN LoganBerry; ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; LogAddress: TYPE = INT; EndOfEntry: CHAR = '\n; UpdateComplete: CHAR = 377C; IndexEntry: TYPE = RECORD [ log: LogID, firstByte: LogAddress ]; IndexPtr: TYPE = LONG POINTER TO IndexEntry; CursorInfo: TYPE = REF CursorRecord; CursorRecord: TYPE = RECORD[ dbinfo: OpenDBInfo, key: AttributeType, start, end: AttributeValue, index: OpenIndexInfo, current: AttributeValue, pathStk: BTreeSimple.PathStk ]; OpenIndexInfo: TYPE = REF OpenIndexInfoRecord; OpenIndexInfoRecord: TYPE = RECORD[ key: AttributeType, type: {primary, secondary}, order: ATOM ¬ $lex, -- ordering of index, e.g. $lex, $ascii, $gmt, $int filename: ROPE, readBacking: STREAM ¬ NIL, writeBacking: STREAM ¬ NIL, btree: BTreeSimple.Tree ]; IndexSet: TYPE = RefTab.Ref; --AttributeType <-> OpenIndexInfo OpenLogInfo: TYPE = REF OpenLogInfoRecord; OpenLogInfoRecord: TYPE = RECORD[ id: LogID, access: {readOnly, readWrite}, filename: ROPE, readStream: STREAM ¬ NIL, writeStream: STREAM ¬ NIL ]; LogSet: TYPE = REF LogSetRecord; LogSetRecord: TYPE = RECORD[seq: SEQUENCE size: LogID OF OpenLogInfo]; OpenDBInfo: TYPE = REF OpenDBRecord; OpenDBRecord: TYPE = MONITORED RECORD[ dbName: ROPE, isOpen: BOOLEAN, remoteAccess: BOOLEAN, openForUpdate: BOOLEAN, transStarted: BOOLEAN, statusMsg: ROPE, indices: IndexSet, primaryIndex: OpenIndexInfo, logs: LogSet ]; SchemaChars: REF READONLY TEXT; -- currently the string "- - >" END. – LoganBerryStructure.mesa Copyright Σ 1985, 1990, 1992 by Xerox Corporation. All rights reserved. Doug Terry, October 24, 1990 4:05 pm PDT Swinehart, September 6, 1987 2:24:59 pm PDT Brian Oki, March 30, 1990 4:42 pm PST Willie-s, April 23, 1992 3:04 pm PDT This module contains defintions for the various data structures and formats used by LoganBerry. Logs and btrees Logs store a time-ordered sequence of database entries separated by end-of-entry markers. An update-complete marker should always be the last byte of a log. Within a btree index, each btree entry contains an attribute value (the key for the btree), as well as a log identifier and byte offset into the given log. The byte offset indicates the first byte of a database entry containing the particular attribute. Cursors Cursors contain the information needed to access a sequence of database entries in btree order. Database schema Since not all attribute types need to be keys, i.e. have btree indices maintained for them, the database schema must contain a list of attribute types that should serve as keys. Associated with each key is the name of the file storing the btree for that key. Two types of btree indices are supported: primary and secondary. A primary index must have unique attribute values for the associated attribute type, whereas secondary indices need not have unique values. (The implementation generates artifically unique btree keys for secondary indices.) Logs are maintained as file streams that are either read only or can be updated by appending entries to them. Currently, only textual logs containing lists of attributes are supported, though, some day, logs might store pickled Cedar data structures. format: {textual, pickled}, A database schema contains information about all logs and indices that comprise a database. Once a database has been opened the schema information is maintained in a OpenDBRecord. This may be a misnomer since the OpenDBRecord for a database remains in existence even if the database is closed. Database operations are monitored so that several processes can share a database. Operations by remote clients are disabled if the remoteAccess flag is FALSE. A schema is created by clients of this package and stored in a DF file that can be used to backup the database. Lines of the file starting with "-->" are deemed to contain schema information for the file named in the subsequent line of the DF file or at the end of the same line. The two types of schema entries are as follows: --> log --> index Doug Terry, December 20, 1985 3:49:26 pm PST Type declarations extracted from LoganBerryImpl.mesa , OpenDBRecord Doug Terry, January 23, 1986 4:17:03 pm PST changes to: OpenDBRecord Doug Terry, February 26, 1986 6:47:11 pm PST changes to: LogInfoRecord, IndexInfoRecord, type, OpenDBRecord ΚL•NewlineDelimiter –(cedarcode) style™code™Kšœ Οeœ=™HKšœ(™(K™+K™%K™$—K˜K™_K™šΟk ˜ Kšœ žœ˜"Kšžœžœžœ˜Kšœžœ˜Kšœžœžœ˜Kšœ ˜ K˜K˜—KšΠln Ρbln œžœž ˜&šœž˜Kšžœ ˜K˜Kšžœžœžœ˜Kšžœžœžœžœ˜—headšœ™Kšœ™™Kšœ žœžœ˜K˜Kšœ žœ˜Kšœžœ˜K˜—Kšœώ™ώK™™šœ žœžœ˜Kšœ ˜ Kšœ˜K˜K˜—Kš œ žœžœžœžœ ˜,——šœ™šœ_™_K™Kšœ žœžœ˜$K˜šœžœžœ˜K˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜———šœ™Kšœ§™§K™™Kšœžœžœ˜.šœžœžœ˜#Kšœ˜Kšœ˜Kšœžœ Οc3˜HKšœ žœ˜Kšœ žœžœ˜Kšœžœžœ˜Kšœ˜K˜—K˜Kšœ žœ‘"˜?K˜—K™ϋK™™Kšœ žœžœ˜*šœžœžœ˜!Kšœ ˜ Kšœ™Kšœ˜Kšœ žœ˜Kšœ žœž˜Kšœ žœž˜K˜K˜—Kšœžœžœ˜ Kš œžœžœžœ žœ˜FK˜K˜—Kšœ Οzœ±Οsœ™ΘK™™Kšœ žœžœ˜$šœžœžœ˜&Kšœžœ˜ Kšœžœ˜Kšœžœ˜Kšœžœ˜Kšœžœ˜Kšœ žœ˜Kšœ˜Kšœ˜Kšœ ˜ K˜K˜—šœΙ™ΙKšœ@™@Kšœ?™?K™—Kšœ žœ‘œ˜?K˜K˜——Kšžœ˜K™™,Kšœ4Οr™5Kš€™—™+Kšœ € ™—™,Kšœ €2™>˜K˜Icode0˜K˜M˜K™—KšΟn™——…—fH