51#ifndef GUM_DATABASE_TABLE_H
52#define GUM_DATABASE_TABLE_H
203 template <
typename TX_DATA >
207 template <
typename TX_DATA >
211 template <
typename TX_DATA >
212 using Matrix = std::vector< DBRow< TX_DATA > >;
299 const std::size_t input_column,
300 const bool unique_column =
true);
324 const std::size_t input_column,
325 const bool unique_column =
true);
345 std::size_t input_column,
346 const std::vector< std::string >& missing_symbols,
347 bool unique_column =
true);
402 bool k_is_input_col =
false,
403 const std::vector< std::string >& missing_symbols
404 = std::vector< std::string >(),
405 bool editable_dictionary =
false,
406 std::size_t max_dico_entries = std::numeric_limits< std::size_t >::max())
480 const bool from_external_object =
true)
override;
514 void ignoreColumn(
const std::size_t k,
const bool from_external_object =
true)
override;
539 std::size_t
domainSize(
const std::size_t k,
const bool k_is_input_col =
false)
const;
597 void reorder(
const std::size_t k,
const bool k_is_input_col =
false);
633 void insertRow(
const std::vector< std::string >& new_row)
override;
646 const IsMissing contains_missing_data)
override;
659 const IsMissing contains_missing_data)
override;
738#ifndef DOXYGEN_SHOULD_SKIP_THIS
756 std::size_t _getKthIndex_(
const std::size_t k,
const bool k_is_input_col)
const;
785 template <
typename Functor1,
typename Functor2 >
786 void _threadProcessDatabase_(Functor1& exec_func, Functor2& undo_func);
A class for storing several translators.
The common class for the tabular database tables.
Base class for every random variable.
the class for packing together the translators used to preprocess the datasets
The base class for all the tabular database cell translators.
bool needsReordering(const std::size_t k, const bool k_is_input_col=false) const
indicates whether a reordering is needed to sort the translations of the kth translator or those of t...
void changeTranslator(DBTranslator &new_translator, std::size_t k, bool k_is_input_col=false)
change the translator of a database column
void insertRow(Row< DBTranslatedValue > &&new_row, const IsMissing contains_missing_data) override
insert a new DBRow at the end of the database
DBVector< std::size_t > domainSizes() const
returns the domain sizes of all the variables in the database table
DatabaseTable(const MissingValType &missing_symbols, const DBTranslatorSet &translators=DBTranslatorSet())
default constructor
typename IDatabaseTable< DBTranslatedValue >::Handler Handler
the unsafe handler type
typename IDatabaseTable< DBTranslatedValue >::IsMissing IsMissing
void setVariableNames(const std::vector< std::string > &names, const bool from_external_object=true) override
sets the names of the variables
void reorder()
performs a reordering of all the columns
std::size_t size_type
Types for STL compliance.
const value_type * const_pointer
Types for STL compliance.
DatabaseTable(const DatabaseTable &from)
copy constructor
std::ptrdiff_t difference_type
Types for STL compliance.
Handler iterator
Types for STL compliance.
const value_type & const_reference
Types for STL compliance.
void insertRow(const Row< DBCell > &new_row) override
insert a new DBRow of DBCells at the end of the database
void insertRows(const Matrix< DBCell > &new_rows) override
insert a set of new DBRows at the end of the database
DatabaseTable(DatabaseTable &&from) noexcept
move constructor
DatabaseTable & operator=(const DatabaseTable &from)
copy operator
DatabaseTable(const DBTranslatorSet &translators=DBTranslatorSet())
default constructor
std::size_t insertTranslator(const DBTranslator &translator, const std::size_t input_column, const bool unique_column=true)
insert a new translator into the database table
void ignoreColumn(const std::size_t k, const bool from_external_object=true) override
makes the database table ignore from now on the kth column of the input dataset or the column parsed ...
auto changeTranslator(const Variable &var, std::size_t k, bool k_is_input_col=false, const std::vector< std::string > &missing_symbols=std::vector< std::string >(), bool editable_dictionary=false, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max()) -> void
change the translator of a database column
~DatabaseTable() override
destructor
void eraseTranslators(std::size_t k, bool k_is_input_col=false)
erases either the kth translator or all those parsing the kth column of the input dataset
HandlerSafe iterator_safe
Types for STL compliance.
const DBVector< std::size_t > inputColumns() const override
returns the set of columns of the original dataset that are present in the DatabaseTable
std::vector< TX_DATA > DBVector
the type for the vectors used in the DatabaseTable
const DBVector< std::size_t > ignoredColumns() const override
returns the set of columns of the original dataset that are ignored
void insertRow(const Row< DBTranslatedValue > &new_row, const IsMissing contains_missing_data) override
insert a new row at the end of the database
value_type * pointer
Types for STL compliance.
DBRow< TX_DATA > Row
a row of the database
void insertRows(const Matrix< DBTranslatedValue > &new_rows, const DBVector< IsMissing > &rows_have_missing_vals) override
insert a set of new DBRows at the end of the database
std::vector< DBRow< TX_DATA > > Matrix
the type for the matrices stored into the database
void insertRow(Row< DBCell > &&new_row) override
insert a new DBRow of DBCells at the end of the database
void insertRows(Matrix< DBCell > &&new_rows) override
insert a set of new DBRows at the end of the database
void insertRows(Matrix< DBTranslatedValue > &&new_rows, const DBVector< IsMissing > &rows_have_missing_vals) override
insert a set of new DBRows at the end of the database
void reorder(const std::size_t k, const bool k_is_input_col=false)
performs a reordering of the kth translator or of the first translator parsing the kth column of the ...
const DBTranslator & translator(const std::size_t k, const bool k_is_input_col=false) const
returns either the kth translator of the database table or the first one reading the kth column of th...
DatabaseTable & operator=(DatabaseTable &&from) noexcept
move constructor
std::size_t domainSize(const std::size_t k, const bool k_is_input_col=false) const
returns the domain size of the kth variable of the database table or of that of the first one corresp...
DatabaseTable * clone() const override
virtual copy constructor
const Variable & variable(const std::size_t k, const bool k_is_input_col=false) const
returns either the kth variable of the database table or the first one corresponding to the kth colum...
Row< DBTranslatedValue > value_type
Types for STL compliance.
typename IDatabaseTable< DBTranslatedValue >::HandlerSafe HandlerSafe
the safe handler type
std::size_t insertTranslator(const Variable &var, std::size_t input_column, const std::vector< std::string > &missing_symbols, bool unique_column=true)
insert a new translator into the database table
std::size_t insertTranslator(const Variable &var, const std::size_t input_column, const bool unique_column=true)
insert a new translator into the database table
void clear() override
erase the content of the database, including the names of the variables
value_type & reference
Types for STL compliance.
std::vector< std::string > MissingValType
void insertRow(const std::vector< std::string > &new_row) override
insert a new row at the end of the database
std::vector< std::pair< Idx, std::shared_ptr< DBTranslator > > > betterTranslators() const
propose a set with translators better suited for the content of the database
const DBTranslatorSet & translatorSet() const
returns the set of translators
the safe handler of the tabular databases
the (unsafe) handler for the tabular databases
IDatabaseTable(const MissingValType &missing_symbols, const std::vector< std::string > &var_names)
The implementation of tabular databases stored in memory (RAM).
include the inlined functions if necessary
The union class for storing the translated values in learning databases.