Column Data¶
General description¶
Data packet of the column data type contains a generic nsamples-by-ncolumns array of data when each column as a label associated.
Warning
Breaking change in the 1.4 version of this datatype.
The data order has been switched from c1s1 c2s1 … cns1 c1s2 c2s2 … cns2 …… cnsn to s1c1 s2c1 … snc1 s1c2 s2c2 … snc2 …… sncn . If you were working with only the datatype API including the special iterator (channels and samples); the change is automatic.
Payload details¶
name |
type |
description |
|---|---|---|
labels |
vector of ncolumn strings |
a string name for each column |
signal |
vector of any datatype |
API¶
-
template<typename T>
class Data : public IData<Data<T>, ParentType> Public Types
-
using BaseClass = IData<Data<T>, ParentType>
-
typedef stride_iter<T*> sample_iterator
-
typedef T *column_iterator
Public Functions
-
inline Data(const std::vector<std::string> &labels, size_t nsamples, bool resizable = false)
Data constructor with the labels for each column and the number of samples.
- Parameters
labels – give a label for each column
nsamples – give the number of samples
-
inline Data(const Parameters ¶meters)
Data constructor from the parameters object.
- Parameters
parameters –
-
inline void ClearData() override
ClearData - clear the data.
-
inline Parameters parameters() const
-
inline size_t ncolumns() const
-
inline size_t nsamples() const
-
inline bool resizable() const
-
inline std::vector<std::string> labels() const
-
inline void set_nsamples(size_t nsamples)
-
inline void set_data_column(std::string column, const std::vector<T> &data)
set_data_column set all samples for one column based on the name of the column
- Parameters
column – - selected column name
data – - vector containing data for all samples
-
inline void set_data_column(size_t column, const std::vector<T> &data)
set_data_column set all samples for one column based on the column index
- Parameters
column – - selected column index
data – - vector containing data for all samples
-
inline void set_data_sample(size_t sample, const std::vector<T> &data)
set_data_sample set column data for one sample
- Parameters
sample – - selected sample index
data – - vector containing data for all columns
-
inline void set_data_sample(size_t sample, size_t column, T data)
set_data_sample set one data for one column index and one sample index
- Parameters
sample – - selected sample index
column – - selected column index
data –
-
inline void set_data_sample(size_t sample, std::string column, T data)
set_data_sample set one data for one column label and one sample index
- Parameters
sample – - selected sample index
column – - selected column label
data –
-
inline void clone_column(std::string column, Data &data_in)
clone_column clone a column from another dataset
- Parameters
column – - label of the selected column to clone
data_in – - data packet to clone
-
inline void clone_column(size_t column_in, size_t column_out, Data &data_in)
clone_column clone a columnfrom another dataset
- Parameters
column – - index of the selected column to clone
data_in – - data packet to clone
-
inline void set_data(std::vector<T> data)
set_data set data for all columns and all labels
- Parameters
data –
-
inline std::vector<T> &data()
data - return full data with this format [s1c1, s1c2.., s1cn, s2c1, s2c2 …, snc1,…sncn]
- Returns
-
inline const std::vector<T> &data() const
-
inline const T &data_sample(size_t sample, size_t column = 0) const
data_sample - return the data for one sample index and one column index
- Parameters
sample – - selected sample index
column – - selected column index
- Returns
-
inline const T &data_sample(size_t sample, std::string column) const
data_sample - return the data for one sample index and one column label
- Parameters
sample – - selected sample index
column – - selected column label
- Returns
-
inline T &operator()(size_t sample, size_t column = 0)
-
inline const T &operator()(size_t sample, size_t column = 0) const
-
inline T &operator()(size_t sample, std::string column)
-
inline const T &operator()(size_t sample, std::string column) const
-
inline T &operator()(size_t index)
-
inline const T &operator()(size_t index) const
-
inline T *begin_column(size_t column)
begin_sample iterator at the start of a sample index
- Parameters
sample –
- Returns
-
inline T *end_column(size_t column)
end_sample iterator at the end of a sample index
- Parameters
sample –
- Returns
-
inline const T *begin_column(size_t column) const
-
inline const T *end_column(size_t column) const
-
inline stride_iter<T*> begin_sample(size_t sample)
begin_column iterator at the start of the column based on the location in the dataset
- Parameters
column – - column index
- Returns
-
inline stride_iter<T*> end_sample(size_t sample)
end_column - iterator at the end of the column based on the location in the dataset
- Parameters
column – - column index
- Returns
-
inline stride_iter<const T*> begin_sample(size_t sample) const
begin_column iterator at the start of the column based on the location in the dataset
- Parameters
column – - column index
- Returns
-
inline stride_iter<const T*> end_sample(size_t sample) const
end_column - iterator at the end of the column based on the location in the dataset
- Parameters
column – - column index
- Returns
-
inline T *begin_column(std::string column)
begin_column - iterator at the start of the column based on name of the column
- Parameters
column – - column label
- Returns
-
inline T *end_column(std::string column)
end_column - iterator at the end of the column based on name of the column
- Parameters
column – - column label
- Returns
-
inline void SerializeBinary(std::ostream &stream, Serialization::Format format = Serialization::Format::FULL) const override
SerializeBinary - add to the binary stream the data [columnxsample].
- Parameters
stream –
format –
-
inline void SerializeFlatBuffer(flexbuffers::Builder &flex_builder) override
SerializeFlatBuffer - add to the flexbuffer the data labeled [label0:nsamples, label1:nsamples…], the number of columns and the number of samples.
- Parameters
flex_builder –
-
inline void SerializeYAML(YAML::Node &node, Serialization::Format format = Serialization::Format::FULL) const override
SerializeYAML - add to the yaml node the data [columnxsample].
- Parameters
node –
format –
-
inline void YAMLDescription(YAML::Node &node, Serialization::Format format = Serialization::Format::FULL) const override
YAMLDescription - this datatype add to the metadata describing the data format the signal, number of columns and samples format.
- Parameters
format –
-
inline T sum_column(std::string column, bool absolute = false) const
sum_column - compute the (absolute) sum of all samples in the same column
- Parameters
column – - column label
absolute – - absolute sum or not
- Returns
(absolute) sum
-
inline T sum_column(size_t column, bool absolute = false) const
sum_column - compute the (absolute) sum of all samples in the same column
- Parameters
column – - column index
absolute – - absolute sum or not
- Returns
(absolute) sum
-
inline T mean_column(std::string column, bool absolute = false) const
mean_column - compute the mean of the (absolute) sum of all samples in the same column
- Parameters
column – - column label
absolute – - absolute sum or not
- Returns
mean of the (absolute) sum
-
inline T mean_column(size_t column, bool absolute = false) const
mean_column - compute the mean of the (absolute) sum of all samples in the same column
- Parameters
column – - column index
absolute – - absolute sum or not
- Returns
mean of the (absolute) sum
-
inline T sum_sample(size_t sample, bool absolute = false) const
sum_sample - compute the (absolute) sum of all column data for the same sample index
- Parameters
sample – - sample index
absolute – - absolute sum or not
- Returns
(absolute) sum
-
inline T mean_sample(size_t sample, bool absolute = false) const
mean_sample - compute the mean of the (absolute) sum of all column data for the same sample index
- Parameters
sample – - sample index
absolute – - absolute sum or not
- Returns
the mean of the (absolute) sum
Public Static Functions
-
static inline const std::string static_datatype()
-
static inline const std::string static_dataname()
-
using BaseClass = IData<Data<T>, ParentType>
Parameters¶
name |
type |
description |
validation |
|---|---|---|---|
nsample |
unsigned int |
0 |
Number of samples cannot be zero and needs to be in range |
nchannels |
unsigned int |
0 |
Number of channels cannot be zero and needs to be in range |
sample_rate |
double |
1.0 |
Sample rate needs to be larger than 0 |
-
struct Parameters
Subclassed by nsTimeSeries::Parameters
Public Functions
-
inline Parameters(const std::vector<std::string> &labels, size_t nsamp = 0, bool resizable = false)
Public Members
-
size_t ncolumns
-
size_t nsamples
-
std::vector<std::string> labels
-
bool resizable
-
inline Parameters(const std::vector<std::string> &labels, size_t nsamp = 0, bool resizable = false)
Capabilities¶
name |
type |
default |
description |
|---|---|---|---|
column range |
ChannelRange or Range<unsigned int> |
(none) |
the number of channels that is supported |
sample range |
SampleRange or Range<size_t> |
[1, (maximum of the datatype can hold)] |
the number of samples that is supported |
OR
name |
type |
default |
description |
|---|---|---|---|
labels |
vector of string |
(none) |
name of all channels supported in input |
sample range |
SampleRange or Range<size_t> |
[1, (maximum of the datatype can hold)] |
the number of samples that is supported |
-
class Capabilities
Public Functions
-
inline Capabilities(ChannelRange column_range, SampleRange sample_range = SampleRange(0, std::numeric_limits<uint32_t>::max()), bool resizable = false)
-
inline Capabilities(std::vector<std::string> labels, SampleRange sample_range = SampleRange(1, std::numeric_limits<uint32_t>::max()), bool resizable = false)
-
inline ChannelRange column_range() const
-
inline SampleRange sample_range() const
-
inline Capabilities(ChannelRange column_range, SampleRange sample_range = SampleRange(0, std::numeric_limits<uint32_t>::max()), bool resizable = false)
Binary Serialization¶
For serialization formats FULL and COMPACT, The timestamps and the data are serialized.
YAML Serialization¶
For serialization formats FULL and COMPACT,
the following YAML is emitted:
label: [label] signal: [data]