Tables
Type | Description |
---|---|
A common implementation of the table concept. Base class for
other table types. | |
An implementation of dm table metadata concept. | |
An enumeration of data layouts used to store
contiguous data blocks inside the table. | |
An enumeration of feature types used in oneDAL to
define set of available operations onto the data. |
Requirements on table types
- Follows the definition of the dm table concept and its restrictions (e.g., immutability).
- Is derived from theoneapi::dal::tableclass. The behavior of this class can be extended, but cannot be weaken.
- Every newoneapi::dal::tablesub-type defines a unique id number - the “kind” that represents objects of that type in runtime.
using namespace onedal;
// Creating homogen_table sub-type.
dal::homogen_table table1 = homogen_table::wrap(queue, data_ptr, row_count, column_count);
// table1 and table2 share the same data (no data copy is performed)
dal::table table2 = table1;
// Creating an empty table
dal::table table3;
std::cout << table1.get_kind() == table2.get_kind() << std::endl; // true
std::cout << homogen_table::kind() == table2.get_kind() << std::endl; // true
std::cout << table2.get_kind() == table3.get_kind() << std::endl; // false
// Referring table3 to the table2.
table3 = table2;
std::cout << table2.get_kind() == table3.get_kind() << std::endl; // true
Table types
Table type | Description |
---|---|
A dense table that contains contiguoushomogeneous data. |
Programming interface
- The instance stores a pointer to table implementation that holds all property values and data
- The reference count indicating how many table objects refer to the same implementation.
- The table increments the reference count for it to be equal to the number of table objects sharing the same implementation.
- The table decrements the reference count when the table goes out of the scope. If the reference count is zero, the table frees its implementation.
- classtable
- Constructors
- table()
- An empty table constructor: creates the table instance with zero number of rows and columns. Implementation is set to the special “empty” object that returns all the property values set to default (see Properties section).
- Creates a new table instance that shares the implementation with another one.
- table(table&&)
- Creates a new table instance and moves implementation from another one into it.
Public Methods- boolhas_data()constnoexcept
- Indicates whether a table contains non-zero number of rows and columns.
Properties- std::int64_tcolumn_count= 0
- The number of columns in the table.
- Getter & Setter
std::int64_t get_column_count() const
- std::int64_trow_count= 0
- The number of rows in the table.
- Getter & Setter
std::int64_t get_row_count() const
- consttable_metadata &metadata= table_metadata()
- The metadata object that holds additional information about the data within the table.
- Getter & Setter
const table_metadata & get_metadata() const
- std::int64_tkind= empty_table_kind
- The runtime id of the table type. Each table sub-type has its uniquekind. An empty table (see the default constructor) has a uniquekindvalue as well.
- Getter & Setter
std::int64_t get_kind() const
- The layout of the data within the table.
- Getter & Setter
data_layout get_data_layout() const
- classtable_metadata
- Constructors
- table_metadata()
- Creates the metadata instance without information about the features. Thefeature_countsshould be set to zero. Thedata_typeandfeature_typeproperties should not be initialized.
- Creates the metadata instance from external information about the data types and the feature types.
- Parameters
- dtypes– The data types of the features. Assigned into thedata_typeproperty.
- ftypes– The feature types. Assigned into thefeature_typeproperty.
- Preconditions
dtypes.get_count() == ftypes.get_count()
Properties- std::int64_tfeature_count
- The number of features that metadata contains information about.
- Getter & Setter
std::int64_t get_feature_count() const
- Feature types in the metadata object. Should be within the range[0, feature_count).
- Getter & Setter
const feature_type & get_feature_type(std::int64_t feature_index) const
- Data types of the features in the metadata object. Should be within the range[0, feature_count).
- Getter & Setter
const data_type & get_data_type(std::int64_t feature_index) const
enum class data_layout { unknown, row_major, column_major };
data_layout::unknown
Represents the :capterm:`data layout` that is undefined or unknown at this moment.
data_layout::row_major
The data block elements are stored in raw-major layout.
data_layout::column_major
The data block elements are stored in column_major layout.
enum class feature_type { nominal, ordinal, interval, ratio };
feature_type::nominal
Represents the type of :capterm:`Nominal feature`.
feature_type::ordinal
Represents the type of :capterm:`Ordinal feature`.
feature_type::interval
Represents the type of :capterm:`Interval feature`.
feature_type::ratio
Represents the type of :capterm:`Ratio feature`.