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; };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 64K in size.char
fields could store C-type strings or binary data. Trailing null characters for C strings are not required to be stored, since eXtremeDB adds them when the string is read out of the database, provided that the size of the supplied buffer is large enough to hold it.Example:{ char<8> name; };nchar<n>
Fixed length double-byte character array less than 64K 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 of less than 64K 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 64K in size. Likechar<n>
except in how comparison is performed while 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. Can be a field of a class, structure and even of a direct structure. Arrays andvectors
ofbinary<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 64K bytes 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 astring
field to save space. Ending null characters can be omitted, for the same reasons as forchar<n>
type. On creation, fields of typestring
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 64K in size. Seenchar
. On creation, fields of typenstring
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 64K in size. Seewchar
. On creation, fields of typewstring
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 typestring
is a variable length character array except for comparison where all bytes of thestring
are used). Can be a member of a class or structure (making it variable length). But it cannot be a field of direct structure; can be nullable; arrays andvectors
ofvarbinary
are allowed. On creation, fields of typevarbinary
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 theenum
is defined. An enumerator can be promoted to aunit1, uint2,
oruint4
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 Storage Type 1 - 2 signed<1> 3 - 4 signed<2> 5 - 9 signed<4> 10 - 19 signed<8> Example:{ numeric<10,2> num; decimal<8> dec; };sequenceA sequence is an unbounded array of eXtremeDB-supported scalar data elements, e.g. [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; };blobBinary data object; a byte array of any size, can be greater than 64K in size.Example:{ blob jpeg };vector
Variable length array of any data type, such assigned, unsigned,
orstruct
(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 object’soid
.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 object’sautoid
.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, typically it is 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 (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, typically it is 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 (Epoch).Example:{ time start_tm; };datetime
A 64 bit unsigned integer. It can store the date/time in higher resolution, up to nanoseconds. To be compatible with Java, C# and xSQL, C/C++ applications must store date/time with database's resolution (defined withMCO_RT_OPTION_DATETIME_PRECISION
). Please refer to page 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,8 byte integers, 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; for this, use avector
.Variable Length Field References
For each
string, vector, sequence, blob
oroptional struct
field a reference pointer (2 or 4 bytes) is stored in the data layout for the objects of this class. The actual object data is stored separately and retrieved via this reference address when the object is accessed. This can lead to performance considerations especially for persistent databases.String, Blob and Binary Fields
It is recommended to use
blob
fields only for large data fields (greater than 1 Kb). When a field is not intended to be used in indexes and its data size is less than 64 Kb it is recommended to usestring
fields (without any encoding).String
fields in eXtremeDB can contain arbitrary data, not only ASCII characters; i.e. arbitrary binary data can be stored in astring
without encoding. The only limitation is thatstring
fields cannot be used in internal comparisons (needed for indexes) and cannot be passed as parameters in xSQL. If a field of binary data is intended to be indexed, thebinary
orvarbinary
data type should be used. Unlikeblob
fields,binary
andvarbinary
fields can be added to both simple and compound indexes.