Go to the first, previous, next, last section, table of contents.


Annotation Order

DB applications may generally assume (and most of them do assume) that all annotations in any given annotation file are in canonical order. Successful use of iannsettime requires that this assumption be correct. Early versions of the DB library (before version 6.2) defined canonical order as time order. More recent versions of the DB library define canonical order as time and chan order (thus annotations are arranged first in time order, and any simultaneous annotations are arranged according to the value of their chan fields, from smallest to largest).

The combination of the time and chan fields of an annotation defines a unique location in a virtual array of annotations which an annotation file represents. No two annotations may occupy the same location in this virtual array. This restriction was enforced by versions of the DB library earlier than version 9.7. In these versions of the DB library, putann required that annotations be written in canonical order, and refused to write any out-of-order annotations supplied to it.

Current versions of the DB library do not impose this requirement. In version 9.7 and later versions, putann accepts and records out-of-order annotations and multiple annotations that occupy the same location. If any such annotations have been written, the completed annotation file is rewritten in canonical order by dbquit or oannclose. This is accomplished by running `sortann' (see the ECG Database Applications Guide) as a separate process using the ANSI C system function. If this function is not available, or if `sortann' cannot be run, dbquit (or oannclose) emits a warning message describing how to post-process the annotations to put them into canonical order.

Although it is possible using current versions of the DB library to write two or more annotations to the same location, only the last annotation written to any given location is retained in the canonically-ordered annotation file. Thus that an application that generates an annotation file can change the anntyp, subtyp, num, or aux fields of a previously-written annotation simply by writing another annotation to the same location (i.e, with the same time and chan fields). As a special case, an application may delete a previously-written annotation by writing a NOTQRS annotation to the same location. To move an annotation to a different location (i.e., to change its time or chan fields), it is necessary to delete it from the original location, and then to insert it at the desired location, using two separate invocations of putann.

In unusual circumstances, an unsorted annotation file may be useful (for example, as an aid for debugging the application that produced it; `rdann' can be used to list all of the annotations in such a file, in the order in which they were written). In some environments, the use of the ANSI C system function may be a security problem, and you may wish to avoid automatic sorting of annotations for this reason. Set the environment variable DBNOSORT (to any value) at run time, or define the symbol DBNOSORT when compiling the DB library, if you wish to suppress automatic annotation sorting by dbquit and oannclose.


Go to the first, previous, next, last section, table of contents.



George B. Moody (george@hstbme.mit.edu)