DIRECTORY RefID USING [ID, nullID], Rope USING [ROPE], LoganBerry; LoganQuery: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; QueryClass: TYPE = REF QueryClassRec; QueryClassRec: TYPE = RECORD [ flavor: ATOM _ NIL, -- name of cursor's class retrieve: RetrieveProc _ NIL, -- get next database entry destroy: DestroyProc _ NIL -- end the query (and destroy the cursor) ]; RetrieveProc: TYPE = PROC [cursor: ComplexCursor, dir: CursorDirection _ increasing] RETURNS [entry: LoganBerry.Entry]; DestroyProc: TYPE = PROC [cursor: ComplexCursor] RETURNS []; ComplexCursor: TYPE = RECORD [ class: QueryClass _ NIL, -- name of cursor's class data: RefID.ID _ RefID.nullID -- data slot for cursor class implementor ]; CursorDirection: TYPE = LoganBerry.CursorDirection; NextEntry: PROC [cursor: ComplexCursor, dir: CursorDirection _ increasing] RETURNS [entry: LoganBerry.Entry]; EndGenerate: PROC [cursor: ComplexCursor] RETURNS []; GenerateEntries: PROC [db: LoganBerry.OpenDB, key: LoganBerry.AttributeType, start: LoganBerry.AttributeValue _ NIL, end: LoganBerry.AttributeValue _ NIL] RETURNS [cursor: ComplexCursor]; FilterEntries: PROC [input: ComplexCursor, pattern: ROPE, filter: FilterProc, atype: LoganBerry.AttributeType, stopIfNothingGreater: BOOLEAN _ FALSE] RETURNS [output: ComplexCursor]; FilterProc: TYPE = PROC [value: ROPE, pattern: ROPE] RETURNS [match: BOOLEAN, nothingGreater: BOOLEAN _ FALSE]; MergeEntries: PROC [input1, input2: ComplexCursor, atype: LoganBerry.AttributeType] RETURNS [output: ComplexCursor]; Equal: FilterProc; Prefix: FilterProc; Wildcard: FilterProc; RE: FilterProc; Soundex: FilterProc; END. ’LoganQuery.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Doug Terry, November 26, 1985 4:12:52 pm PST LoganQuery allows more complicated queries to be performed on a LoganBerry database than the simple retrievals provided by the LoganBerry interface. Database queries of various classes can be registered; retrieval operations are class-specific. For instance, the $Filter class returns database entries that match a particular pattern, while the $Merger class merges the entries returned by two independent queries. Filters can be cascaded to perform multiple-attribute queries. The predefined $Simple class permits operations identical to those provided by LoganBerry. Clients are free to create their own class of queries. Query classes Retrieves the next database entry in a manner particular to the class of query. Destroys the given cursor and any embedded cursors. ComplexCursor type Basic operations ComplexCursor creation is a class-specific operation. The following operations are syntactically identical and semantically similar to those provided by LoganBerry. Any errors raised by these operations are generated by LoganBerry. Retrieves the next entry relative to the given cursor. 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: IndexNotOpen, BadIndex, LogNotOpen, BadLogEntry Releases the cursor; no further operations may be performed using the given cursor. This must be called once for every cursor created. Predefined query classes $Simple Identical to the GenerateEntries operation provided by LoganBerry but returns a ComplexCursor with class=$Simple and data=LoganBerry.Cursor. Errors: LoganBerry.NoIndex $Filter Returns a ComplexCursor of class $Filter. Retrievals using this new cursor apply the given pattern-matching filter to the appropriate attribute of entries identified by the input cursor. A retrieval returns NIL if the input is exhausted or stopIfNothingGreater=TRUE and the filter procedure returns nothingGreater=TRUE. Compares the presented value to the pattern; match indicates the result of the comparison. If nothingGreater=TRUE then no value greater than or equal to the presented value could possibly match the pattern; nothingGreater=FALSE implies nothing about future comparisons. $Merger Returns a ComplexCursor of class $Merger. Retrievals using this new cursor merge the two input streams. The input streams should be ordered by the given attribute type. A retrieval returns NIL only when both inputs are exhausted. Predefined filters Compares the value and pattern for equality. Checks if the pattern is a prefix of the value. Prefix[v, "p"] is the same as Wildcard[v, "p*"], though faster. The pattern may contain zero or more wildcards (the character "*") that match anything. The pattern is taken to be a regular expression as defined in RegularExpressionDoc.tioga. Compares the value and pattern based on their Soundex codes. The Soundex encoding tends to group together variants of the same name; for instance, Johnson, Jansen, and Johansen have identical Soundex codes. Doug Terry November 6, 1985 9:55:44 am PST created Doug Terry, November 6, 1985 5:15:27 pm PST changes to: DIRECTORY, ILQuery, ~, Cursor, CursorDirection, CursorClass, CursorClassRec, RetrieveProc, DestroyProc, NextEntry, EndGenerate, GenerateEntries, FilterEntries, MatchResult, FilterProc, MergeEntries Doug Terry, November 7, 1985 2:59:51 pm PST changes to: ~, QueryClass, QueryClassRec, ComplexCursor, RetrieveProc, DestroyProc, FilterEntries, FilterProc, MergeEntries, Equal, Prefix, Wildcard, RegularExpression, Soundex, DIRECTORY, NextEntry Doug Terry, November 26, 1985 4:12:52 pm PST changes to: DIRECTORY, LoganQuery, RetrieveProc, CursorDirection, NextEntry, GenerateEntries, FilterEntries, MergeEntries ΚQ˜codešœ™Kšœ Οmœ1™