Record Class Descriptor
Create Record Class Descriptor
Each stream has a unique schema (message class definitions), not shared with other streams. Stream schema is represented by a RecordClassDescriptor
class or a collection of RecordClassDescriptor
classes in case of a polymorphic stream, a stream that can include messages of different classes. RecordClassDescriptor
class includes all fields with data types, references to parents RecordClassDescriptor
classes (in case data types form a hierarchy).
There several ways to create RecordClassDescriptor
:
By listing all message fields:
- Java
- Python
final DataField[] fields = {
new NonStaticDataField ("closePrice", "Close Price", new FloatDataType(FloatDataType.ENCODING_FIXED_DOUBLE, true)),
new NonStaticDataField ("openPrice", "Open Price", new FloatDataType (FloatDataType.ENCODING_FIXED_DOUBLE, true)),
new NonStaticDataField ("highPrice", "High", new FloatDataType (FloatDataType.ENCODING_FIXED_DOUBLE, true)),
new NonStaticDataField ("lowPrice", "Low", new FloatDataType (FloatDataType.ENCODING_FIXED_DOUBLE, true)),
new NonStaticDataField ("volume", "Volume", new FloatDataType (FloatDataType.ENCODING_FIXED_DOUBLE, true)),
new NonStaticDataField ("currency", "Currency Code", new VarcharDataType(VarcharDataType.ENCODING_INLINE_VARSIZE, true, true)),
new StaticDataField("exchange", "Exchange Code", new VarcharDataType("ALPHANUMERIC(10)", true, false), "EPAM")
};
String typeName = MyBarMessage.class.getName();
RecordClassDescriptor descriptor = new RecordClassDescriptor(typeName, "My Bar Message", false, null, fields);
marketMessageType = dxapi.TypeDef(
'deltix.timebase.api.messages.MarketMessage',
'Market Message',
[
dxapi.FieldDef('originalTimestamp', 'Original Timestamp', None, dxapi.DataTypeDef('TIMESTAMP'), False),
dxapi.FieldDef('currencyCode', 'Currency Code', None, dxapi.DataTypeDef('INTEGER', 'INT64'), True, 999),
dxapi.FieldDef('sequenceNumber', None, None, dxapi.DataTypeDef('INTEGER', 'INT64'), True, 0),
dxapi.FieldDef('sourceId', None, None, dxapi.DataTypeDef('VARCHAR', 'ALPHANUMERIC(10)'), False)
],
False, None, True
)
myBarsMessageType = dxapi.TypeDef(
'org.messages.MyBarMessage',
'My Bar Message',
[
dxapi.FieldDef('close', 'Close Price', None, dxapi.DataTypeDef('FLOAT', 'DECIMAL')),
dxapi.FieldDef('open', 'Open Price', None, dxapi.DataTypeDef('FLOAT', 'DECIMAL'), False, None, 'close'),
dxapi.FieldDef('high', 'High', None, dxapi.DataTypeDef('FLOAT', 'DECIMAL'), False, None, 'close'),
dxapi.FieldDef('low', 'Low', None, dxapi.DataTypeDef('FLOAT', 'DECIMAL'), False, None, 'close'),
dxapi.FieldDef('volume', 'Volume', None, dxapi.DataTypeDef('FLOAT', 'DECIMAL')),
dxapi.FieldDef('exchangeId', 'Exchange Code', None, dxapi.DataTypeDef('VARCHAR', 'ALPHANUMERIC(10)'), False)
],
False,
'deltix.timebase.api.messages.MarketMessage'
)
schema = dxapi.SchemaDef(
[myBarsMessageType],
[marketMessageType, myBarsMessageType]
)
By generating RecordClassDescriptor
based on the existing Java or C# class. Refer to introspection to learn more.
- Java
- Python
@SchemaElement(
name = "org.messages.MyBarMessage",
title = "Bar Message"
)
public class MyBarMessage extends InstrumentMessage {
public double closePrice;
public double openPrice;
public double highPrice;
public double lowPrice;
public double volume;
}
Introspector introspector = Introspector.createEmptyMessageIntrospector();
RecordClassDescriptor descriptor = introspector.introspectRecordClass(MyBarMessage.class);
schema = db.generateSchema(['deltix.timebase.api.messages.BarMessage'])
Several RecordClassDescriptor
classes can be aggregated into a RecordClassSet
. RecordClassSet
provides a list of all existing RecordClassDescriptor
classes as well as top level RecordClassDescriptor
classes.
info
Refer to Schema Annotations to learn more about annotations used by introspector to create stream schemas.
Static Fields
Stream schema fields may be static
and non-static
. Non-static field, see example above, is a regular type of field where each row has a specific value. Each static field value is identical for all columns and is recorded in the specific stream schema (e.g. "Exchange Code" field in the example above).
Field Data Types
Each field in a stream schema has a specific type, that determines the data type this field may work with.
Data Type | Class Name |
---|---|
BOOLEAN | BooleanDataType |
BYTE | IntegerDataType (INT8) |
SHORT | IntegerDataType (INT16) |
INTEGER | IntegerDataType (INT32) |
INT48 | IntegerDataType (INT48) |
LONG | IntegerDataType (INT64) |
PINTERVAL | IntegerDataType (PINTERVAL) |
FLOAT | FloatDataType (IEEE32) |
DOUBLE | FloatDataType (IEEE64) |
DECIMAL | FloatDataType (DECIMAL64) |
TIME_OF_DAY | TimeOfDayDataType |
TIMESTAMP | DateTimeDataType |
CHAR | CharDataType |
VARCHAR | VarcharDataType (UTF8) |
ALPHANUMERIC | VarcharDataType (ALPHANUMERIC) |
BINARY | BinaryDataType |
ARRAY | ArrayDataType |
CLASS | ClassDataType |
ENUM | EnumDataType |