Skip to content

DataSource

#include <sbio/core/datasource.hh>
template<IOTraits IO, class EPolicy, FormatTraits< IO, EPolicy > FTraits, IsStreamBroker BrokerType = StreamBroker<IO, EPolicy, FTraits>, std::size_t MaxDataStreams = 128>
class DataSource

Defined in src/lib/sbio/core/datasource.hh:90

The highest-level abstraction for defining the set of StreamBrokers that will be used.

The DataSource is used to find and collect together the group of all StreamBrokers that will be relevant for the IO of a specific dataset. The DataSource can be used to spawn BrokerGroups to organize the StreamBrokers into logical groupings, and can be used to generate indices to distribute among said groups to order the way in which data is fetched and queried.

  • IO The type of the IO strategy being used.

  • EPolicy The Execution policy to use for reading data.

  • FTraits The data format to read.

  • BrokerType The type of the StreamBroker being used. In general, the StreamBroker does not need to be subclassed, and can be instantiated directly. In that case, this template parameter can be left on its default value. Only if using a StreamBroker subclass does it need to be changed.

Name Description
SourceSet A SourceSet drives the reindexing of the DataSources it iterates.

template<class... Sources> friend class SourceSet

Defined in src/lib/sbio/core/datasource.hh:157

A SourceSet drives the reindexing of the DataSources it iterates.

Reindexing is private - it was easiest to let the SourceSet be a friend.

Return Name Description
DataSource Defaulted constructor.
DataSource inline explicit Construct a DataSource, with the execution policy already configured.
DataSource inline explicit Construct a DataSource and initialize the Execution policy.
void configure_execution_policy inline Configure the Execution policy.
SBIO_HD bool add_data_stream inline Add a new StreamBroker to the set tracked by the DataSource.
bool load_source inline
bool load_source_with inline
SBIO_HDIOStatus discover_metadata inline After finding StreamBrokers and opening connections, determine available metadata.
SBIO_HD FTraits::StepIdxType next const inline Request the next index for a step to read data for.
SBIO_HDStepBatch< typename FTraits::StepIdxType > next_batch const inline Request the next contiguous batch of indices for steps to read data for.
SBIO_HDBrokerGroup< BrokerType, FTraits, MaxSegments > get_stream_group inline Construct a BrokerGroup by name from the set of StreamBrokers.
SBIO_HD std::size_t num_data_streams const inline The number of data Streams in the DataSource’s set.
SBIO_HD const BrokerType * data_streams const inline A pointer to the first StreamBroker of the set.
SBIO_HD BrokerType * data_streams inline A pointer to the first StreamBroker of the set.
SBIO_HD const BrokerType & data_stream const inline The requested StreamBroker.
SBIO_HD BrokerType & data_stream inline The requested StreamBroker.
SBIO_HDStepRange steps inline Return a range over the steps of this DataSource for the calling unit.
SBIO_HDConstStepRange steps const inline
SBIO_HDConstStepRange csteps const inline
SBIO_HDIterator begin inline Return an iterator at the first step index.
SBIO_HDConstIterator begin const inline
SBIO_HDIterator end inline Return an iterator pointing to the ExhasutedSentinel.
SBIO_HDConstIterator end const inline
SBIO_HDConstIterator cbegin const inline
SBIO_HDConstIterator cend const inline
SBIO_HDBatchRange batches inline Return a range over contiguous batches of steps for the calling unit.
SBIO_HDConstBatchRange batches const inline
SBIO_HDConstBatchRange cbatches const inline

DataSource() = default

Defined in src/lib/sbio/core/datasource.hh:159

Defaulted constructor.


inline explicit

inline explicit DataSource(ExecutionPolicyConfigured)

Defined in src/lib/sbio/core/datasource.hh:167

Construct a DataSource, with the execution policy already configured.


inline explicit

inline explicit DataSource(const EPolicyConfig & ecfg)

Defined in src/lib/sbio/core/datasource.hh:176

Construct a DataSource and initialize the Execution policy.

Parameter Type Description
ecfg const EPolicyConfig & The configuration for the Execution policy.

inline

inline void configure_execution_policy(const EPolicyConfig & ecfg)

Defined in src/lib/sbio/core/datasource.hh:189

Configure the Execution policy.

The Execution policy must be configured before Streams are opened and read from as the policy controls the allocation of the buffers that will be read into.

Parameter Type Description
ecfg const EPolicyConfig & The configuration for the Execution policy.

inline

inline SBIO_HD bool add_data_stream(const GenericStreamConfig< DataFormat > & cfg)

Defined in src/lib/sbio/core/datasource.hh:204

Add a new StreamBroker to the set tracked by the DataSource.

Whether the incorporation of the StreamBroker, and subsequent configuration was successful.

Parameter Type Description
cfg const GenericStreamConfig< DataFormat > & The base configuration for the StreamBroker’s Stream(s). This configuration may be modified slightly for the parameters that are required by the Stream, but do not make sense to be set directly by the user.

