This document presents an insider's look into the design of translation table, a data structure now heavily used and relied on in SDSS environment.
In this scheme, a translation table is built at runtime to map data source to data destination, while actual data conversion is done through compiled-code. In other words, a translation table is a set of string-based commands that instruct the compiled-code how data conversion should be done. Translation tables contain information specific to a particular data structure, but the underlying code is generaly and invariant.
A translation table is a collection of translation entries, each entry effectively instruct the conversion code to do one conversion. For an intruction to be flexible enough, a table entry must
Note here we don't have to require source data type be specified. If TBLCOL is the source or a C object is the data source, the source type information is easily avaible from TBLCOL or SCHEMA. Even though most likely same thing can be said about destination data, there are cases one does have to specify the destination type, e.g, aliased types (by typedef).
A good example of this requirement being particularly useful is when destination is a string represented by a pointer to char and the source data should be copied over to the memory area pointed by the pointer, not the memory area occupied by the pointer. Same thing can be said about other type of pointers, pointers with mulitple level of indirections, etc.
In SDSS, data structures in which one field points off to another structure are frequently encountered. The translation table scheme must be able to copy over the data to the real destination.
Note, we can imitate the process of traversing links in memory by using multiple source/destination pairs, each pair is an entry. Thus the translation table should support multi-line translation entry.
Note this requirement is different from 3, where dimensionality is invariant among objects.
Useful when source and destination should differ in units.
where num and dstDataType are the enumerated and numeric representation of dsttype and size. Num is filled not at the time when entry is added.
A translation table keeps the track of the access status of all the entries and uses a hashing scheme:
Creates a bare-bone translation table in memory. No entries yet.
Deletes a translation table as well all the entries in it and free the memory.
Add a table entry to a translation table.
clear and frees the memory of all the entries in a table but keep the bare-bone structure.
create a complete translation table from a given ascii file.
dump out the content of the translation table to an ascii file. Users may edit the output file.
Check the translation table syntax according to a specific schema. The routine checks for correct grammar and test if the fields are existent in the schema. At this time, it also fill a few attributes in each entry, e.g, the "num" field in SCHEMATRANS_ENTRY.