Skip to content

StreamBroker

#include <sbio/core/broker.hh>
template<IOTraits IO, class EPolicy, FormatTraits< IO, EPolicy > FTraits, class Derived = void>
class StreamBroker

Defined in src/lib/sbio/core/broker.hh:117

A StreamBroker organizes Streams and mediates data requests.

The StreamBroker has a state machine and exposes data-format dependent metadata and data buffers.

  • IO The type of the IO strategy being used.

  • EPolicy The Execution policy to use for reading data.

  • FTraits The data format to read.

  • Derived The sub-class type if defined. All functionality can be exposed purely from the FTraits template parameter, so sub-classing is not strictly necessary. I.e., this class can be instantiated directly.

Name Kind Owner
StreamBroker function Declared here
StreamBroker function Declared here
configure_broker function Declared here
allocate_storage function Declared here
open_data_stream function Declared here
discover_metadata function Declared here
prepare function Declared here
index_stream function Declared here
fetch_step function Declared here
fetch_steps function Declared here
process function Declared here
run function Declared here
step function Declared here
state function Declared here
stream_state function Declared here
capacity function Declared here
current_buffer function Declared here
get_data_in_buffer function Declared here
metadata function Declared here
metadata function Declared here
config function Declared here
config function Declared here
set_metadata function Declared here
stream function Declared here
stream function Declared here
sync_vars function Declared here
stream_idx function Declared here
StreamCount variable Declared here
m_streams variable Declared here
m_config variable Declared here
m_broker_state variable Declared here
m_stream_state variable Declared here
m_metadata_inv variable Declared here
m_storage variable Declared here
IOPolicy typedef Declared here
ExecutionPolicy typedef Declared here
DataFormat typedef Declared here
StreamType typedef Declared here
SBStorageType typedef Declared here
EPolicyConfig typedef Declared here
StreamConfig typedef Declared here
DSConfig typedef Declared here
StreamState typedef Declared here
StreamMetadata typedef Declared here
DataAccessPtn typedef Declared here
DataRequest typedef Declared here
StepIdxType typedef Declared here
Return Name Description
StreamBroker inline A default constructor is provided for simplicity.
StreamBroker inline Construct the Broker with a specific, data-format-dependent, set of parameters.
SBIO_HD void configure_broker inline If a Broker has been default-constructed, it can be moved through the INIT state via this function.
SBIO_HD void allocate_storage inline Perform data format specific allocations in preparation for streaming data.
SBIO_HDIOStatus open_data_stream inline Connect and open brokered Streams.
SBIO_HDIOStatus discover_metadata inline After Stream connection, perform metadata discovery.
SBIO_HDIOStatus prepare inline Run through the initial allocate, connect, discover steps in one.
SBIO_HDIOStatus index_stream inline Index the data Stream if appropriate and implemented.
SBIO_HDIOStatus fetch_step inline Retrieve data for the specified index using the provided lookup pattern.
SBIO_HDIOStatus fetch_steps inline
SBIO_HDIOStatus process inline
SBIO_HDIOStatus run inline
SBIO_HDIOStatus step inline
SBIO_HDBrokerState state const inline Return the current broker state along the state machine.
SBIO_HDStreamState stream_state const inline Return the underlying StreamState of the brokered stream(s).
SBIO_HD std::size_t capacity const inline Return the current capacity for data formats that support indexing.
SBIO_HD FTraits::DataUnit * current_buffer inline Access the current data after a fetch.
SBIO_HDDataResult get_data_in_buffer inline Parse specific data from the buffer after a fetch.
SBIO_HDStreamMetadata & metadata inline The compiled metadata from the brokered Stream(s).
SBIO_HD const StreamMetadata & metadata const inline The compiled metadata from the brokered Stream(s).
SBIO_HDStreamConfig & config inline The set of StreamParameters configuration used to instantiate the broker.
SBIO_HD const StreamConfig & config const inline The set of StreamParameters configuration used to instantiate the broker.
SBIO_HD void set_metadata inline Configure the Broker with a set of metadata.
SBIO_HDStreamType & stream inline
SBIO_HD const StreamType & stream const inline
SBIO_HD auto sync_vars inline
SBIO_HD std::uint32_t stream_idx const inline

