TBD
Click Tag to Display Pages: development

Standard use case of loading data into TimeBase is when data is arranged chronologically. Time series events are recorded in TimeBase streams chronologically in a form of Messages. Messages are recorded in Time Slice Files (TSF) by their timestamps. Each TS file represents (describes) a specific time range. A TimeBase stream may be seen as a chronological collection of TS files. You may use insert mode to subsequently rewrite or modify some data in TS files. See Basic Concepts to learn more.

TimeBase allows working also with data that is not chronologically arranged. Even though you may use insert mode to write such data, data distribution approach allows to maximize writing performance (increase throughput and speed of writing data). In case you plan to work with data that is not chronologically arranged, you can create dedicated data partitions (spaces) to physically distribute TS files based on time range or other criteria. In this case, loaders can reference a specific space when loading data instead of just ingesting data into a stream. TimeBase allows multiple loaders to write concurrently to specific spaces. Reading performance is not impacted by this approach. Similar to loaders, cursors can reference spaces to read a specific data from TimeBase. One loader can write to just one TS file, one cursor can read from more than one TS file at the same time. Chronological order is preserved when working with spaces. For example, you can keep all rarely-traded instruments in your portfolio in a specific space, or you can create space, each for a specific time range. In the code example below we write data to a space that stores all messages for the year 2020.


//write into stream "space" 2020

LoadingOptions options = new LoadingOptions();
options.space = "2020";
try (TickLoader loader = stream.createLoader(options)) {
    InstrumentMessage message;
    // populate message attributes
    ...
    loader.send(message);
    ...
}
...

//select from the stream "space" 2020

SelectionOptions opts = new SelectionOptions();
opts.raw = false;
opts.live = false;
opts.space = "2020";
int count = 0;
try (TickCursor cursor = stream.select(Long.MIN_VALUE, opts)) {
    while (cursor.next())
        count++;
}
...