Dictionaries

Dictionaries are data structures that associate keys with values. They are called maps in C++ and Java, arrays in AWK, and association lists in LISP, so they are common data structures.

Declare a dictionary in a Global or Local block using the syntax:
dictionary(keyType, valueType) variable;
For instance, if you have an input stream called "input_stream", you could store an integer for distinct records as
dictionary(typeof(input_stream), integer) counter;

Only one value is stored per key. It is therefore important to understand what equality on keys means. For the simple datatypes, equality means the usual equality, for example, equality on integer or on string values. For record types, equality means that the keys match (the data fields and operation are ignored).

While dictionary and vector data structures can be defined globally, global use should be limited to reading them. Only one stream should write to a dictionary or vector data structure. And while that stream is writing, no other stream should write to or read from that data structure. The underlying objects used to manage the global dictionary or vector data structures are not thread-safe. A stream must have exclusive access to the global dictionary or vector data structure while writing. Allowing other streams to access these data structures while one stream is writing can result in server failure.

Use of these data structures should be limited to relatively static data (such as country codes) that will not need to be updated during processing, but will be read by multiple streams. Writing the data to the dictionary or vector must be completed before any streams read it.

All operations that read a global dictionary or vector should perform an isnull check, as shown in this example.
>typeof(streamname) rec := dict[symbol];
if( not (isnull(rec)) {
// use rec
}