inline

inline StreamBroker()

Defined in src/lib/sbio/core/broker.hh:198

A default constructor is provided for simplicity.

The Broker will remain in the INIT state until explicitly configured, if using this constructor.


inline

inline StreamBroker(const StreamConfig & cfg)

Defined in src/lib/sbio/core/broker.hh:207

Construct the Broker with a specific, data-format-dependent, set of parameters.

Parameter Type Description
cfg const [StreamConfig](#streamconfig-2) & The data-format-dependent configuration parameters.

inline

inline SBIO_HD void configure_broker(const StreamConfig & cfg)

Defined in src/lib/sbio/core/broker.hh:220

If a Broker has been default-constructed, it can be moved through the INIT state via this function.

This corresponds to the INIT stage of the state machine.

Parameter Type Description
cfg const [StreamConfig](#streamconfig-2) & The data format specif configuration parameters.

inline

inline SBIO_HD void allocate_storage()

Defined in src/lib/sbio/core/broker.hh:230

Perform data format specific allocations in preparation for streaming data.

This corresponds to the ALLOCATE stage of the state machine.


inline

inline SBIO_HDIOStatus open_data_stream()

Defined in src/lib/sbio/core/broker.hh:257

Connect and open brokered Streams.

This corresponds to the CONNECT stage of the state machine.

The IOStatus result from connecting.


inline

inline SBIO_HDIOStatus discover_metadata()

Defined in src/lib/sbio/core/broker.hh:276

After Stream connection, perform metadata discovery.

This function determines what contents are available from the brokered Streams. This information is then available to the caller (or higher-level abstractions).

This corresponds to the DISCOVERY stage of the state machine.

The IOStatus result for whether metadata reads were successful.


inline

inline SBIO_HDIOStatus prepare()

Defined in src/lib/sbio/core/broker.hh:306

Run through the initial allocate, connect, discover steps in one.

This is simply a convenience wrapper instead of calling each of the early state transitions independently. The down-side is the status will be cummulative so a failure may possibly not be immediately clear as originiating from one step or another.

The IOStatus result from all 3 steps.


inline

inline SBIO_HDIOStatus index_stream()

Defined in src/lib/sbio/core/broker.hh:343

Index the data Stream if appropriate and implemented.

Indexing affords the possibility of ordering the data from (a) Stream(s) for indexable lookup. Not all data formats support a notion of indexing.

This corresponds to the INDEXING stage of the state machine.

An IOStatus for whether indexing was successful.


inline

inline SBIO_HDIOStatus fetch_step(StepIdxType step_idx, const DataAccessPtn ptn)

Defined in src/lib/sbio/core/broker.hh:387

Retrieve data for the specified index using the provided lookup pattern.

The index used for lookup is data format dependent. If the format supports indexing, then it may correspond to a chunk of data other than the most recent. If not, then this will always return the most recent data from the Stream.

An IOStatus for whether the lookup was succesful.

Parameter Type Description
step_idx [StepIdxType](#stepidxtype-4) The data format-dependent data chunk index.
ptn const [DataAccessPtn](#dataaccessptn-5) A lookup pattern. Some data formats support access in various ways.

inline

inline SBIO_HDIOStatus fetch_steps(std::initializer_list< StepIdxType > steps, const DataAccessPtn ptn)

Defined in src/lib/sbio/core/broker.hh:412


inline

inline SBIO_HDIOStatus process()

Defined in src/lib/sbio/core/broker.hh:460


inline

inline SBIO_HDIOStatus run()

Defined in src/lib/sbio/core/broker.hh:468


inline

template<class CBType> inline SBIO_HDIOStatus step(CBType && callback)

Defined in src/lib/sbio/core/broker.hh:478


const inline

inline SBIO_HDBrokerState state() const

Defined in src/lib/sbio/core/broker.hh:495

Return the current broker state along the state machine.

The current broker state along the state machine.


const inline

inline SBIO_HDStreamState stream_state() const

Defined in src/lib/sbio/core/broker.hh:510

Return the underlying StreamState of the brokered stream(s).

The StreamState tracks data format-specific information about the streamed data. This may include information such as counters, whether certain transitions have been encountered, or whether the stream has been exhausted/will be soon. Refer to the specific FormatTraits for the format of interest for more information.

In cases where the broker manages multiple Streams, there is still one shared StreamState which encompasses all of them.

The current Stream(s) StreamState.


const inline

inline SBIO_HD std::size_t capacity() const

Defined in src/lib/sbio/core/broker.hh:522

Return the current capacity for data formats that support indexing.

When indexing is supported, the capacity indicates how many indices are immediately available to jump to in the stream. Reading beyond the capacity requires another INDEXING transition, or a move to reading in true streaming manner.

The current capacity: the number of immediately available indices.


inline

inline SBIO_HD FTraits::DataUnit * current_buffer()

Defined in src/lib/sbio/core/broker.hh:544

Access the current data after a fetch.

The action of performing a fetch pulls the data from the stream into available memory managed by the Broker (in conjunction with the Execution policy). The fetch APIs, however, do not return access to this memory directly. Instead, this function should be used to access data after a fetch if the raw buffer is required. Otherwise, more specific APIs can be used to parse specific components from the buffer.

A pointer to the buffer filled after a fetch from (a) Stream(s).


inline

inline SBIO_HDDataResult get_data_in_buffer(const DataRequest & req, const DataAccessPtn ptn, std::size_t batch_idx = 0)

Defined in src/lib/sbio/core/broker.hh:567

Parse specific data from the buffer after a fetch.

This function parses, in a data format-dependent manner, a portion of data from a buffer fetched from (a) Stream(s).

A data-format-dependent result object with the requested data.

Parameter Type Description
req const [DataRequest](#datarequest-7) & A data-format-dependent struct with a parse request.
ptn const [DataAccessPtn](#dataaccessptn-5) A data-format-dependent access pattern for formats that can be read in different ways.
batch_idx std::size_t If reading by batches, the index for which of the steps in the batch to be resolved.

inline

inline SBIO_HDStreamMetadata & metadata()

Defined in src/lib/sbio/core/broker.hh:586

The compiled metadata from the brokered Stream(s).

This function should only be used after having passed the DISCOVERY state, or having set the metadata explicitly.

The compiled metadata from the brokered Stream(s).


const inline

inline SBIO_HD const StreamMetadata & metadata() const

Defined in src/lib/sbio/core/broker.hh:595

The compiled metadata from the brokered Stream(s).

This function should only be used after having passed the DISCOVERY state, or having set the metadata explicitly.

The compiled metadata from the brokered Stream(s).


inline

inline SBIO_HDStreamConfig & config()

Defined in src/lib/sbio/core/broker.hh:602

The set of StreamParameters configuration used to instantiate the broker.

The StreamParameters configuration.


const inline

inline SBIO_HD const StreamConfig & config() const

Defined in src/lib/sbio/core/broker.hh:608

The set of StreamParameters configuration used to instantiate the broker.

The StreamParameters configuration.


inline

inline SBIO_HD void set_metadata(StreamMetadata & metadata)

Defined in src/lib/sbio/core/broker.hh:624

Configure the Broker with a set of metadata.

Under some Execution policies, not all Brokers will necessarily move through all states of the state machine. In case the DISCOVERY state is not explicitly moved to, then the metadata for the Broker can be set using this function. For example, multiple Brokers may be reading different parts of the same Stream(s) in parallel.

The metadata is not only used by the caller, but also internally by the Broker, or at least, it may be used. For that reason, this function is made available.


inline

inline SBIO_HDStreamType & stream(std::size_t role_idx)

Defined in src/lib/sbio/core/broker.hh:628


const inline

inline SBIO_HD const StreamType & stream(std::size_t role_idx) const

Defined in src/lib/sbio/core/broker.hh:632


inline

inline SBIO_HD auto sync_vars()

Defined in src/lib/sbio/core/broker.hh:636


const inline

inline SBIO_HD std::uint32_t stream_idx() const

Defined in src/lib/sbio/core/broker.hh:649

Return Name Description
constexpr std::size_t StreamCount static constexpr

static constexpr

constexpr std::size_t StreamCount = FTraits::RoleCount

Defined in src/lib/sbio/core/broker.hh:190

Return Name Description
StreamType m_streams
StreamConfig m_config
BrokerState m_broker_state
StreamState m_stream_state
StreamMetadata m_metadata_inv
SBStorageType m_storage

StreamType m_streams

Defined in src/lib/sbio/core/broker.hh:652


StreamConfig m_config

Defined in src/lib/sbio/core/broker.hh:653


BrokerState m_broker_state

Defined in src/lib/sbio/core/broker.hh:654


StreamState m_stream_state

Defined in src/lib/sbio/core/broker.hh:655


StreamMetadata m_metadata_inv

Defined in src/lib/sbio/core/broker.hh:656


SBStorageType m_storage

Defined in src/lib/sbio/core/broker.hh:657

Name Description
IOPolicy The type of the IO strategy being used.
ExecutionPolicy The Execution policy type.
DataFormat The type of data being read.
StreamType The type of Stream: I.e., the IO strategy and data format being read.
SBStorageType The type of the StreamBroker’s Storage.
EPolicyConfig The Execution policy configuration object type.
StreamConfig The individual Stream configuration object type.
DSConfig The DataSource configuration object type.
StreamState The type of state tracking object for the data format’s Stream.
StreamMetadata The type of the general metadata object for the data format’s Stream.
DataAccessPtn The type of the enumerator used to specify access patterns used for the format.
DataRequest The type of a request object used to query for data.
StepIdxType The type used to request a specific step from the Stream.

using IOPolicy = IO

Defined in src/lib/sbio/core/broker.hh:122

The type of the IO strategy being used.


using ExecutionPolicy = EPolicy

Defined in src/lib/sbio/core/broker.hh:126

The Execution policy type.


using DataFormat = FTraits

Defined in src/lib/sbio/core/broker.hh:130

The type of data being read.


using StreamType = Stream< IO, FTraits >

Defined in src/lib/sbio/core/broker.hh:135

The type of Stream: I.e., the IO strategy and data format being read.


using SBStorageType = Storage< typename FTraits::BrokerBufferRequirements, EPolicy >

Defined in src/lib/sbio/core/broker.hh:140

The type of the StreamBroker’s Storage.


using EPolicyConfig = typename EPolicy::Config

Defined in src/lib/sbio/core/broker.hh:149

The Execution policy configuration object type.

epolicy_config objects configure the global behaviour of the Execution policy being used. The Execution policy must be configured before any Streams are opened as it controls all aspects of IO down to the allocation of Storage.


using StreamConfig = typename FTraits::StreamParameters

Defined in src/lib/sbio/core/broker.hh:156

The individual Stream configuration object type.

stream_config objects are used to set up each individual Stream so that it can connect and read from its individual data.


using DSConfig = typename FTraits::DataSourceParameters

Defined in src/lib/sbio/core/broker.hh:163

The DataSource configuration object type.

ds_config objects are used for initial discovery and connection of the full set of Streams.


using StreamState = typename FTraits::DiscoveryState

Defined in src/lib/sbio/core/broker.hh:168

The type of state tracking object for the data format’s Stream.


using StreamMetadata = typename FTraits::MetadataInventory

Defined in src/lib/sbio/core/broker.hh:172

The type of the general metadata object for the data format’s Stream.


using DataAccessPtn = typename FTraits::DataAccessPtn

Defined in src/lib/sbio/core/broker.hh:177

The type of the enumerator used to specify access patterns used for the format.


using DataRequest = typename FTraits::DataRequest

Defined in src/lib/sbio/core/broker.hh:181

The type of a request object used to query for data.


using StepIdxType = typename FTraits::StepIdxType

Defined in src/lib/sbio/core/broker.hh:188

The type used to request a specific step from the Stream.

This type is required and guaranteed to be convertible std::size_t; however, different data format’s may use different underlying types.