Base Data Types

The following table describes the data types recognized by the DDL compiler mcocomp:

Data type
Meaning
Example
signed<n>
Signed n-byte integer, n = 1, 2, 4, or 8.
Example:
    {
        signed<2> a_short;
    };
unsigned<n>
Unsigned n-byte integer, n = 1, 2, 4, or 8.
Example:
    {
        unsigned<4> hall;
    };
float
4-byte real number.
Example:
    {
        float rate;
    };
double
8-byte real number.
Example:
    {
        double rate;
    };
char<n>
Fixed-length single-byte character array less than 64 KB in size. char fields can store C-type strings or binary data. Trailing null characters for C strings do not need to be stored, since eXtremeDB adds them when the string is read out of the database, provided that the supplied buffer is large enough to hold them.
Example:
    {
        char<8> name;
    };
nchar<n>
Fixed-length double-byte character array less than 64 KB in size. nchar fields store 2-byte characters that are sorted by their numerical value. This is suitable for many Asian languages.
Example:

In the schema:

    {
        nchar<20> uname;
    };

In the C/C++ program:

    nchar_t uname[21];
wchar<n>
Fixed-length double-byte character array less than 64 KB in size. wchar fields store Unicode characters that are sorted according to the machine’s locale setting.
Example:

In the schema:

    {
        wchar<20> uname;
    };

In the C/C++ program:

    wchar_t uname[21];
binary<n>
Fixed-length byte array less than 64 KB in size. Unlike char<n>, comparisons are performed differently when building an index or searching. For these purposes, an array of characters has the natural delimiter '\0' that marks the end of the compared part; binary data are used entirely as defined by the array size. It can be a field of a class, structure, or direct structure. Arrays and vectors of binary<n> are allowed.
Example:
    {
        binary<100> b;
        binary<100> b_array[10];
        vector<binary<100>> b_vector;
    };
string
Variable-length single-byte character array of less than 64 KB in size. Bytes are returned to the application exactly as stored, up to the length of the supplied buffer. C strings of unknown length should be stored in a string field to save space. Ending null characters can be omitted for the same reasons as for the char<n> type. On creation, fields of type string contain only a 2- or 4-byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable-length storage, which consists of the 2-byte length followed by the body.
Example:
    {
        string description;
    };
nstring
Variable-length double-byte character array less than 64 KB in size. See nchar. On creation, fields of type nstring contain only a 2- or 4-byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable-length storage, which consists of the 2-byte length followed by the body.
Example:

In the schema:

    {
        nstring uname;
    };

In the C/C++ program:

    nchar_t *uname;
wstring
Variable-length double-byte character array less than 64 KB in size. See wchar. On creation, fields of type wstring contain only a 2- or 4-byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable-length storage, which consists of the 2-byte length followed by the body.
Example:

In the schema:

    {
        wstring uname;
    };

In the C/C++ program:

    wchar_t *uname;
varbinary
Variable-length byte array. Like the string type, it is a variable-length character array, except that comparisons use all bytes. It can be a member of a class or structure, making it variable length. However, it cannot be a field of a direct structure; it can be nullable; and arrays and vectors of varbinary are allowed. On creation, fields of type varbinary contain only a 2- or 4-byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable-length storage, which consists of the 2-byte length followed by the body.
Example:
    {
        varbinary vb;
        varbinary vb_array[10];
        vector<varbinary> vb_vector;
    };
enum
User-defined type consisting of a set of named constants called enumerators. The name of each enumerator is treated as a constant and must be unique within the scope of the DDL schema where the enum is defined. An enumerator can be promoted to a uint1, uint2, or uint4 value.
Example:
    enum FLOWCONTROL {
        XON, CTS
    };

    class using_enum {
        FLOWCONTROL fc;
    };
numeric | decimal
numeric<W,P> = decimal<W,P>; W = width P = precision where P <= W < 20 The actual storage space occupied is determined by the specified width:
  • Width 1 - 2 — storage type signed<1>.
  • Width 3 - 4 — storage type signed<2>.
  • Width 5 - 9 — storage type signed<4>.
  • Width 10 - 19 — storage type signed<8>.
Example:
    {
        numeric<10,2> num;
        decimal<8> dec;
    };
sequence
A sequence is an unbounded array of eXtremeDB-supported scalar data elements, such as [u]int[1|2|3|4|8], float, and double.
Example:
    class quote
    {
        sequence<float> open;
        sequence<float> close;
        sequence<float> high;
        sequence<float> low;
        sequence<int4> volume;
        sequence< time asc> timestamp;
    };
blob
Binary data object: a byte array of any size, which can be greater than 64 KB.
Example:
    {
        blob jpeg;
    };
vector
Variable-length array of any data type, such as signed, unsigned, or struct in C terminology.
Example:
    struct A {
        unsigned<2> a1;
        char a2;
    };

    class A_class {
        vector <A> struct_array;
        vector<unsigned<2>> numbers;
    };
ref
Explicitly declared reference to an object by its oid.
Example:
    struct Id {
        unsigned<2> a1;
        char a2;
    };

    declare oid Id[20000];

    class A {
        ...
        oid;
    };

    class B {
        ...
        ref a; // reference to an
               // object of class A
    };
autoid_t
Explicitly declared reference to an object by its autoid.
Example:
    class A {
        ...
        autoid[20000];
    };

    class B {
        ...
        autoid_t<A> a;
        vector <autoid_t> va;
    };
date
A 32-bit unsigned integer. Though it can be used to store date values in any user-defined format, it is typically used to store the value used in most C/C++ time functions, which treat the integer value as the number of seconds since 1 Jan 1970 (the Epoch).
Example:
    {
        date start_dt;
    };
time
A 32-bit unsigned integer. Though it can be used to store time values in any user-defined format, it is typically used to store the value used in most C/C++ time functions, which treat the integer value as the number of seconds since 1 Jan 1970 (the Epoch).
Example:
    {
        time start_tm;
    };
datetime
A 64-bit unsigned integer. It can store date and time at a higher resolution, up to nanoseconds. To be compatible with Java, C#, and xSQL, C/C++ applications must store date and time at the database resolution, defined with MCO_RT_OPTION_DATETIME_PRECISION. See Managing Date/Time Fields in C for further details.
Example:
    {
        datetime start_dt;
    };
boolean
A fixed-size array of bits.
Example:
    {
        boolean bits[8];
    };
rect | rectangle
A rectangle with 2-, 4-, or 8-byte integer, float, or double coordinates.
Example:
    {
        rectangle <uint2> u2[3];
        rectangle<float> f[2];
    };

In addition, data types can be fixed-size arrays, for example:

    time start_tm[3];

Defines an array of three time values. Any element except vectors, blobs, and optional structs can be a fixed-size array. Fixed-size arrays cannot be used in indexes; use a vector instead.

Variable Length Field References

For each string, vector, or sequence field, and for each blob or optional struct field, a 2- or 4-byte reference pointer is stored in the data layout for objects of this class. The actual object data is stored separately and retrieved through this reference address when the object is accessed. This can lead to performance considerations, especially for persistent databases.

String, Blob and Binary Fields

Use blob fields only for large data fields, greater than 1 KB. When a field is not intended for use in indexes and its data size is less than 64 KB, use string fields without an encoding. string fields in eXtremeDB can contain arbitrary data, not only ASCII characters; that is, arbitrary binary data can be stored in a string without encoding. The only limitation is that string fields cannot be used in internal comparisons, needed for indexes, or passed as parameters in xSQL. If binary data is intended to be indexed, use the binary or varbinary data type. Unlike blob fields, binary and varbinary fields can be added to both simple and compound indexes.