inline

template<typename... Args> inline bool load_source(const StreamConfig & cfg, Args &&... args)

Defined in src/lib/sbio/core/datasource.hh:216


inline

template<IsLocator< DataSource > Locator, typename... Args> inline bool load_source_with(const StreamConfig & cfg, Args &&... args)

Defined in src/lib/sbio/core/datasource.hh:225


inline

inline SBIO_HDIOStatus discover_metadata()

Defined in src/lib/sbio/core/datasource.hh:241

After finding StreamBrokers and opening connections, determine available metadata.

The metadata discovery stage is crucial to be able to organize StreamBrokers into their logical BrokerGroups. The metadata informs the rest of the infrastructure what kind of data is available in the set of Streams beign read from.

The IOStatus result from performing metadata discovery.


const inline

inline SBIO_HD FTraits::StepIdxType next() const

Defined in src/lib/sbio/core/datasource.hh:287

Request the next index for a step to read data for.

The step indices are used to request data for a specific step/event. In general, this corresponds to chronological ordering (i.e. a step is mappable to a time point); however, this is by no means a requirement.

The next step index to fetch and query data for, or the ExhaustedSentinel if no more data is available.


const inline

inline SBIO_HDStepBatch< typename FTraits::StepIdxType > next_batch(std::size_t batch_size = 0) const

Defined in src/lib/sbio/core/datasource.hh:311

Request the next contiguous batch of indices for steps to read data for.

The next batch of step indices [first, last) to fetch data for. The Exhausted batch is returned as first and last equal to ExhaustedSentinel

Parameter Type Description
batch_size std::size_t The maximum size of the batch of step indices to read.

inline

template<std::size_t MaxSegments = 128> inline SBIO_HDBrokerGroup< BrokerType, FTraits, MaxSegments > get_stream_group(const char * name)

Defined in src/lib/sbio/core/datasource.hh:338

Construct a BrokerGroup by name from the set of StreamBrokers.

The BrokerGroup of the given name. The success of the group formation can be checked by inspecting the number of segments the returned group has (0 indicating no group could be formed).


const inline

inline SBIO_HD std::size_t num_data_streams() const

Defined in src/lib/sbio/core/datasource.hh:350

The number of data Streams in the DataSource’s set.


const inline

inline SBIO_HD const BrokerType * data_streams() const

Defined in src/lib/sbio/core/datasource.hh:357

A pointer to the first StreamBroker of the set.

A pointer to the first StreamBroker of the set.


inline

inline SBIO_HD BrokerType * data_streams()

Defined in src/lib/sbio/core/datasource.hh:363

A pointer to the first StreamBroker of the set.

A pointer to the first StreamBroker of the set.


const inline

inline SBIO_HD const BrokerType & data_stream(std::size_t i) const

Defined in src/lib/sbio/core/datasource.hh:373

The requested StreamBroker.

The requested StreamBroker.

Parameter Type Description
i std::size_t The StreamBroker to return.

inline

inline SBIO_HD BrokerType & data_stream(std::size_t i)

Defined in src/lib/sbio/core/datasource.hh:383

The requested StreamBroker.

The requested StreamBroker.

Parameter Type Description
i std::size_t The StreamBroker to return.

inline

inline SBIO_HDStepRange steps()

Defined in src/lib/sbio/core/datasource.hh:506

Return a range over the steps of this DataSource for the calling unit.

A range to iterate over in a range-based for loop.


const inline

inline SBIO_HDConstStepRange steps() const

Defined in src/lib/sbio/core/datasource.hh:507


const inline

inline SBIO_HDConstStepRange csteps() const

Defined in src/lib/sbio/core/datasource.hh:508


inline

inline SBIO_HDIterator begin()

Defined in src/lib/sbio/core/datasource.hh:520

Return an iterator at the first step index.

An iterator at the first step index.


const inline

inline SBIO_HDConstIterator begin() const

Defined in src/lib/sbio/core/datasource.hh:521


inline

inline SBIO_HDIterator end()

Defined in src/lib/sbio/core/datasource.hh:527

Return an iterator pointing to the ExhasutedSentinel.

An iterator pointing to the ExhaustedSentinel.


const inline

inline SBIO_HDConstIterator end() const

Defined in src/lib/sbio/core/datasource.hh:528


const inline

inline SBIO_HDConstIterator cbegin() const

Defined in src/lib/sbio/core/datasource.hh:530


const inline

inline SBIO_HDConstIterator cend() const

Defined in src/lib/sbio/core/datasource.hh:531


inline

inline SBIO_HDBatchRange batches(std::size_t batch_size = 0)

Defined in src/lib/sbio/core/datasource.hh:644

Return a range over contiguous batches of steps for the calling unit.

A range to iterate over in a range-based for loop.

Parameter Type Description
batch_size std::size_t The maximum number of steps per batch. The default is the configured max_batch_size.

