Atomary Types
MonetDB supports an extensible type system to accomodate a wide spectrum of database kernels and application needs. The type administration keeps track of their properties and provides access to the underlying implementations.
MAL recognizes the definition of a new type by replacing the module keyword with atom. Atoms definitions require special care, because their definition and properties should be communicated with the kernel library. The commands defined in an atom block are screened as of interest to the library.
MonetDB comes with the hardwired types bit, chr, sht, int, lng, oid, flt, dbl, str and bat, the representation of a bat identifier. The kernel code has been optimized to deal with these types efficiently, i.e. without unnecessary function call overheads.
A small collection of user-defined atom types is shipped with the sysem. They implement types considered essential for end-user applications, such as color, date, daytime, time, timestamp, timezone, blob, and inet, url. They are implemented using the type extension mechanism described below. As such, they provide examples for future extensions. A concrete example is the 'blob' datatype in the MonetDB atom module library(see ../modules/atoms/blob.mx)
The MAL type module overloads the atom structure managed in the GDK library. For the time being, we assume GDK to support at most 127 different atomic types. Type composition is limited to at most two builtin types to form a BAT. Furthermore, the polymorphic type any can be qualified with a type variable index any$I, where I is a digit (1-9). Beware, the TYPE_any is a speudo type known within MAL only.
Defining your own types
For the courageous at heart, you may enter the difficult world of extending the kernel library. The easiest way is to derive the atom modules from one shipped in the source distributed. More involved atomary types require a study of the documentation associated with the atom structures (gdk_atoms), because you have to develop a handful routines complying with the signatures required in the kernel library. They are registered upon loading the atom module.
- Printer-friendly version
- Login to post comments
