T - type of the event symbol for this event type.public interface IndexedEvent<T> extends EventType<T>
Order represents an order to buy or to sell some market instrument
that is currently active on a market exchange and multiple
orders are active for each symbol at any given moment in time.
Candle represent snapshots of aggregate information
about trading over a specific time period and there are multiple periods available.
The Candle is also an example of TimeSeriesEvent that is a more specific event type.
Index for each event is available via index property.
Indexed events retain information about multiple events per symbol based on the event index
and are conflated based on the event index. Last indexed event for each symbol and index is always
delivered to event listeners on subscription, but intermediate (next-to-last) events for each
symbol+index pair are not queued anywhere, they are simply discarded as stale events.
More recent events represent an up-to-date information about some external entity.
eventFlags property.
Some indexed events, like Order, support multiple sources of information for the
same symbol. The event source is available via source property.
The value of source property is always DEFAULT for
time-series events and other singe-sourced events like Series, that do not support this feature.
The value of eventFlags property has several significant bits that are packed
into an integer in the following way:
31..7 6 5 4 3 2 1 0
+---------+----+----+----+----+----+----+----+
| | SM | | SS | SE | SB | RE | TX |
+---------+----+----+----+----+----+----+----+
Each source updates its transactional state using these bits separately.
The state of each source has to be tracked separately in a map for each source.
However, event index is unique across the sources. This is achieved by allocating
an event-specific number of most significant bits of index for use as
a source id.
TX (bit 0) — TX_PENDING is an indicator of pending transactional update.
It can be retrieved from eventFlags with the following piece of code:
boolean txPending = (event.
getEventFlags() & IndexedEvent.TX_PENDING) != 0;
When txPending is true it means, that an ongoing transaction update that spans multiple events is
in process. All events with txPending true shall be put into a separate pending list
for each source id and should be processed later when an event for this source id with txPending
false comes.
RE (bit 1) — REMOVE_EVENT is used to indicate that that the event with the
corresponding index has to be removed.
boolean removeEvent = (event.
getEventFlags() & IndexedEvent.REMOVE_EVENT) != 0;
SB (bit 2) — SNAPSHOT_BEGIN is used to indicate when the loading of a snapshot starts.
boolean snapshotBegin = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_BEGIN) != 0;
Snapshot load starts on new subscription and the first indexed event that arrives for each non-zero source id
on new subscription may have snapshotBegin set to true. It means, that an ongoing snapshot
consisting of multiple events is incoming. All events for this source id shall be put into a separate
pending list for each source id.
SE (bit 3) — SNAPSHOT_END or SS (bit 4) — SNAPSHOT_SNIP
are used to indicate the end of a snapshot.
boolean snapshotEnd = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_END) != 0; boolean snapshotSnip = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_SNIP) != 0;
The last event of a snapshot is marked with either snapshotEnd or snapshotSnip. At this time, all events
from a pending list for the corresponding source can be processed, unless txPending is also
set to true. In the later case, the processing shall be further delayed due to ongoing transaction.
The difference between snapshotEnd and snapshotSnip is the following.
snapshotEnd indicates that the data source had sent all the data pertaining to the subscription
for the corresponding indexed event, while snapshotSnip indicates that some limit on the amount
of data was reached and while there still might be more data available, it will not be provided.
SM (bit 6) — SNAPSHOT_MODE is used to instruct dxFeed to use snapshot mode.
It is intended to be used only for publishing to activate (if not yet activated) snapshot mode.
The difference from SNAPSHOT_BEGIN flag is that SNAPSHOT_MODE only switches on snapshot mode
without starting snapshot synchronization protocol.
When a snapshot is empty or consists of a single event, then the event can have both snapshotBegin
and snapshotEnd or snapshotSnip flags. In case of an empty snapshot, removeEvent on this event is
also set to true.
| Modifier and Type | Field and Description |
|---|---|
static int |
REMOVE_EVENT
Bit mask to get removal indicator from the value of
eventFlags property. |
static int |
SNAPSHOT_BEGIN
Bit mask to get snapshot begin indicator from the value of
eventFlags property. |
static int |
SNAPSHOT_END
Bit mask to get snapshot end indicator from the value of
eventFlags property. |
static int |
SNAPSHOT_MODE
Bit mask to set snapshot mode indicator into the value of
eventFlags property. |
static int |
SNAPSHOT_SNIP
Bit mask to get snapshot snip indicator from the value of
eventFlags property. |
static int |
TX_PENDING
Bit mask to get transaction pending indicator from the value of
eventFlags property. |
| Modifier and Type | Method and Description |
|---|---|
int |
getEventFlags()
Returns transactional event flags.
|
long |
getIndex()
Returns unique per-symbol index of this event.
|
IndexedEventSource |
getSource()
Returns source of this event.
|
void |
setEventFlags(int eventFlags)
Changes transactional event flags.
|
void |
setIndex(long index)
Changes unique per-symbol index of this event.
|
getEventSymbol, getEventTime, setEventSymbol, setEventTimestatic final int TX_PENDING
eventFlags property.
boolean txPending = (event.
getEventFlags() & IndexedEvent.TX_PENDING) != 0;
See "Event Flags" section.
static final int REMOVE_EVENT
eventFlags property.
boolean removeEvent = (event.
getEventFlags() & IndexedEvent.REMOVE_EVENT) != 0;
See "Event Flags" section.
static final int SNAPSHOT_BEGIN
eventFlags property.
boolean snapshotBegin = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_BEGIN) != 0;
See "Event Flags" section.
static final int SNAPSHOT_END
eventFlags property.
boolean snapshotEnd = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_END) != 0;
See "Event Flags" section.
static final int SNAPSHOT_SNIP
eventFlags property.
boolean snapshotSnip = (event.
getEventFlags() & IndexedEvent.SNAPSHOT_SNIP) != 0;
See "Event Flags" section.
static final int SNAPSHOT_MODE
eventFlags property.
This flag is intended for publishing only.
See "Event Flags" section.IndexedEventSource getSource()
int getEventFlags()
void setEventFlags(int eventFlags)
eventFlags - transactional event flags.IllegalArgumentException - if unsupported event flag is set in eventFlags.long getIndex()
void setIndex(long index)
index - unique per-symbol index of this event.Copyright © 2002–2023 Devexperts LLC. All rights reserved.