Data Types and Forms

Data Type Mappings

The following table shows the mapping between data types in C++ and their corresponding data types in DolphinDB (“-“ indicates that there is no matching C++ data type).

Category

DolphinDB Data Type

DolphinDB Example

C++ Underlying Type

C++ Example

C++ API Type

Example for Converting Between C++ Primitive and API Type

NUMERIC BOOL false char 0 Bool

ConstantSP data = new Bool(true);

bool value = data->getBool();

CHAR ’a' char 'a' Char

ConstantSP data = new Char('a');

char value = data->getChar();

SHORT 122h short 122 Short

ConstantSP data = new Short(122);

short value = data->getShort();

INT 21 int 21 Int

ConstantSP data = new Int(21);

int value = data->getInt();

LONG 22l long long 22 Long

ConstantSP data = new Long(22);

long long value = data->getLong();

FLOAT 2.1f float 2.1f Float

ConstantSP data = new Float(2.1f);

float value = data->getFloat();

DOUBLE 2.2 double 2.2 Double

ConstantSP data = new Double(2.2);

double value = data->getDouble();

DECIMAL32 decimal32(2.1, 3) int 2100 Decimal32

ConstantSP data = new Decimal32(2, 2);

double value = data->getDouble();

DECIMAL64 decimal64(2.1, 3) long 2100 Decimal64

ConstantSP data = new Decimal64(8, 8);

double value = data->getDouble();

DECIMAL128 decimal128(2.1, 3) int128 2100 Decimal128

ConstantSP data = new Decimal128(18, 18);

double value = data->getDouble();

TEMPORAL DATE 2013.06.13 int 15869 Date

ConstantSP data = new Date(2013, 6, 13);

int value = data->getInt();

MONTH 2012.06M int 24149 Month

ConstantSP data = new Month(2012, 6);

int value = data->getInt();

TIME 13:30:10.008 int 48610008 Time

ConstantSP data = new Time(13, 30, 10, 8);

int value = data->getInt();

MINUTE 13:30m int 810 Minute

ConstantSP data = new Minute(13, 30);

int value = data->getInt();

SECOND 13:30:10 int 48610 Second

ConstantSP data = new Second(13, 30, 10);

int value = data->getInt();

DATETIME 2012.06.13 13:30:10 int 1339594210 DateTime

ConstantSP data = new DateTime(2012, 6, 13, 13, 30, 10);

int value = data->getInt();

DATEHOUR 2012.06.13T13 int 372109 DateHour

ConstantSP data = new DateHour(2012, 6, 13, 13);

int value = data->getInt();

TIMESTAMP 2012.06.13 13:30:10.008 long long 1339594210008 Timestamp

ConstantSP data = new Timestamp(2012, 6, 13, 13, 30, 10, 8);

long long value = data->getLong();

NANOTIME 13:30:10.008007006 long long 48610008007006 NanoTime

ConstantSP data = new NanoTime(13, 30, 10, 8007006);

long long value = data->getLong();

NANOTIMESTAMP 2012.06.13 13:30:10.008007006 long long 1339594210008007006 NanoTimestamp

ConstantSP data = new NanoTimestamp(2012, 6, 13,13, 30, 10, 8007006);

long long value = data->getLong();

LITERAL STRING “Hello” std::string “Hello” String

ConstantSP data = new String("Hello");

std::string value = data->getString();

SYMBOL “Hello” - - - -
BLOB “Hello” std::string “Hello” String

ConstantSP data = new String("Hello", true);

std::string value = data->getString();

OTHER UUID 5d212a78-cc48-e3b1-4235-b4d91473ee87 unsigned char[16] - Uuid

ConstantSP data = new Uuid(true);

std::string value = data->getString();

INT128 e1671797c52e15f763380b45e841ec32 unsigned char[16] - Int128

ConstantSP data = new Int128();

std::string value = data->getString();

IPADDR 192.168.1.13 unsigned char[16] - IPAddr

ConstantSP data = new IPAddr();

std::string value = data->getString();

VOID NULL - - Void

ConstantSP data = new Void();

Supported Data Forms

The DolphinDB C++ API supports various data forms, which are listed below with examples of DolphinDB data forms.

Data Form Description DolphinDB Example
scalar a variable that holds one value at a time 5, 1.3, 2012.11.15, `hello
vector a container that holds a list of objects in a given order [1,2,3,4,5,6,7,8,9,10]
array vector a two-dimensional vector where each row is a variable-length vector [[1,2,3],[4,5],[6,7,8],[9,10]]
matrix a one-dimensional array with column major matrix([1 2 3, 4 5 6]);
set a container that holds a list of unsorted objects with no duplicate values (2,5)
dictionary a container that holds a list of unique key-value pairs (1->4.5, 2->7.8, 3->4.3)
table a database object that holds a list of vectors in a given order -