Abstract Datasets
The concepts svs::data::ImmutableMemoryDataset
and svs::data::MemoryDataset
are used to encapsulate the expected behavior of classes implementing datasets.
These concepts are described below.
Concrete implementations of these concepts can be found here.
Main Concepts
This sub-section highlights the main exported concepts that are expected to be used by this logical grouping of code.
-
template<typename T>
concept ImmutableMemoryDataset - #include <svs/concepts/data.h>
Compatibility interface for methods working with datasets.
template <typename T> concept ImmutableMemoryDataset = HasValueType<T> && requires(const T a, size_t i) { // Return the number of valid entries in the dataset. { a.size() } -> std::convertible_to<size_t>; // @brief Return the number of dimensions for each entry in the dataset. // // **Note**: The existence of this method is targeted for deprecation. It assumes // that // all elements in the dataset have uniform dimensionality, which may not be // the case in future workloads. { a.dimensions() } -> std::convertible_to<size_t>; // Return a constant handl to the element at index ``i``. { a.get_datum(i) } -> std::same_as<const_value_type_t<T>>; // Performance optimization. Prefetch the data at index ``i``. // // This may be implemented as a no-op if it is too difficult for a particular // dataset instance. However, a correctly implemented ``prefetch`` can greatly // improve performance. a.prefetch(i); }
-
template<typename T>
concept MemoryDataset - #include <svs/concepts/data.h>
Compatibility interface for working with mutable datasets.
Mutable datasets aren’t required to be resizeable. Mutability here simply means “the
element values may change”.
template <typename T> concept MemoryDataset = ImmutableMemoryDataset<T> && requires(T a, size_t i, const_value_type_t<T> v) { // Return a (potentially) mutable handle to the entry at index ``i``. // // **Note**: This method is targeted for deprecation. This is because data-sets // may require more contextual information for writing or overwriting contents // and updating a mutable reference may not be sufficient. // // (From Mark): I don't **think** any functions in the library use this // particular method, instead opting to use the more power ``set_datum``. { a.get_datum(i) } -> std::same_as<value_type_t<T>>; // Overwrite the contents of the index ``i`` with ``v``. { a.set_datum(i, v) }; };
Public API
-
template<typename T>
concept HasValueType - #include <svs/concepts/data.h>
Require the type aliases
value_type
andconst_value_type
.The members and inline documentation are given in the code snippet below.
template<typename T> concept HasValueType = requires { // Require that ``T`` has the type alias ``T::value_type``. // // Note that the the alias does not necessarily need to be a "value_type" in the // sence of C++ value type. In other words, it can (and probably should be for // performance reasons be a reference). typename T::value_type; // Require that ``T`` has the type alias ``T::const_value_type``. // // Note that the the alias does not necessarily need to be a "value_type" in the // sence of C++ value type. In other words, it can (and probably should be for // performance reasons be a reference). typename T::const_value_type; };