50#ifndef GUM_IDATABASE_TABLE_H
51#define GUM_IDATABASE_TABLE_H
73 template <
bool ENABLE_INSERT >
78 template <
typename TX_DATA >
81 template <
typename TX_DATA >
84 template <
typename TX_DATA >
85 using Matrix = std::vector< DBRow< TX_DATA > >;
111 virtual void insertRow(
const std::vector< std::string >& new_row) = 0;
121 template <
typename TX_DATA >
124 template <
typename TX_DATA >
127 template <
typename TX_DATA >
128 using Matrix = std::vector< DBRow< TX_DATA > >;
133 virtual void insertRow(
const std::vector< std::string >& new_row) = 0;
267 template <
typename T_DATA >
272 template <
typename TX_DATA >
276 template <
typename TX_DATA >
280 template <
typename TX_DATA >
281 using Matrix = std::vector< DBRow< TX_DATA > >;
391 template <
typename TX_DATA >
394 template <
typename TX_DATA >
397 template <
typename TX_DATA >
398 using Matrix = std::vector< DBRow< TX_DATA > >;
577#ifndef DOXYGEN_SHOULD_SKIP_THIS
586 const Matrix< T_DATA >* _row_;
589 std::size_t _index_{std::size_t(0)};
592 std::size_t _begin_index_{std::size_t(0)};
595 std::size_t _end_index_{std::size_t(0)};
747#ifndef DOXYGEN_SHOULD_SKIP_THIS
751 void _attachHandler_();
754 void _detachHandler_();
784 const std::vector< std::string >& var_names);
866 const
bool from_external_object = true)
930 virtual
void ignoreColumn(const
std::
size_t k, const
bool from_external_object = true) = 0;
1117 std::vector< std::pair< std::size_t, std::size_t > >
1127#ifndef DOXYGEN_SHOULD_SKIP_THIS
1135 mutable std::mutex _safe_handlers_mutex_;
1150 void _updateHandlers_(std::size_t new_size)
const;
1153 void _createEndIterators_();
The class representing the original values of the cells of databases.
The base class for all database handlers.
The base class for all the tabular databases' cell translators.
The implementation of the common class for tabular databases.
The class representing the original values of the cells of databases.
The base class for all database handlers.
DBRow< T_DATA > value_type
Types for STL compliance.
the safe handler of the tabular databases
std::ptrdiff_t difference_type
Types for STL compliance.
virtual HandlerSafe & operator=(HandlerSafe &&)
move operator
value_type * pointer
Types for STL compliance.
HandlerSafe(const IDatabaseTable< T_DATA > &db)
default constructor
virtual HandlerSafe & operator=(const Handler &)
copy operator
virtual HandlerSafe & operator=(const HandlerSafe &)
copy operator
const value_type * const_pointer
Types for STL compliance.
virtual HandlerSafe & operator=(Handler &&)
move operator
std::random_access_iterator_tag iterator_category
Types for STL compliance.
value_type & reference
Types for STL compliance.
virtual ~HandlerSafe()
destructor
HandlerSafe(HandlerSafe &&h)
move constructor
const value_type & const_reference
Types for STL compliance.
HandlerSafe(const HandlerSafe &h)
copy constructor
typename Handler::value_type value_type
Types for STL compliance.
the (unsafe) handler for the tabular databases
virtual Handler & operator++() final
makes the operator point to the next row in the database
const value_type * const_pointer
Types for STL compliance.
virtual const DBVector< std::string > & variableNames() const final
returns the names of the variables
virtual Handler begin() const
returns a new handler that points to the beginning of the database's area of the current handler
Handler(const IDatabaseTable< T_DATA > &db)
default constructor
const value_type & const_reference
Types for STL compliance.
value_type & reference
Types for STL compliance.
virtual void setRange(std::size_t first, std::size_t last) final
sets the area in the database the handler will handle
virtual bool hasRows() const final
indicates whether the handler has reached its end or not
virtual Handler end() const
returns a new handler that points to the end of the database's area of the current handler
virtual Handler & operator=(Handler &&)
move operator
virtual std::size_t size() const final
returns the number of rows managed by the handler
virtual const_reference row() const final
returns the current row pointed to by the handler (unsafe version)
virtual void reset() final
puts the handler to the beginning of the database's area it handles
virtual const IDatabaseTable< T_DATA > & database() const
returns a pointer on the database
virtual Handler & operator=(const Handler &)
copy operator
typename DBHandler< T_DATA >::value_type value_type
Types for STL compliance.
virtual std::size_t nbVariables() const final
returns the number of variables (columns) of the database
std::ptrdiff_t difference_type
Types for STL compliance.
std::vector< TX_DATA > DBVector
virtual std::size_t numRow() const final
the number of the current row (0 = the 1st row managed by the handler)
virtual ~Handler()
destructor
std::random_access_iterator_tag iterator_category
Types for STL compliance.
virtual const_reference rowSafe() const final
returns the current row pointed to by the handler (safe version)
virtual std::pair< std::size_t, std::size_t > range() const final
returns the current range of the handler [begin,end)
Handler(Handler &&h)
move constructor
Handler(const Handler &h)
copy constructor
virtual void nextRow() final
makes the handler point to the next row, equivalent to operator++
std::vector< DBRow< TX_DATA > > Matrix
virtual std::size_t DBSize() const final
returns the number of rows of the whole database
value_type * pointer
Types for STL compliance.
const iterator & end() const noexcept
returns a new unsafe handler pointing to the end of the database
void setAllRowsWeight(const double new_weight)
assign a given weight to all the rows of the database
IDatabaseTable(IDatabaseTable< T_DATA > &&from)
move constructor
IDatabaseTable< T_DATA > & operator=(const IDatabaseTable< T_DATA > &from)
copy operator
value_type & reference
Types for STL compliance.
std::size_t nbProcessingThreads_() const
returns the number of threads used to process the current database content
const Handler const_iterator
Types for STL compliance.
DBVector< IsMissing > has_row_missing_val_
IDatabaseTable< T_DATA > & operator=(IDatabaseTable< T_DATA > &&from)
move operator
const iterator_safe & endSafe() const noexcept
returns a new safe handler pointing to the end of the database
std::size_t nbRows() const noexcept
returns the number of records (rows) in the database
IDatabaseTable(const MissingValType &missing_symbols, const std::vector< std::string > &var_names)
default constructor
DBVector< std::string > variable_names_
the names of the variables for each column
std::size_t min_nb_rows_per_thread_
bool empty() const noexcept
indicates whether the database contains some records or not
void eraseRow(std::size_t index)
erase a given row specified by its index in the table
std::ptrdiff_t difference_type
Types for STL compliance.
virtual const DBVector< std::size_t > ignoredColumns() const =0
returns the set of columns of the original dataset that are ignored
void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context
void eraseFirstRows(const std::size_t k)
erase the k first rows
DBVector< std::string > missing_symbols_
virtual void clear()
erase the content of the database, including the names of the variables
void eraseLastRow()
erase the last row
const DBVector< std::string > & missingSymbols() const
returns the set of missing symbols
IDatabaseTable(const IDatabaseTable< T_DATA > &from)
copy constructor
std::vector< std::pair< std::size_t, std::size_t > > rangesProcessingThreads_(const std::size_t nb_threads) const
returns the ranges that threads should process
std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
std::vector< std::string > MissingValType
const Matrix< T_DATA > & content() const noexcept
returns the content (the records) of the database
const DBVector< std::string > & variableNames() const noexcept
returns the variable names for all the columns of the database
std::size_t columnFromVariableName(const std::string &name) const
returns the index of the column whose name is passed in argument
Row< T_DATA > value_type
Types for STL compliance.
const HandlerSafe const_iterator_safe
Types for STL compliance.
void eraseLastRows(const std::size_t k)
erase the k last rows
iterator begin() const
returns a new unsafe handler pointing to the beginning of the database
void eraseRows(std::size_t deb, std::size_t end)
erase the rows from the debth to the endth (not included)
virtual void setVariableNames(const std::vector< std::string > &names, const bool from_external_object=true)=0
sets the names of the variables
iterator handler() const
returns a new unsafe handler pointing to the 1st record of the database
DBVector< std::size_t > columnsFromVariableName(const std::string &name) const
returns the indices of all the columns whose name is passed in argument
virtual IDatabaseTable< T_DATA > * clone() const =0
virtual copy constructor
const value_type * const_pointer
Types for STL compliance.
virtual void ignoreColumn(const std::size_t k, const bool from_external_object=true)=0
makes the database table ignore from now on the kth column
void setMaxNbThreads(const std::size_t nb) const
changes the max number of threads that a database can use
double weight(const std::size_t i) const
returns the weight of the ith record
std::size_t size_type
Types for STL compliance.
std::size_t size() const noexcept
returns the number of records (rows) in the database
virtual void insertRow(const std::vector< std::string > &new_row)=0
insert a new row at the end of the database
bool hasMissingValues() const
indicates whether the database contains some missing values
std::vector< DBRow< TX_DATA > > Matrix
the type for the matrices stored into the database
value_type * pointer
Types for STL compliance.
void eraseAllRows()
erase all the rows
std::size_t nbThreads() const
returns the number of threads used to parse the database
iterator_safe handlerSafe() const
returns a new safe handler pointing to the 1st record of the database
const std::string & variableName(const std::size_t k) const
returns the name of the kth column of the IDatabaseTable
std::size_t nbVariables() const noexcept
returns the number of variables (columns) of the database
void eraseFirstRow()
erase the first row
void setWeight(const std::size_t i, const double weight)
assigns a given weight to the ith row of the database
std::size_t max_nb_threads_
std::vector< TX_DATA > DBVector
the type for the vectors used in the IDatabaseTable
Handler iterator
Types for STL compliance.
const value_type & const_reference
Types for STL compliance.
virtual ~IDatabaseTable()
destructor
DBRow< TX_DATA > Row
a row of the database
virtual void insertRows(Matrix< T_DATA > &&new_rows, const DBVector< IsMissing > &rows_have_missing_vals)
insert a set of new DBRows at the end of the database
bool isRowSizeOK_(const std::size_t size) const
checks whether a size corresponds to the number of columns of the database
iterator_safe beginSafe() const
returns a new safe handler pointing to the beginning of the database
virtual const DBVector< std::size_t > inputColumns() const =0
returns the set of columns of the original dataset that are present in the IDatabaseTable
HandlerSafe iterator_safe
Types for STL compliance.
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities
unsigned int getNumberOfThreads()
returns the max number of threads used by default when entering the next parallel region
virtual void insertRows(const DBVector< DBVector< std::string > > &new_rows)
insert new rows at the end of the database
std::vector< TX_DATA > DBVector
std::vector< DBRow< TX_DATA > > Matrix
virtual void insertRow(const std::vector< std::string > &new_row)=0
insert a new row at the end of the database
virtual void insertRows(const Matrix< DBCell > &new_rows)=0
insert a set of new DBRows at the end of the database
virtual void insertRow(const std::vector< std::string > &new_row)=0
insert a new row at the end of the database
virtual void insertRow(Row< DBCell > &&new_row)=0
insert a new DBRow at the end of the database
std::vector< TX_DATA > DBVector
virtual void insertRows(Matrix< DBCell > &&new_rows)=0
insert a set of new DBRows at the end of the database
std::vector< DBRow< TX_DATA > > Matrix
virtual void insertRows(const DBVector< DBVector< std::string > > &new_rows)
insert new rows at the end of the database
virtual void insertRow(const Row< DBCell > &new_row)=0
insert a new row at the end of the database
The class to use to execute a function by several threads.
Utility functions used for exploiting OpenMP/STL parallelism.