50#ifndef DOXYGEN_SHOULD_SKIP_THIS
68 _ignored_cols_ = from._ignored_cols_;
77 _ignored_cols_ = std::move(from._ignored_cols_);
84 const bool from_external_object) {
85 const std::size_t
size = names.size();
86 const std::size_t ignored_cols_size = _ignored_cols_.size();
88 if (!from_external_object || !ignored_cols_size) {
89 if (this->
rows_.empty() || (
size == this->rows_[0].size())) {
93 "the number of variable's names (i.e., "
94 <<
size <<
") does not correspond to the number of columns of the "
95 <<
"raw database table (i.e.," << this->
rows_[0].
size() <<
")");
100 std::size_t ignored_size = std::size_t(0);
103 for (
auto iter = _ignored_cols_.rbegin(), rend = _ignored_cols_.rend(); iter != rend;
104 ++iter, ++ignored_size) {
105 if (*iter <
size) {
break; }
107 ignored_size = ignored_cols_size - ignored_size;
109 if (this->
rows_.empty() || (
size == this->rows_[0].size() + ignored_size)) {
111 for (std::size_t i = std::size_t(0), j = std::size_t(0); i <
size; ++i) {
112 if (i != _ignored_cols_[j]) {
113 new_names.push_back(names[i]);
115 if (++j == ignored_cols_size) {
116 for (++i; i <
size; ++i) {
117 new_names.push_back(names[i]);
126 "the number of variable's names excluding the ignored "
127 <<
"columns (i.e., " << (
size - ignored_size)
128 <<
") does not correspond to the number of columns of the "
129 <<
"raw database table (i.e.," << this->
rows_[0].
size() <<
")");
140 const std::size_t
size = _ignored_cols_.size();
142 if (from_external_object) {
143 for (i = std::size_t(0); i <
size; ++i) {
144 if (k <= _ignored_cols_[i]) {
145 if (k == _ignored_cols_[i])
return;
150 for (i = std::size_t(0); i <
size; ++i, ++kk) {
151 if (kk <= _ignored_cols_[i]) {
152 if (kk == _ignored_cols_[i])
return;
163 const std::size_t col = kk - i;
169 const std::size_t nb_rows = this->
rows_.size();
170 if (nb_rows != std::size_t(0)) {
171 const std::size_t nb_cols = this->
rows_[0].size();
172 for (std::size_t i = std::size_t(0); i < nb_rows; ++i) {
173 auto& row = this->
rows_[i].row();
175 bool has_missing_val =
false;
176 for (std::size_t j = std::size_t(0); j < nb_cols; ++j) {
177 if ((j != col) && row[j].isMissing()) {
178 has_missing_val =
true;
184 row.erase(row.begin() + col);
191 _ignored_cols_.push_back(std::size_t(0));
192 for (std::size_t j =
size; j > i; --j)
193 _ignored_cols_[j] = _ignored_cols_[j - 1];
194 _ignored_cols_[i] = kk;
198 const typename RawDatabaseTable::template DBVector< std::size_t >
203 const std::size_t
size = data[0].size();
204 const std::size_t ignored_cols_size = _ignored_cols_.size();
207 if (!ignored_cols_size) {
208 for (std::size_t i = std::size_t(0); i <
size; ++i) {
214 std::size_t i = std::size_t(0);
215 std::size_t k = std::size_t(0);
216 std::size_t j = std::size_t(0);
218 if (i != _ignored_cols_[j]) {
220 if (++k ==
size)
break;
222 if (++j == ignored_cols_size) {
223 for (++i; k <
size; ++i, ++k) {
240 const std::size_t row_size = new_row.size();
241 const std::size_t ignored_cols_size = _ignored_cols_.size();
242 std::size_t ignored_size = std::size_t(0);
243 if (ignored_cols_size) {
245 for (
auto iter = _ignored_cols_.rbegin(), rend = _ignored_cols_.rend(); iter != rend;
246 ++iter, ++ignored_size) {
247 if (*iter < row_size) {
break; }
249 ignored_size = ignored_cols_size - ignored_size;
254 "the new row has " << (row_size - ignored_size)
255 <<
" elements whereas the raw database table has "
261 dbrow.reserve(row_size - ignored_size);
262 bool has_missing_val =
false;
265 if (ignored_size == 0) {
266 for (
const auto& elt: new_row) {
267 const DBCell new_cell(this->_convert_(elt));
268 if (new_cell.isMissing()) has_missing_val =
true;
269 dbrow.pushBack(new_cell);
272 for (std::size_t i = std::size_t(0), j = std::size_t(0); i < row_size; ++i) {
273 if (i != _ignored_cols_[j]) {
274 const DBCell new_cell(this->_convert_(new_row[i]));
275 if (new_cell.isMissing()) has_missing_val =
true;
276 dbrow.pushBack(new_cell);
278 if (++j == ignored_size) {
279 for (++i; i < row_size; ++i) {
280 const DBCell new_cell(this->_convert_(new_row[i]));
281 if (new_cell.isMissing()) has_missing_val =
true;
282 dbrow.pushBack(new_cell);
290 has_missing_val ? IsMissing::True : IsMissing::False);
295 _ignored_cols_.clear();
IDatabaseTable< T_DATA > & operator=(const IDatabaseTable< T_DATA > &from)
copy operator
DBVector< IsMissing > has_row_missing_val_
DBVector< std::string > variable_names_
virtual void clear()
erase the content of the database, including the names of the variables
const Matrix< T_DATA > & content() const noexcept
returns the content (the records) of the database
std::size_t size() const noexcept
virtual void insertRow(const std::vector< std::string > &new_row)=0
insert a new row at the end of the database
void eraseAllRows()
erase all the rows
bool isRowSizeOK_(const std::size_t size) const
The table containing the raw/original data of a database.
virtual void clear() final
erase the content of the database, including the names of the variables
DBRow< TX_DATA > Row
a row of the database
virtual RawDatabaseTable * clone() const final
virtual copy constructor
void insertRow(const std::vector< std::string > &new_row) final
insert a new row at the end of the database
RawDatabaseTable()
default constructor
void ignoreColumn(const std::size_t k, const bool from_external_object=true) final
makes the database table ignore from now on the kth column
void setVariableNames(const std::vector< std::string > &names, const bool from_external_object=true) final
sets the names of the variables
std::vector< TX_DATA > DBVector
the type for the vectors used in the RawDatabaseTable
const DBVector< std::size_t > inputColumns() const final
returns the set of columns of the original dataset that are present in the RawDatabaseTable
RawDatabaseTable & operator=(const RawDatabaseTable &from)
copy operator
#define GUM_ERROR(type, msg)
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities
The table containing the raw/original data of a database.
The implementation of raw tabular databases stored in memory (RAM).