-- File: DBTuplesConcrete.mesa -- Contents: Concrete definitions of DBStorage and DBView types. -- File created by Rick Cattell, 7-Jun-81 -- Last edited by: -- Cattell on: August 2, 1983 1:44 pm -- MBrown on: 9-Jun-81 15:33:33 -- Eric Bier on: 17-Aug-81 14:20:59 -- Willie-Sue on June 25, 1982 5:09 pm DIRECTORY DBCache USING[CacheHandle], DB, DBStorage, Rope; DBTuplesConcrete: DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; TupleHandle, TupleSet, Index, IndexFactor: TYPE = REF TupleObject; Domain, Relation, Attribute, DataType: TYPE = Entity; Relship: TYPE = REF RelshipObject; Entity: TYPE = REF EntityObject; EntityObject: TYPE = TupleObject; RelshipObject: TYPE = TupleObject; SystemATuple: TYPE = REF attribute TupleObject; SystemTSTuple: TYPE = REF tupleSet TupleObject; SystemSTuple: TYPE = REF surrogate TupleObject; TupleObject: TYPE = RECORD[ tid: LONG CARDINAL, pred: TupleHandle ← NIL, succ: TupleHandle ← NIL, -- Links in doubly-linked list of all in-use TupleObjects otherInfo: SELECT type: DBStorage.TupleObjectType FROM stored => [ -- tid > DBStorage.MaxSystemTuplesetID cacheHint: DBCache.CacheHandle ], -- hint in finding the cache page for the tid tupleSet => [ -- tid IN [TupleSetTSID..IndexFactorTSID] vTuple: DBStorage.SystemTuplesetHandle← NIL, -- corresponding system tupleset vName: ROPE← NIL, -- name of this tupleset entity vIsDomain: BOOL, -- TRUE if tuple set is domain, FALSE if is relation vAttributes: LIST OF Attribute← NIL, -- if relation, list of its attributes; if domain, list of -- "fake" surrogate attributes that are attributes of this domain and not client-visible vR1to1: BOOLEAN← TRUE], -- whether 1-to-1 if relation; unused if domain attribute => [ -- tid IN [FirstAttributeID .. MaxSystemTupleID] vHandle: DBStorage.FieldHandle← NIL, -- handle for this attribute vType: DataType, -- type of this attribute vName: ROPE← NIL, -- name of this attribute vRelation: Relation← NIL], -- relation this attribute belongs to entity => [ -- used only for IntType, StringType, etc. vName: ROPE← NIL, -- name of the entity vParent: Domain← NIL], -- domain entity belongs to (always ValueTypeDomain) surrogate => [ vRelation: Relation← NIL, -- relation this surrogate relship belongs to vEntity: Entity← NIL, -- entity this relship corresponds to in target domain vTargetAttribute: Attribute← NIL], -- the target (first) attribute of vRelation ENDCASE ]; -- A SYSTEM tuple is of one of three types: tupleset tuples (there are 4 of these -- currently), attribute tuples (about a dozen of these), and entity tuples (about 4 -- of these). These tuples are used in definition and access of dictionary tuples. -- A SURROGATE tuple is a tuple in a surrogate relation. A surrogate relation is one -- whose first, "target", attribute is an entity-valued with Key uniqueness; such a -- relation's relships are not stored as tuples, but rather the 2nd through Nth -- attributes are stored as attributes of tuples representing entities in the "target" -- domain, i.e. the domain the target attribute references. -- A DICTIONARY tuple is a real tuple stored in the database, and is of one of the 4 types -- corresponding to the 4 tupleset system tuples (which one can be determined by -- SL.ReadTupleSet). They describe the user's tuplesets, attributes, and indexes, and -- can be be read but not modified by the user (except through the system routines: -- AddField, etc.). -- A DATA tuple is any other kind of tuple, namely the ones in which data are stored. -- GetF[data tuple, attribute dictionary tuple] would get a field, for example. RelshipSet: TYPE = REF RelshipSetObject; RelshipSetObject: TYPE = RECORD[ scan: SELECT type: * FROM tupleSet => [ -- scan all relships in the tupleset, serially testing each serialCheck: AttributeValueList, -- if non-NIL, serially check that tuples satisfy this scanHandle: DBStorage.TuplesetScanHandle, -- this scan gives the tuples to consider surrogate: Relation← NIL], -- if non-NIL, above gives entities, must convert to surrogate index => [ -- scan all relships in an index, serially testing each serialCheck: AttributeValueList, -- if non-NIL, serially check that tuples satisfy this scanHandle: DBStorage.IndexScanHandle, -- this scan gives the tuples to consider surrogate: Relation← NIL], -- if non-NIL, above gives entities, must convert to surrogate group => [ -- scan all relships referencing a particular entity serialCheck: AttributeValueList, -- if non-NIL, serially check that tuples satisfy this scanHandle: DBStorage.GroupScanHandle, -- this scan gives the tuples to consider surrogate: Relation← NIL], -- if non-NIL, above gives entities, must convert to surrogate justOne => [ -- just return hereItIs for first NextRelship call [hereItIs set to NIL after that] hereItIs: Relship], empty => -- NextRelship always returns NIL on one of these NULL, segment => [ -- scan multiple segments, concatenating the RelationSubset results remainingSegments: LIST OF ATOM, -- remaining segments to search previousSegments: LIST OF ATOM, -- segments already searched relation: Relation, -- relation we are scanning (passed by client) constraint: AttributeValueList, -- the constraint passed by client start: FirstLast, -- passed by client currentRelshipSet: RelshipSet], -- the RelshipSet in the current segment ENDCASE ]; EntitySet: TYPE = REF EntitySetObject; EntitySetObject: TYPE = RECORD[ SELECT scan: * FROM index => [ -- scan of a domain index by name scanHandle: DBStorage.IndexScanHandle], tupleSet => [ -- scan of entire domain, no constraint scanHandle: DBStorage.TuplesetScanHandle], empty => -- NextEntity always returns NIL on one of these NULL, nested => [ -- scan multiple domains, concatenating the DomainSubset results remainingDomains: LIST OF Domain, -- (sub-)domains still to scan previousDomains: LIST OF Domain, -- domains already scanned lowName, highName: ROPE, -- passed by client start: FirstLast, -- passed by client currentEntitySet: EntitySet], -- current set; go on to next domain when done segment => [ -- scan multiple segments, concatenating the DomainSubset results remainingSegments: LIST OF ATOM, -- remaining segments to search previousSegments: LIST OF ATOM, -- segments already scanned domain: Domain, -- domain we are scanning (passed by client) lowName, highName: ROPE, -- passed by client start: FirstLast, -- passed by client searchSubDomains: BOOL← FALSE, -- passed by client (not currently used) currentEntitySet: EntitySet], -- the EntitySet in the current segment ENDCASE ]; FirstLast: TYPE = DB.FirstLast; AttributeValueList: TYPE = DB.AttributeValueList; AttributeList: TYPE = DB.AttributeList; END. Edited by: Cattell on 23-Nov-81 13:12:33: added nameElement EntitySet variant. Cattell on 29-Dec-81 14:16:20: removed it again, don't need it; added empty variant, made all variants lower case names. Cattell on 29-Dec-81 16:32:50: what Eric was calling a system EntitySetObject was really a group EntitySetObject, i changed it to use an entity position. Took out DBTuples dependency. Cattell on July 16, 1982 3:11 pm: Removed RefSet, MatchSet, RefSetObject, MatchSetObject. Added empty variant of RelshipSet. Cattell on October 22, 1982 12:28 pm: Changes for new properties, indexes, and system entities. Reduced size of largest variant of TupleHandle. Cattell on November 4, 1982 9:29 am: More revisions. Didn't need to reduce size of largest variant of TupleHandle, since allocation machinery only allocates for size needed. Put vAttributes into tupleSet variant. Added surrogate field to tupleset, index, and group variants of RelshipSets. Added augment variant to RelshipSets and EntitySets for future use; may have to change later.