The following table describes the data types recognized by the DDL compiler
mcocomp:Data typeMeaningExamplesigned<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; };float4-byte real number.Example:{ float rate; };double8-byte real number.Example:{ double rate; };char<n>Fixed-length single-byte character array less than 64 KB in size.charfields 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.ncharfields 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.wcharfields 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. Unlikechar<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;binarydata are used entirely as defined by the array size. It can be a field of a class, structure, or direct structure. Arrays andvectorsofbinary<n>are allowed.Example:{ binary<100> b; binary<100> b_array[10]; vector<binary<100>> b_vector; };stringVariable-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 astringfield to save space. Ending null characters can be omitted for the same reasons as for thechar<n>type. On creation, fields of typestringcontain 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; };nstringVariable-length double-byte character array less than 64 KB in size. Seenchar. On creation, fields of typenstringcontain 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;wstringVariable-length double-byte character array less than 64 KB in size. Seewchar. On creation, fields of typewstringcontain 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;varbinaryVariable-length byte array. Like thestringtype, 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 andvectorsofvarbinaryare allowed. On creation, fields of typevarbinarycontain 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; };enumUser-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 theenumis defined. An enumerator can be promoted to auint1,uint2, oruint4value.Example:enum FLOWCONTROL { XON, CTS }; class using_enum { FLOWCONTROL fc; };numeric | decimalnumeric<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 typesigned<1>.Width 3 - 4— storage typesigned<2>.Width 5 - 9— storage typesigned<4>.Width 10 - 19— storage typesigned<8>.Example:{ numeric<10,2> num; decimal<8> dec; };sequenceA sequence is an unbounded array of eXtremeDB-supported scalar data elements, such as [u]int[1|2|3|4|8],float, anddouble.Example:class quote { sequence<float> open; sequence<float> close; sequence<float> high; sequence<float> low; sequence<int4> volume; sequence< time asc> timestamp; };blobBinary data object: a byte array of any size, which can be greater than 64 KB.Example:{ blob jpeg; };vectorVariable-length array of any data type, such assigned,unsigned, orstructin C terminology.Example:struct A { unsigned<2> a1; char a2; }; class A_class { vector <A> struct_array; vector<unsigned<2>> numbers; };refExplicitly declared reference to an object by itsoid.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 };Explicitly declared reference to an object by itsautoid.Example:class A { ... autoid[20000]; }; class B { ... autoid_t<A> a; vector <autoid_t> va; };dateA 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; };timeA 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; };datetimeA 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 withMCO_RT_OPTION_DATETIME_PRECISION. See Managing Date/Time Fields in C for further details.Example:{ datetime start_dt; };booleanA fixed-size array of bits.Example:{ boolean bits[8]; };rect | rectangleA rectangle with 2-, 4-, or 8-byte integer,float, ordoublecoordinates.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
timevalues. Any element except vectors, blobs, and optional structs can be a fixed-size array. Fixed-size arrays cannot be used in indexes; use avectorinstead.Variable Length Field References
For each
string,vector, orsequencefield, and for eachbloboroptional structfield, 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
blobfields 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, usestringfields without an encoding.stringfields in eXtremeDB can contain arbitrary data, not only ASCII characters; that is, arbitrary binary data can be stored in astringwithout encoding. The only limitation is thatstringfields cannot be used in internal comparisons, needed for indexes, or passed as parameters in xSQL. If binary data is intended to be indexed, use thebinaryorvarbinarydata type. Unlikeblobfields,binaryandvarbinaryfields can be added to both simple and compound indexes.