27 #ifndef DOXYGEN_SHOULD_SKIP_THIS 35 template <
template <
typename >
class ALLOC >
36 template <
template <
typename >
class XALLOC >
38 const typename DatabaseTable< ALLOC >::template MissingValType< XALLOC >&
40 const DBTranslatorSet< ALLOC >& translators,
42 IDatabaseTable< DBTranslatedValue, ALLOC >(
44 std::vector<
std::string, ALLOC<
std::string > >(),
46 __translators(translators, alloc) {
47 if (translators.size()) {
49 std::vector< std::string, ALLOC< std::string > > var_names(
51 for (std::size_t i = std::size_t(0),
size = translators.size(); i <
size;
53 var_names[i] = __translators.translator(i).variable()->name();
63 template <
template <
typename >
class ALLOC >
65 const DBTranslatorSet< ALLOC >& translators,
68 std::vector<
std::string, ALLOC<
std::string > >(),
69 std::vector<
std::string, ALLOC<
std::string > >(),
71 __translators(translators, alloc) {
72 if (translators.size()) {
74 std::vector< std::string, ALLOC< std::string > > var_names(
76 for (std::size_t i = std::size_t(0), size = translators.size(); i <
size;
78 var_names[i] = __translators.translator(i).variable()->name();
88 template <
template <
typename >
class ALLOC >
90 const DatabaseTable< ALLOC >& from,
93 __translators(from.__translators, alloc),
94 __ignored_cols(from.__ignored_cols) {
100 template <
template <
typename >
class ALLOC >
107 template <
template <
typename >
class ALLOC >
109 DatabaseTable< ALLOC >&& from,
112 __translators(
std::move(from.__translators), alloc),
113 __ignored_cols(
std::move(from.__ignored_cols)) {
119 template <
template <
typename >
class ALLOC >
125 template <
template <
typename >
class ALLOC >
128 ALLOC< DatabaseTable< ALLOC > > allocator(alloc);
129 DatabaseTable< ALLOC >* new_db = allocator.allocate(1);
131 allocator.construct(new_db, *
this, alloc);
133 allocator.deallocate(new_db, 1);
142 template <
template <
typename >
class ALLOC >
149 template <
template <
typename >
class ALLOC >
156 template <
template <
typename >
class ALLOC >
158 operator=(
const DatabaseTable< ALLOC >& from) {
161 __translators = from.__translators;
162 __ignored_cols = from.__ignored_cols;
170 template <
template <
typename >
class ALLOC >
172 operator=(DatabaseTable< ALLOC >&& from) {
175 __translators = std::move(from.__translators);
176 __ignored_cols = std::move(from.__ignored_cols);
184 template <
template <
typename >
class ALLOC >
185 template <
typename Functor1,
typename Functor2 >
186 void DatabaseTable< ALLOC >::__threadProcessDatabase(Functor1& exec_func,
187 Functor2& undo_func) {
193 const std::size_t db_size = this->
_rows.size();
199 std::size_t nb_rows_par_thread = db_size / nb_threads;
200 std::size_t rest_rows = db_size - nb_rows_par_thread * nb_threads;
203 if (nb_threads == 1) {
204 exec_func(std::size_t(0), db_size);
211 std::vector< std::thread > threads;
212 threads.reserve(nb_threads);
213 std::vector< std::exception_ptr > func_exceptions(nb_threads,
nullptr);
216 auto real_exec_func = [&exec_func](std::size_t
begin,
218 std::exception_ptr& exc) ->
void {
220 exec_func(begin, end);
221 }
catch (...) { exc = std::current_exception(); }
225 std::size_t begin_index = std::size_t(0);
226 for (std::size_t i = std::size_t(0); i < nb_threads; ++i) {
227 std::size_t end_index = begin_index + nb_rows_par_thread;
228 if (rest_rows != std::size_t(0)) {
232 threads.push_back(std::thread(std::ref(real_exec_func),
235 std::ref(func_exceptions[i])));
236 begin_index = end_index;
241 threads.begin(), threads.end(), std::mem_fn(&std::thread::join));
244 bool exception_raised =
false;
245 for (
const auto& exc : func_exceptions) {
246 if (exc !=
nullptr) {
247 exception_raised =
true;
252 if (exception_raised) {
255 auto real_undo_func = [&undo_func](std::size_t
begin,
257 std::exception_ptr& exc) ->
void {
259 undo_func(begin, end);
260 }
catch (...) { exc = std::current_exception(); }
265 begin_index = std::size_t(0);
266 std::vector< std::exception_ptr > undo_func_exceptions(nb_threads,
268 for (std::size_t i = std::size_t(0); i < nb_threads; ++i) {
269 std::size_t end_index = begin_index + nb_rows_par_thread;
270 if (rest_rows != std::size_t(0)) {
275 if (func_exceptions[i] ==
nullptr)
276 threads.push_back(std::thread(std::ref(real_undo_func),
279 std::ref(undo_func_exceptions[i])));
280 begin_index = end_index;
285 threads.begin(), threads.end(), std::mem_fn(&std::thread::join));
288 for (
const auto& exc : func_exceptions) {
289 if (exc !=
nullptr) { std::rethrow_exception(exc); }
296 template <
template <
typename >
class ALLOC >
299 const std::size_t input_column,
300 const bool unique_column) {
302 if (__ignored_cols.exists(input_column))
306 << input_column <<
" is marked as being ignored. " 307 <<
"So it is forbidden to create a translator for that column.");
310 const std::size_t new_size = this->
nbVariables() + 1;
315 auto reserve_lambda = [
this, new_size](std::size_t
begin,
316 std::size_t
end) ->
void {
317 for (std::size_t i = begin; i <
end; ++i)
318 this->
_rows[i].row().reserve(new_size);
321 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
324 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
327 const std::size_t pos =
328 __translators.insertTranslator(translator, input_column, unique_column);
334 __translators.eraseTranslator(pos);
341 const DBTranslatedValue missing = __translators[pos].missingValue();
344 auto fill_lambda = [
this, missing](std::size_t
begin,
345 std::size_t
end) ->
void {
346 std::size_t i =
begin;
348 for (; i <
end; ++i) {
349 this->
_rows[i].row().push_back(missing);
353 for (std::size_t j = begin; j < i; ++j)
354 this->
_rows[i].row().pop_back();
359 auto undo_fill_lambda = [
this](std::size_t
begin,
360 std::size_t
end) ->
void {
361 for (std::size_t i = begin; i <
end; ++i)
362 this->
_rows[i].row().pop_back();
366 this->__threadProcessDatabase(fill_lambda, undo_fill_lambda);
374 template <
template <
typename >
class ALLOC >
377 const std::size_t input_column,
378 const bool unique_column) {
380 if (__ignored_cols.exists(input_column))
384 << input_column <<
" is marked as being ignored. " 385 <<
"So it is forbidden to create a translator for that column.");
393 MissingValueInDatabase,
394 "inserting a new translator into a database creates a new column " 395 <<
"with missing values. However, you did not define any symbol for " 400 const std::size_t new_size = this->
nbVariables() + 1;
405 auto reserve_lambda = [
this, new_size](std::size_t
begin,
406 std::size_t
end) ->
void {
407 for (std::size_t i = begin; i <
end; ++i)
408 this->
_rows[i].row().reserve(new_size);
411 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
414 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
417 const std::size_t pos =
418 __translators.insertTranslator(var, input_column, unique_column);
424 __translators.eraseTranslator(pos);
433 template <
template <
typename >
class ALLOC >
434 template <
template <
typename >
class XALLOC >
437 const std::size_t input_column,
438 std::vector< std::string, XALLOC< std::string > > missing_symbols,
439 const bool unique_column) {
441 if (__ignored_cols.exists(input_column))
445 << input_column <<
" is marked as being ignored. " 446 <<
"So it is forbidden to create a translator for that column.");
449 const std::size_t new_size = this->
nbVariables() + 1;
454 auto reserve_lambda = [
this, new_size](std::size_t
begin,
455 std::size_t
end) ->
void {
456 for (std::size_t i = begin; i <
end; ++i)
457 this->
_rows[i].row().reserve(new_size);
460 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
463 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
466 const std::size_t pos = __translators.insertTranslator(
467 var, input_column, missing_symbols, unique_column);
473 __translators.eraseTranslator(pos);
480 const DBTranslatedValue missing = __translators[pos].missingValue();
483 auto fill_lambda = [
this, missing](std::size_t
begin,
484 std::size_t
end) ->
void {
485 std::size_t i =
begin;
487 for (; i <
end; ++i) {
488 this->
_rows[i].row().push_back(missing);
492 for (std::size_t j = begin; j < i; ++j)
493 this->
_rows[i].row().pop_back();
498 auto undo_fill_lambda = [
this](std::size_t
begin,
499 std::size_t
end) ->
void {
500 for (std::size_t i = begin; i <
end; ++i)
501 this->
_rows[i].row().pop_back();
505 this->__threadProcessDatabase(fill_lambda, undo_fill_lambda);
516 template <
template <
typename >
class ALLOC >
517 INLINE
typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
518 DatabaseTable< ALLOC >::__getKthIndices(
const std::size_t k,
519 const bool k_is_input_col)
const {
520 const std::size_t nb_trans = __translators.size();
521 if (!k_is_input_col) {
523 return DBVector< std::size_t >{k};
525 return DBVector< std::size_t >();
527 DBVector< std::size_t > trans;
528 for (std::size_t i = std::size_t(0), kk = nb_trans - 1; i < nb_trans;
530 if (__translators.inputColumn(kk) == k) trans.push_back(kk);
539 template <
template <
typename >
class ALLOC >
541 const bool k_is_input_col) {
542 for (
const auto kk : __getKthIndices(k, k_is_input_col)) {
550 const std::size_t nb_trans = __translators.size();
552 auto erase_lambda = [
this, nb_trans, kk](std::size_t
begin,
553 std::size_t
end) ->
void {
554 for (std::size_t i = begin; i <
end; ++i) {
555 auto& row = this->
_rows[i].row();
556 if (this->__translators.isMissingValue(row[kk], kk)) {
557 bool has_missing_val =
false;
558 for (std::size_t j = std::size_t(0); j < nb_trans; ++j) {
559 if ((j != kk) && this->__translators.isMissingValue(row[j], j)) {
560 has_missing_val =
true;
564 if (!has_missing_val)
567 row.erase(row.begin() + kk);
571 auto undo_erase_lambda = [](std::size_t
begin, std::size_t
end) ->
void {
575 this->__threadProcessDatabase(erase_lambda, undo_erase_lambda);
577 __translators.eraseTranslator(kk);
583 template <
template <
typename >
class ALLOC >
584 INLINE
const DBTranslatorSet< ALLOC >&
586 return __translators;
593 template <
template <
typename >
class ALLOC >
595 DatabaseTable< ALLOC >::__getKthIndex(
const std::size_t k,
596 const bool k_is_input_col)
const {
597 if (k_is_input_col) {
598 const std::size_t nb_trans = __translators.size();
599 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
600 if (__translators.inputColumn(i) == k) {
return i; }
610 template <
template <
typename >
class ALLOC >
611 const DBTranslator< ALLOC >&
613 const bool k_is_input_col)
const {
616 const std::size_t nb_trans = __translators.size();
617 const std::size_t kk = __getKthIndex(k, k_is_input_col);
620 if (nb_trans <= kk) {
621 if (k_is_input_col) {
623 "there is no translator in the database table that " 624 <<
"parses Column " << k);
627 "the database has " << nb_trans
628 <<
" translators, so Translator #" << k
629 <<
" does not exist");
633 return __translators.translator(kk);
638 template <
template <
typename >
class ALLOC >
641 const bool k_is_input_col)
const {
644 const std::size_t nb_trans = __translators.size();
645 const std::size_t kk = __getKthIndex(k, k_is_input_col);
648 if (nb_trans <= kk) {
649 if (k_is_input_col) {
651 "there is no variable in the database table that " 652 <<
"corresponds to Column " << k);
655 "the database has " << nb_trans <<
" variables, so Variable #" 656 << k <<
" does not exist");
660 return __translators.variable(kk);
665 template <
template <
typename >
class ALLOC >
667 const std::vector< std::string, ALLOC< std::string > >& names,
668 const bool from_external_object) {
669 const std::size_t size = names.size();
670 const std::size_t nb_trans = __translators.size();
671 if (!from_external_object) {
672 if (nb_trans != size) {
674 "the number of variable's names (i.e., " 676 <<
") does not correspond to the number of columns of the " 677 <<
"database table (i.e.," << nb_trans <<
")");
681 for (std::size_t i = std::size_t(0); i <
size; ++i) {
682 __translators.translator(i).setVariableName(names[i]);
685 if (nb_trans && (__translators.highestInputColumn() >=
size)) {
687 "the names vector has " 688 << size <<
" elements whereas it should have at least " 689 << (__translators.highestInputColumn() + 1)
690 <<
"elements so that each translator is assigned a name");
694 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
695 __translators.translator(i).setVariableName(
696 names[__translators.inputColumn(i)]);
702 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
710 template <
template <
typename >
class ALLOC >
712 const bool k_is_input_col) {
716 const std::size_t nb_trans = __translators.size();
717 if (k_is_input_col) {
718 if (__ignored_cols.exists(k))
return;
719 __ignored_cols.insert(k);
722 __ignored_cols.insert(__translators.inputColumn(k));
725 "It is impossible to ignore the column parsed by Translator #" 726 << k <<
"because there exist only " << nb_trans
737 template <
template <
typename >
class ALLOC >
738 const typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
740 const std::size_t nb_trans = __translators.size();
742 if (nb_trans == std::size_t(0)) {
743 return DBVector< std::size_t >{std::size_t(0)};
747 DBVector< std::size_t > cols(nb_trans);
748 for (std::size_t i = std::size_t(0); i < nb_trans; ++i)
749 cols[i] = __translators.inputColumn(i);
750 std::sort(cols.begin(), cols.end());
753 const std::size_t highest = __translators.highestInputColumn() + 1;
754 DBVector< std::size_t > ignored_cols(highest);
755 std::iota(ignored_cols.begin(), ignored_cols.end(), 0);
758 for (std::size_t i = std::size_t(0),
764 if (cols[kk] == ii) {
765 ignored_cols.erase(ignored_cols.begin() + ii);
766 while ((k < nb_trans) && (cols[kk] == ii)) {
770 if (k == nb_trans)
break;
775 ignored_cols.push_back(highest);
782 template <
template <
typename >
class ALLOC >
783 const typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
785 const std::size_t nb_trans = __translators.size();
786 if (nb_trans == std::size_t(0)) {
return DBVector< std::size_t >(); }
788 DBVector< std::size_t > input_cols(nb_trans);
789 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
790 input_cols[i] = __translators.inputColumn(i);
797 template <
template <
typename >
class ALLOC >
800 const bool k_is_input_col)
const {
802 const std::size_t nb_trans = __translators.size();
803 const std::size_t kk = __getKthIndex(k, k_is_input_col);
806 if (nb_trans <= kk) {
807 if (k_is_input_col) {
809 "there is no variable in the database table that " 810 <<
"corresponds to Column " << k);
813 "the database has " << nb_trans <<
" variables, so Variable #" 814 << k <<
" does not exist");
818 return __translators.domainSize(kk);
823 template <
template <
typename >
class ALLOC >
824 INLINE std::vector< std::size_t, ALLOC< std::size_t > >
826 const std::size_t nb_trans = __translators.size();
827 std::vector< std::size_t > dom(nb_trans);
828 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
829 dom[i] = __translators.domainSize(i);
837 template <
template <
typename >
class ALLOC >
839 const bool k_is_input_col)
const {
841 const std::size_t nb_trans = __translators.size();
842 const std::size_t kk = __getKthIndex(k, k_is_input_col);
845 if (nb_trans <= kk) {
846 if (k_is_input_col) {
848 "there is no translator in the database table that " 849 <<
"parses Column " << k);
852 "the database has " << nb_trans
853 <<
" translators, so Translator #" << k
854 <<
" does not exist");
858 return __translators.needsReordering(kk);
864 template <
template <
typename >
class ALLOC >
866 const bool k_is_input_col) {
868 const std::size_t nb_trans = __translators.size();
869 const std::size_t kk = __getKthIndex(k, k_is_input_col);
872 if (nb_trans <= kk) {
873 if (k_is_input_col) {
875 "there is no translator in the database table that " 876 <<
"parses Column " << k);
879 "the database has " << nb_trans
880 <<
" translators, so Translator #" << k
881 <<
" does not exist");
887 if (__translators.translator(kk).getValType()
892 auto updates = __translators.reorder(kk);
893 if (updates.empty())
return;
895 std::size_t size = updates.size();
896 std::vector< std::size_t, ALLOC< std::size_t > > new_values(size);
897 for (
const auto& update : updates) {
898 if (update.first >= size) {
899 size = update.first + 1;
900 new_values.resize(size);
902 new_values[update.first] = update.second;
906 auto newtrans_lambda = [
this, kk, &new_values](std::size_t
begin,
907 std::size_t
end) ->
void {
908 for (std::size_t i = begin; i <
end; ++i) {
909 auto& elt = this->
_rows[i][kk].discr_val;
910 if (elt != std::numeric_limits< std::size_t >::max())
911 elt = new_values[elt];
915 auto undo_newtrans_lambda = [](std::size_t
begin, std::size_t
end) ->
void {
919 this->__threadProcessDatabase(newtrans_lambda, undo_newtrans_lambda);
924 template <
template <
typename >
class ALLOC >
926 const std::size_t nb_trans = __translators.size();
927 for (std::size_t i = std::size_t(0); i < nb_trans; ++i)
933 template <
template <
typename >
class ALLOC >
935 const std::vector< std::string, ALLOC< std::string > >& new_row) {
938 const std::size_t row_size = new_row.size();
939 if (row_size == std::size_t(0))
return;
941 if (__translators.highestInputColumn() >= row_size) {
945 <<
" columns whereas the database requires at least " 946 << (__translators.highestInputColumn() + 1) <<
" columns");
950 const std::size_t nb_trans = __translators.size();
951 Row< DBTranslatedValue > dbrow;
952 dbrow.reserve(nb_trans);
953 bool has_missing_val =
false;
954 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
955 const DBTranslatedValue new_val(__translators.translate(new_row, i));
956 if (__translators.isMissingValue(new_val, i)) has_missing_val =
true;
957 dbrow.pushBack(std::move(new_val));
961 has_missing_val ? IsMissing::True : IsMissing::False);
967 template <
template <
typename >
class ALLOC >
968 bool DatabaseTable< ALLOC >::__isRowCompatible(
969 const typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&
972 const std::size_t row_size = row.size();
973 if (row_size != __translators.size())
return false;
975 const auto& translators = __translators.translators();
976 for (std::size_t i = std::size_t(0); i < row_size; ++i) {
977 switch (translators[i]->getValType()) {
979 if ((row[i].discr_val >= translators[i]->
domainSize())
980 && (row[i].discr_val != std::numeric_limits< std::size_t >::max()))
985 const IContinuousVariable& var =
986 static_cast< const IContinuousVariable&
>(
987 *(translators[i]->variable()));
988 if (((var.lowerBoundAsDouble() > (
double)row[i].cont_val)
989 || (var.upperBoundAsDouble() < (
double)row[i].cont_val))
990 && (row[i].cont_val != std::numeric_limits< float >::max()))
997 "Translated value type not supported yet");
1006 template <
template <
typename >
class ALLOC >
1008 typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&&
1013 if (!__isRowCompatible(new_row)) {
1014 if (new_row.size() != __translators.size()) {
1018 <<
" elements whereas the database table has " 1019 << __translators.size() <<
" columns");
1022 "the new row is not compatible with the current translators");
1027 contains_missing_data);
1032 template <
template <
typename >
class ALLOC >
1034 const typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&
1039 if (!__isRowCompatible(new_row)) {
1040 if (new_row.size() != __translators.size()) {
1044 <<
" elements whereas the database table has " 1045 << __translators.size() <<
" columns");
1048 "the new row is not compatible with the current translators");
1053 contains_missing_data);
1058 template <
template <
typename >
class ALLOC >
1060 const typename DatabaseTable< ALLOC >::template Row< DBCell >& new_row) {
1061 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1065 template <
template <
typename >
class ALLOC >
1067 typename DatabaseTable< ALLOC >::template Row< DBCell >&& new_row) {
1068 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1073 template <
template <
typename >
class ALLOC >
1078 rows_have_missing_vals) {
1081 for (
const auto& new_row : rows) {
1082 if (!__isRowCompatible(new_row)) {
1083 if (new_row.size() != __translators.size()) {
1087 <<
" elements whereas the database table has " 1088 << __translators.size() <<
" columns");
1092 "the new row is not compatible with the current translators");
1098 std::move(rows), rows_have_missing_vals);
1103 template <
template <
typename >
class ALLOC >
1108 rows_have_missing_vals) {
1111 for (
const auto& new_row : new_rows) {
1112 if (!__isRowCompatible(new_row)) {
1113 if (new_row.size() != __translators.size()) {
1117 <<
" elements whereas the database table has " 1118 << __translators.size() <<
" columns");
1122 "the new row is not compatible with the current translators");
1128 new_rows, rows_have_missing_vals);
1133 template <
template <
typename >
class ALLOC >
1136 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1141 template <
template <
typename >
class ALLOC >
1145 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1150 template <
template <
typename >
class ALLOC >
1152 __translators.clear();
1153 __ignored_cols.clear();
virtual ~DatabaseTable()
destructor
void insertRow(const std::vector< std::string, OTHER_ALLOC< std::string > > &new_row)
insert a new row at the end of the database
DBVector< IsMissing > _has_row_missing_val
The class representing a tabular database stored in RAM.
virtual 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 of the input dataset or the column parsed ...
DBVector< std::size_t > domainSizes() const
returns the domain sizes of all the variables in the database table
ALLOC< DBTranslatedValue > getAllocator() const
returns the allocator of the database
const DBTranslatorSet< ALLOC > & translatorSet() const
returns the set of translators
std::size_t size() const noexcept
returns the number of records (rows) in the database
virtual void insertRow(const std::vector< std::string, ALLOC< std::string > > &new_row) final
insert a new row at the end of the database
IDatabaseTable< T_DATA, ALLOC > & operator=(const IDatabaseTable< T_DATA, ALLOC > &from)
copy operator
void eraseAllRows()
erase all the rows
gum is the global namespace for all aGrUM entities
ALLOC< DBTranslatedValue > allocator_type
Types for STL compliance.
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...
std::size_t nbVariables() const noexcept
returns the number of variables (columns) of the database
IDatabaseTable(const MissingValType< MISSALLOC > &missing_symbols, const std::vector< std::string, VARALLOC< std::string > > &var_names, const ALLOC< DBTranslatedValue > &alloc)
default constructor
virtual DatabaseTable< ALLOC > * clone() const final
virtual copy constructor
DBVector< std::string > _variable_names
the names of the variables for each column
bool empty() const noexcept
indicates whether the database contains some records or not
virtual const DBVector< std::size_t > inputColumns() const final
returns the set of columns of the original dataset that are present in the DatabaseTable ...
const iterator & end() const noexcept
returns a new unsafe handler pointing to the end of the database
const DBTranslator< ALLOC > & 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...
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...
virtual const DBVector< std::size_t > ignoredColumns() const final
returns the set of columns of the original dataset that are ignored
DatabaseTable< ALLOC > & operator=(const DatabaseTable< ALLOC > &from)
copy operator
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
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...
virtual void insertRows(Matrix< DBTranslatedValue > &&new_rows, const DBVector< IsMissing > &rows_have_missing_vals) final
insert a set of new DBRows at the end of the database
std::size_t _min_nb_rows_per_thread
virtual void clear() final
erase the content of the database, including the names of the variables
std::size_t insertTranslator(const DBTranslator< ALLOC > &translator, const std::size_t input_column, const bool unique_column=true)
insert a new translator into the database table
virtual void setVariableNames(const std::vector< std::string, ALLOC< std::string > > &names, const bool from_external_object=true) final
sets the names of the variables
typename IDatabaseTable< DBTranslatedValue, ALLOC >::IsMissing IsMissing
iterator begin() const
returns a new unsafe handler pointing to the beginning of the database
std::size_t _max_nb_threads
DatabaseTable(const MissingValType< XALLOC > &missing_symbols, const DBTranslatorSet< ALLOC > &translators=DBTranslatorSet< ALLOC >(), const allocator_type &alloc=allocator_type())
default constructor
Matrix< DBTranslatedValue > _rows
void eraseTranslators(const std::size_t k, const bool k_is_input_col=false)
erases either the kth translator or all those parsing the kth column of the input dataset ...
#define GUM_ERROR(type, msg)
virtual void clear()
erase the content of the database, including the names of the variables
void reorder()
performs a reordering of all the columns