Sample
A sample is the unit of data exchanged between writers and readers. It provides multiple data members which are accessed with get accessor methods.
On this page:
Key and value
The sample key and value can be obtained by calling the getKey
and getValue
methods. If no value is available (if the sample event is Remove
for example), a default value is returned. You should check the sample event before getting the value to ensure the sample has a value.
Event
The getEvent
method returns the sample event enumeration value. The SampleEvent
enum definition is:
enum class SampleEvent : unsigned char { Add, Update, PartialUpdate, Remove };
If the event is Remove
, the sample value will be a default value.
If it's PartialUpdate
, the sample also provides the update tag with the getUpdateTag
method. The value returned by getValue
for a PartialUpdate
event is the value computed after applying the partial update using the updater identified by the update tag. If no updater is setup for the update tag, the partial update isn't applied leaving the value unchanged.
Timestamp, origin and session
The getTimestamp
method returns a std::chrono::time_point<std::chrono::system_clock>
value. It's set by the writer to the sending time of the sample.
The origin of the sample returned by getOrigin
is the name of the writer that published the sample. It's only available with samples returned by a reader. If no explicit writer name was set on writer creation, a unique name is generated by DataStorm.
The getSession
method returns an identifier to identify the session established between the two nodes that exchanged the sample. This session identifier can be used to retrieve the Ice connection using the node getSessionConnection method.