const inline

inline SBIO_HDConstBatchRange batches(std::size_t batch_size = 0) const

Defined in src/lib/sbio/core/datasource.hh:647


const inline

inline SBIO_HDConstBatchRange cbatches(std::size_t batch_size = 0) const

Defined in src/lib/sbio/core/datasource.hh:650

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.
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.
Iterator
ConstIterator
StepRange
ConstStepRange
BatchIterator
ConstBatchIterator
BatchRange
ConstBatchRange

using IOPolicy = IO

Defined in src/lib/sbio/core/datasource.hh:95

The type of the IO strategy being used.


using ExecutionPolicy = EPolicy

Defined in src/lib/sbio/core/datasource.hh:99

The Execution policy type.


using DataFormat = FTraits

Defined in src/lib/sbio/core/datasource.hh:103

The type of data being read.


using StreamType = Stream< IO, FTraits >

Type: Stream< IO, FTraits >

Defined in src/lib/sbio/core/datasource.hh:108

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


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

Type: Storage< typename FTraits::BrokerBufferRequirements, EPolicy >

Defined in src/lib/sbio/core/datasource.hh:113

The type of the StreamBroker’s Storage.


using EPolicyConfig = typename EPolicy::Config

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

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 = GenericStreamConfig< FTraits >

Type: GenericStreamConfig< FTraits >

Defined in src/lib/sbio/core/datasource.hh:129

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 StreamMetadata = MetadataInventory< FTraits >

Type: MetadataInventory< FTraits >

Defined in src/lib/sbio/core/datasource.hh:134

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


using DataAccessPtn = typename FTraits::DataAccessPtn

Defined in src/lib/sbio/core/datasource.hh:139

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/datasource.hh:143

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


using StepIdxType = typename FTraits::StepIdxType

Defined in src/lib/sbio/core/datasource.hh:150

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.


using Iterator = IteratorImpl< DataSource >

Type: IteratorImpl< DataSource >

Defined in src/lib/sbio/core/datasource.hh:444


using ConstIterator = IteratorImpl< const DataSource >

Type: IteratorImpl< const DataSource >

Defined in src/lib/sbio/core/datasource.hh:445


using StepRange = StepRangeImpl< DataSource >

Type: StepRangeImpl< DataSource >

Defined in src/lib/sbio/core/datasource.hh:498


using ConstStepRange = StepRangeImpl< const DataSource >

Type: StepRangeImpl< const DataSource >

Defined in src/lib/sbio/core/datasource.hh:499


using BatchIterator = BatchIteratorImpl< DataSource >

Type: BatchIteratorImpl< DataSource >

Defined in src/lib/sbio/core/datasource.hh:578


using ConstBatchIterator = BatchIteratorImpl< const DataSource >

Type: BatchIteratorImpl< const DataSource >

Defined in src/lib/sbio/core/datasource.hh:579


using BatchRange = BatchRangeImpl< DataSource >

Type: BatchRangeImpl< DataSource >

Defined in src/lib/sbio/core/datasource.hh:634


using ConstBatchRange = BatchRangeImpl< const DataSource >

Type: BatchRangeImpl< const DataSource >

Defined in src/lib/sbio/core/datasource.hh:635

Return Name Description
BrokerType m_data_streams The set of StreamBrokers in the DataSource
std::size_t m_num_data_streams The total number of StreamBrokers in the DataSource
std::size_t m_steps_capacity The current steps capacity before reindexing is required.
EPolicy::IterationState m_iteration_state The EPolicy’s state for iterating and distribution steps from this DataSource.
bool m_epolicy_configured Flag to track whether the Execution policy has been configured.

BrokerType m_data_streams[MaxDataStreams]

Defined in src/lib/sbio/core/datasource.hh:692

The set of StreamBrokers in the DataSource


std::size_t m_num_data_streams { 0 }

Defined in src/lib/sbio/core/datasource.hh:697

The total number of StreamBrokers in the DataSource


std::size_t m_steps_capacity { 0 }

Defined in src/lib/sbio/core/datasource.hh:702

The current steps capacity before reindexing is required.


EPolicy::IterationState m_iteration_state {}

Defined in src/lib/sbio/core/datasource.hh:707

The EPolicy’s state for iterating and distribution steps from this DataSource.


bool m_epolicy_configured { false }

Defined in src/lib/sbio/core/datasource.hh:719

Flag to track whether the Execution policy has been configured.

Since there may be global state in the policy, ensure that a configuration gets called. If its explicitly provided, then that gets used. Otherwise, a default configuration will be invoked before any IO. This allows any global state to be reset if iteratively creating multiple DataSource instantiations over time. This only applies to static state (generally, process and environment). The remaining state is held in the member m_iteration_state.

Return Name Description
SBIO_HD bool reindex_trigger const inline

const inline

inline SBIO_HD bool reindex_trigger() const

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