quad technology - part ii

Upload: paolor

Post on 14-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 QUAD Technology - Part II

    1/4

    The Technology of theQUAD Editor, Part IIJim KramerHewlett-Packard

    St. Louis, MissouriINT"RODUCTION

    The QUAD editor is a text editor that was contributed to the Users Group library last year at the OrlandoUsers Group meeting. It has several features whichmake it notable and useful, the most important of whichare that it texts files instantaneously and that it canundo any or all editing changes. A paper in the proceedings of that meeting, titled "The Technology of theQUAD Editor," described the implementation of thesefeatures.In the past year QUAD has acquired many newcapabilities, including the ability to maintain multipleversions of a file, to cancel the effects of the precedingcommand, and to compile programs. The purpose ofthis paper is to describe the implementation of thesenew capabilities.A BRIEF DESCRIPTION

    QUAD is a line-oriented editor similar to EDIT/3000and TDP/3000. Its most important capability is instantaneous texting, and sometimes instantaneous keepingof files. A file is texted just by opening it and changesare kept in a separate work file. If the only changes to aftIe are modifications of existing lines, then keeping isdone by posting the changes back to the texted fIle.Since changes are kept in a separate work file it is easyto undo any or all changes just by removing them fromthe work file: QUAD's UNDO command does this.It is important that .QUAD be able to fmd lines in thetexted ftIe quickly. QUAD starts out with no knowledgeof the location of lines in the file, and must find re- "quested lines using binary search. However, QUADkeeps a record of all blocks read during the search pro-

    cess and uses this record to shorten subsequentsearches. The method is described in "a paper titled "ANew Tool for Keyed File Access (Sometimes)" in theproceedings of the Users Group's 1980 North Americanmeeting in San Jose.Features that are new to QUAD in the past year include the following:1. Operating directly on changes to the work ftIe, bymeans of the MODS key word in a line range.Changes can be listed, kept, and otherwise operated on. Fo r example, "List Mods" l is ts allchanges that have been made to the current file,

    and "Keep Modfile(Mods)" saves the modifications in a file named Modfile..2. Cancelling the most recent command which modified the file. The Cancel command does this.3. Maintaining multiple versions of the ftIe beingedited. The Freeze command prohibits furtherchanges to the current version and starts a newcurrent version. Prior versions can be read at anytime, but not modified, by using the VERSIONkeyword. For example, "List Version 1" lists thefirst version, and "Keep Filename(Version 1)"keepts it.

    TICKET FILESThe important characteristics of QUAD work fdes variable length keys and data and re-use of space - areprovided by a file access method which I call ticketfiles.With most ftIe access methods, the user who wantsdata stored specifies where it is to be stored - a record

    number. With ticket files the user does not specify; instead he just supplies the data to the access method andreceives back a "ticket" telling him where the data hasbeen stored. In order to retrieve the data at a later time,he must supply the ticket.It is important to recognize that this technique givesenormous flexibility to the ftIe access manager. Thedata can be put in the most convenient spot, for example a block that is already in a buffer in main memory.Within the block the record can be placed whereverthere is space. With ticket files a record need not evenbe placed contiguously within the block - it can bebroken into pieces.Ticket files turn out to be peIfectly suited to thoseapplications in which data is found through pointers:tickets are really just pointers.In order to make ticket ftIes satisfactory as work fIles,it was necessary to implement a keyed sequential access method based on ticket ftIes. The implementationis significantly different from KSAM and actually morepoweIful: both keys and data Can be variable length,space is re-used, and keyed sequential access can beeither forward or backward.When a key is stored, a ticket is stored with it. The

    5 -57-1J

  • 7/29/2019 QUAD Technology - Part II

    2/4

    ticket points to data. Thus storing data by key is a twostep process:1. Store the data and receive a ticket.2. Store the key and the ticket..Retrieving data by key reverses the two stC5Ps:1. Supply the key and receive the associated ticket.2. Use the ticket to retrieve the associated data.

    THE WORK FILE BEFOREMULTIPLE VERSIONSBefore describing how the current QUAD maintainsmultiple versions of a ftle, I will describe how earlierversions maintain the work fde.A ticket file is used as a work ftle, and contains twotypes of keys within the key structure: keys describing

    deleted ranges, and keys describing new or changed'data.To do a deletion, QUAD makes a single entry in itswork ftle which is just a 17 character key. The firstcharacter is a "0" (for delete), the next 8 characters arethe lower line number in the range, and the last 8 are theupper line number.

    . Since deletion is achieved with a single work fue entry, i t is very fast, and the speed is independent of thenumber of lines being deleted.A change entry consists of both a key and data. Thekey isjust the letter "C" followed by the 8 character linenumber, and the data is the line of text corresponding tothat line number.Schematically this s tructure is as follows, with anarrow representing a ticket h e l ~ with the key and pointing to the data.

    Change key -----------------> DataDelete key. IMPLEMENTING MULTIPLE VERSIONSMultiple versions were implemented by introducing a

    version record for each key, as follows:

    Change key - - - - ~ - - - > Version Record --------> Data1 1 1 1---------> Data1 . 1 1-----------> Da ta1 1-------------> DataII t ~ - - - - - - - - - - - - - - - - - - - - ) Data

    Again the arrows represent tickets. In this case a ticket is stored with the key and points to a record calledthe version record, which itself contains one or moretickets pointing to data. With each such ticket there is anumber identifying the version to which the data belongs.Using this structure QUAD can, for each line number(represented by the change key in the figure), maintainmultiple versions of each line.Version records are themselves variable length, each

    being large enough to hold tickets for all versions of thecorresponding line. There are generally many fewerversions of a particular line than there are ftIe versions,because a given line will not change with each versionof the ftle. A version record is restricted by QUADinternal buffering to 31 versions, but in general this willallow hundreds of file versions.To operate on a version of the ftIe, QUAD must integrate all deletions and changes for that version and allprevious versions with the originally texted ftIe. Thealgorithm to accomplish this is one of the most difficult Ihave had to write, and is complicated by trying to op-

    5 -57-2

    timize performance. One performance problem thatarises is that modifications to early versions which havesince been deleted can slow down access to later versions..: ., IMPLEMENTING THE CANCEL COMMAND

    The Cancel command cancels all changes made bythe most recent command to change the fue. Two consecutive Cancels have no net effect: the second cancelsthe effects of the first.The Cancel command was almost trivial to implementonce multiple versions had been implemented. Thetechnique used was to reserve space in each version.record to save a version number and ticket. Then whena command changes a line, the previous version numberand ticket can be saved in this space. The Cancel command then just restores the saved version number andticket to its prior place.The only other implementation requirement for theCancel command was to link together all the changedversion records. This was easily accomplished using thetickets of the version records.

  • 7/29/2019 QUAD Technology - Part II

    3/4

    COMPILING FROMWITHIN QUADQUAD allows compiling for five languages: COBOL,FORTRAN, RPG, SPL and PASCAL. The syntax ofthe commands for compiling is identical to the syntaxfor the corresponding MPE command. However tocompile from the fde currently being edited, it is necessary to replace the text file part of the command with aline range enclosed in quotes. For example:

    /SPL (ALL),$NEWPASS/FORTRAN (2B/4B),USL,*LPThe ability to compile from the fde being edited turnsout to' be especially useful for FORTRAN, because itpermits compilation of single subroutines.. All compilations are done by invoking the requestedcompiler as a son process. File equations are set up for

    all specified fdes, and the compiler is passed a PARM totell it which fdeswere specified.Whenever a line range is being compiled, QUADpasses the line range to the compiler through a messagefde. Message fdes are a new fde type for MPE as ofMPEIV.This was my first experience with message fdes, and Iencountered the following problems:

    1. Unless the message rde is built to contain only asingle block, all blocks are posted to disc. QUADuses a single block message ftle to prevent thisposting.

    2. If QUAD fdls the message rtle before the compileropens the ftle, QUAD's next write will fail with anend-of-ftle error. In this case, QUAD must loop,pausing and trying to write until the compiler getsthe ftle open. Once this occurs QUAD will automatically be suspended by the fde system ontrying towrite to a full ftle, as long as the compilerhas the file open.3. QUAD must be careful not to send a null ftle (norecords) to the compiler, because the fIle systemwill suspend the compiler indefmitely on its frrstattempt to read a record regardless ofwhether theftle has any writers.

    CONCLUSIONQUAD was created to quickly list ftles and makesimple changes. I believe it or a similar tool belong inevery 3000 shop as a significant resource saver.A few users now use QUAD rather than EDIT/3000.This pleases me because I think QUAD deserves it,although there are still things that EDIT can do whichQUAD cannot. However, I suspect that most users ofthese tools would quickly abandon' them for generalediting were a good full-screen editor to appear. I knowI would.If there is any permanent significance to QUAD, Ibelieve it is to be found in the ticket rde access method,which I have found to be enormously flexible and easyto use. QUAD does not take full advantage of its flexibility, and I am looking for an application that does.

    5 -57-3

  • 7/29/2019 QUAD Technology - Part II

    4/4

    '--;

    \