30 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 template <
template <
typename >
class ALLOC >
39 template <
template <
typename >
class XALLOC >
41 const typename DatabaseTable< ALLOC >::template MissingValType< XALLOC >&
43 const DBTranslatorSet< ALLOC >& translators,
45 IDatabaseTable< DBTranslatedValue, ALLOC >(
47 std::vector<
std::string, ALLOC<
std::string > >(),
49 __translators(translators, alloc) {
50 if (translators.size()) {
52 std::vector< std::string, ALLOC< std::string > > var_names(
54 for (std::size_t i = std::size_t(0),
size = translators.size(); i <
size;
56 var_names[i] = __translators.translator(i).variable()->name();
66 template <
template <
typename >
class ALLOC >
68 const DBTranslatorSet< ALLOC >& translators,
71 std::vector<
std::string, ALLOC<
std::string > >(),
72 std::vector<
std::string, ALLOC<
std::string > >(),
74 __translators(translators, alloc) {
75 if (translators.size()) {
77 std::vector< std::string, ALLOC< std::string > > var_names(
79 for (std::size_t i = std::size_t(0), size = translators.size(); i <
size;
81 var_names[i] = __translators.translator(i).variable()->name();
91 template <
template <
typename >
class ALLOC >
93 const DatabaseTable< ALLOC >& from,
96 __translators(from.__translators, alloc),
97 __ignored_cols(from.__ignored_cols) {
103 template <
template <
typename >
class ALLOC >
110 template <
template <
typename >
class ALLOC >
112 DatabaseTable< ALLOC >&& from,
115 __translators(
std::move(from.__translators), alloc),
116 __ignored_cols(
std::move(from.__ignored_cols)) {
122 template <
template <
typename >
class ALLOC >
128 template <
template <
typename >
class ALLOC >
131 ALLOC< DatabaseTable< ALLOC > > allocator(alloc);
132 DatabaseTable< ALLOC >* new_db = allocator.allocate(1);
134 allocator.construct(new_db, *
this, alloc);
136 allocator.deallocate(new_db, 1);
145 template <
template <
typename >
class ALLOC >
152 template <
template <
typename >
class ALLOC >
159 template <
template <
typename >
class ALLOC >
161 operator=(
const DatabaseTable< ALLOC >& from) {
164 __translators = from.__translators;
165 __ignored_cols = from.__ignored_cols;
173 template <
template <
typename >
class ALLOC >
175 operator=(DatabaseTable< ALLOC >&& from) {
178 __translators = std::move(from.__translators);
179 __ignored_cols = std::move(from.__ignored_cols);
187 template <
template <
typename >
class ALLOC >
188 template <
typename Functor1,
typename Functor2 >
189 void DatabaseTable< ALLOC >::__threadProcessDatabase(Functor1& exec_func,
190 Functor2& undo_func) {
196 const std::size_t db_size = this->
_rows.size();
202 std::size_t nb_rows_par_thread = db_size / nb_threads;
203 std::size_t rest_rows = db_size - nb_rows_par_thread * nb_threads;
206 if (nb_threads == 1) {
207 exec_func(std::size_t(0), db_size);
214 std::vector< std::thread > threads;
215 threads.reserve(nb_threads);
216 std::vector< std::exception_ptr > func_exceptions(nb_threads,
nullptr);
219 auto real_exec_func = [&exec_func](std::size_t
begin,
221 std::exception_ptr& exc) ->
void {
223 exec_func(begin, end);
224 }
catch (...) { exc = std::current_exception(); }
228 std::size_t begin_index = std::size_t(0);
229 for (std::size_t i = std::size_t(0); i < nb_threads; ++i) {
230 std::size_t end_index = begin_index + nb_rows_par_thread;
231 if (rest_rows != std::size_t(0)) {
235 threads.push_back(std::thread(std::ref(real_exec_func),
238 std::ref(func_exceptions[i])));
239 begin_index = end_index;
244 threads.begin(), threads.end(), std::mem_fn(&std::thread::join));
247 bool exception_raised =
false;
248 for (
const auto& exc : func_exceptions) {
249 if (exc !=
nullptr) {
250 exception_raised =
true;
255 if (exception_raised) {
258 auto real_undo_func = [&undo_func](std::size_t
begin,
260 std::exception_ptr& exc) ->
void {
262 undo_func(begin, end);
263 }
catch (...) { exc = std::current_exception(); }
268 begin_index = std::size_t(0);
269 std::vector< std::exception_ptr > undo_func_exceptions(nb_threads,
271 for (std::size_t i = std::size_t(0); i < nb_threads; ++i) {
272 std::size_t end_index = begin_index + nb_rows_par_thread;
273 if (rest_rows != std::size_t(0)) {
278 if (func_exceptions[i] ==
nullptr)
279 threads.push_back(std::thread(std::ref(real_undo_func),
282 std::ref(undo_func_exceptions[i])));
283 begin_index = end_index;
288 threads.begin(), threads.end(), std::mem_fn(&std::thread::join));
291 for (
const auto& exc : func_exceptions) {
292 if (exc !=
nullptr) { std::rethrow_exception(exc); }
299 template <
template <
typename >
class ALLOC >
302 const std::size_t input_column,
303 const bool unique_column) {
305 if (__ignored_cols.exists(input_column))
309 << input_column <<
" is marked as being ignored. " 310 <<
"So it is forbidden to create a translator for that column.");
313 const std::size_t new_size = this->
nbVariables() + 1;
318 auto reserve_lambda = [
this, new_size](std::size_t
begin,
319 std::size_t
end) ->
void {
320 for (std::size_t i = begin; i <
end; ++i)
321 this->
_rows[i].row().reserve(new_size);
324 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
327 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
330 const std::size_t pos =
331 __translators.insertTranslator(translator, input_column, unique_column);
337 __translators.eraseTranslator(pos);
344 const DBTranslatedValue missing = __translators[pos].missingValue();
347 auto fill_lambda = [
this, missing](std::size_t
begin,
348 std::size_t
end) ->
void {
349 std::size_t i =
begin;
351 for (; i <
end; ++i) {
352 this->
_rows[i].row().push_back(missing);
356 for (std::size_t j = begin; j < i; ++j)
357 this->
_rows[i].row().pop_back();
362 auto undo_fill_lambda = [
this](std::size_t
begin,
363 std::size_t
end) ->
void {
364 for (std::size_t i = begin; i <
end; ++i)
365 this->
_rows[i].row().pop_back();
369 this->__threadProcessDatabase(fill_lambda, undo_fill_lambda);
377 template <
template <
typename >
class ALLOC >
380 const std::size_t input_column,
381 const bool unique_column) {
383 if (__ignored_cols.exists(input_column))
387 << input_column <<
" is marked as being ignored. " 388 <<
"So it is forbidden to create a translator for that column.");
396 MissingValueInDatabase,
397 "inserting a new translator into a database creates a new column " 398 <<
"with missing values. However, you did not define any symbol for " 403 const std::size_t new_size = this->
nbVariables() + 1;
408 auto reserve_lambda = [
this, new_size](std::size_t
begin,
409 std::size_t
end) ->
void {
410 for (std::size_t i = begin; i <
end; ++i)
411 this->
_rows[i].row().reserve(new_size);
414 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
417 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
420 const std::size_t pos =
421 __translators.insertTranslator(var, input_column, unique_column);
427 __translators.eraseTranslator(pos);
436 template <
template <
typename >
class ALLOC >
437 template <
template <
typename >
class XALLOC >
440 const std::size_t input_column,
441 std::vector< std::string, XALLOC< std::string > > missing_symbols,
442 const bool unique_column) {
444 if (__ignored_cols.exists(input_column))
448 << input_column <<
" is marked as being ignored. " 449 <<
"So it is forbidden to create a translator for that column.");
452 const std::size_t new_size = this->
nbVariables() + 1;
457 auto reserve_lambda = [
this, new_size](std::size_t
begin,
458 std::size_t
end) ->
void {
459 for (std::size_t i = begin; i <
end; ++i)
460 this->
_rows[i].row().reserve(new_size);
463 auto undo_reserve_lambda = [](std::size_t
begin, std::size_t
end) ->
void {};
466 this->__threadProcessDatabase(reserve_lambda, undo_reserve_lambda);
469 const std::size_t pos = __translators.insertTranslator(
470 var, input_column, missing_symbols, unique_column);
476 __translators.eraseTranslator(pos);
483 const DBTranslatedValue missing = __translators[pos].missingValue();
486 auto fill_lambda = [
this, missing](std::size_t
begin,
487 std::size_t
end) ->
void {
488 std::size_t i =
begin;
490 for (; i <
end; ++i) {
491 this->
_rows[i].row().push_back(missing);
495 for (std::size_t j = begin; j < i; ++j)
496 this->
_rows[i].row().pop_back();
501 auto undo_fill_lambda = [
this](std::size_t
begin,
502 std::size_t
end) ->
void {
503 for (std::size_t i = begin; i <
end; ++i)
504 this->
_rows[i].row().pop_back();
508 this->__threadProcessDatabase(fill_lambda, undo_fill_lambda);
519 template <
template <
typename >
class ALLOC >
520 INLINE
typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
521 DatabaseTable< ALLOC >::__getKthIndices(
const std::size_t k,
522 const bool k_is_input_col)
const {
523 const std::size_t nb_trans = __translators.size();
524 if (!k_is_input_col) {
526 return DBVector< std::size_t >{k};
528 return DBVector< std::size_t >();
530 DBVector< std::size_t > trans;
531 for (std::size_t i = std::size_t(0), kk = nb_trans - 1; i < nb_trans;
533 if (__translators.inputColumn(kk) == k) trans.push_back(kk);
542 template <
template <
typename >
class ALLOC >
544 const bool k_is_input_col) {
545 for (
const auto kk : __getKthIndices(k, k_is_input_col)) {
553 const std::size_t nb_trans = __translators.size();
555 auto erase_lambda = [
this, nb_trans, kk](std::size_t
begin,
556 std::size_t
end) ->
void {
557 for (std::size_t i = begin; i <
end; ++i) {
558 auto& row = this->
_rows[i].row();
559 if (this->__translators.isMissingValue(row[kk], kk)) {
560 bool has_missing_val =
false;
561 for (std::size_t j = std::size_t(0); j < nb_trans; ++j) {
562 if ((j != kk) && this->__translators.isMissingValue(row[j], j)) {
563 has_missing_val =
true;
567 if (!has_missing_val)
570 row.erase(row.begin() + kk);
574 auto undo_erase_lambda = [](std::size_t
begin, std::size_t
end) ->
void {
578 this->__threadProcessDatabase(erase_lambda, undo_erase_lambda);
580 __translators.eraseTranslator(kk);
586 template <
template <
typename >
class ALLOC >
587 INLINE
const DBTranslatorSet< ALLOC >&
589 return __translators;
596 template <
template <
typename >
class ALLOC >
598 DatabaseTable< ALLOC >::__getKthIndex(
const std::size_t k,
599 const bool k_is_input_col)
const {
600 if (k_is_input_col) {
601 const std::size_t nb_trans = __translators.size();
602 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
603 if (__translators.inputColumn(i) == k) {
return i; }
613 template <
template <
typename >
class ALLOC >
614 const DBTranslator< ALLOC >&
616 const bool k_is_input_col)
const {
619 const std::size_t nb_trans = __translators.size();
620 const std::size_t kk = __getKthIndex(k, k_is_input_col);
623 if (nb_trans <= kk) {
624 if (k_is_input_col) {
626 "there is no translator in the database table that " 627 <<
"parses Column " << k);
630 "the database has " << nb_trans
631 <<
" translators, so Translator #" << k
632 <<
" does not exist");
636 return __translators.translator(kk);
641 template <
template <
typename >
class ALLOC >
644 const bool k_is_input_col)
const {
647 const std::size_t nb_trans = __translators.size();
648 const std::size_t kk = __getKthIndex(k, k_is_input_col);
651 if (nb_trans <= kk) {
652 if (k_is_input_col) {
654 "there is no variable in the database table that " 655 <<
"corresponds to Column " << k);
658 "the database has " << nb_trans <<
" variables, so Variable #" 659 << k <<
" does not exist");
663 return __translators.variable(kk);
668 template <
template <
typename >
class ALLOC >
670 const std::vector< std::string, ALLOC< std::string > >& names,
671 const bool from_external_object) {
672 const std::size_t size = names.size();
673 const std::size_t nb_trans = __translators.size();
674 if (!from_external_object) {
675 if (nb_trans != size) {
677 "the number of variable's names (i.e., " 679 <<
") does not correspond to the number of columns of the " 680 <<
"database table (i.e.," << nb_trans <<
")");
684 for (std::size_t i = std::size_t(0); i <
size; ++i) {
685 __translators.translator(i).setVariableName(names[i]);
688 if (nb_trans && (__translators.highestInputColumn() >=
size)) {
690 "the names vector has " 691 << size <<
" elements whereas it should have at least " 692 << (__translators.highestInputColumn() + 1)
693 <<
"elements so that each translator is assigned a name");
697 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
698 __translators.translator(i).setVariableName(
699 names[__translators.inputColumn(i)]);
705 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
713 template <
template <
typename >
class ALLOC >
715 const bool k_is_input_col) {
719 const std::size_t nb_trans = __translators.size();
720 if (k_is_input_col) {
721 if (__ignored_cols.exists(k))
return;
722 __ignored_cols.insert(k);
725 __ignored_cols.insert(__translators.inputColumn(k));
728 "It is impossible to ignore the column parsed by Translator #" 729 << k <<
"because there exist only " << nb_trans
740 template <
template <
typename >
class ALLOC >
741 const typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
743 const std::size_t nb_trans = __translators.size();
745 if (nb_trans == std::size_t(0)) {
746 return DBVector< std::size_t >{std::size_t(0)};
750 DBVector< std::size_t > cols(nb_trans);
751 for (std::size_t i = std::size_t(0); i < nb_trans; ++i)
752 cols[i] = __translators.inputColumn(i);
753 std::sort(cols.begin(), cols.end());
756 const std::size_t highest = __translators.highestInputColumn() + 1;
757 DBVector< std::size_t > ignored_cols(highest);
758 std::iota(ignored_cols.begin(), ignored_cols.end(), 0);
761 for (std::size_t i = std::size_t(0),
767 if (cols[kk] == ii) {
768 ignored_cols.erase(ignored_cols.begin() + ii);
769 while ((k < nb_trans) && (cols[kk] == ii)) {
773 if (k == nb_trans)
break;
778 ignored_cols.push_back(highest);
785 template <
template <
typename >
class ALLOC >
786 const typename DatabaseTable< ALLOC >::template DBVector< std::size_t >
788 const std::size_t nb_trans = __translators.size();
789 if (nb_trans == std::size_t(0)) {
return DBVector< std::size_t >(); }
791 DBVector< std::size_t > input_cols(nb_trans);
792 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
793 input_cols[i] = __translators.inputColumn(i);
800 template <
template <
typename >
class ALLOC >
803 const bool k_is_input_col)
const {
805 const std::size_t nb_trans = __translators.size();
806 const std::size_t kk = __getKthIndex(k, k_is_input_col);
809 if (nb_trans <= kk) {
810 if (k_is_input_col) {
812 "there is no variable in the database table that " 813 <<
"corresponds to Column " << k);
816 "the database has " << nb_trans <<
" variables, so Variable #" 817 << k <<
" does not exist");
821 return __translators.domainSize(kk);
826 template <
template <
typename >
class ALLOC >
827 INLINE std::vector< std::size_t, ALLOC< std::size_t > >
829 const std::size_t nb_trans = __translators.size();
830 std::vector< std::size_t > dom(nb_trans);
831 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
832 dom[i] = __translators.domainSize(i);
840 template <
template <
typename >
class ALLOC >
842 const bool k_is_input_col)
const {
844 const std::size_t nb_trans = __translators.size();
845 const std::size_t kk = __getKthIndex(k, k_is_input_col);
848 if (nb_trans <= kk) {
849 if (k_is_input_col) {
851 "there is no translator in the database table that " 852 <<
"parses Column " << k);
855 "the database has " << nb_trans
856 <<
" translators, so Translator #" << k
857 <<
" does not exist");
861 return __translators.needsReordering(kk);
867 template <
template <
typename >
class ALLOC >
869 const bool k_is_input_col) {
871 const std::size_t nb_trans = __translators.size();
872 const std::size_t kk = __getKthIndex(k, k_is_input_col);
875 if (nb_trans <= kk) {
876 if (k_is_input_col) {
878 "there is no translator in the database table that " 879 <<
"parses Column " << k);
882 "the database has " << nb_trans
883 <<
" translators, so Translator #" << k
884 <<
" does not exist");
890 if (__translators.translator(kk).getValType()
895 auto updates = __translators.reorder(kk);
896 if (updates.empty())
return;
898 std::size_t size = updates.size();
899 std::vector< std::size_t, ALLOC< std::size_t > > new_values(size);
900 for (
const auto& update : updates) {
901 if (update.first >= size) {
902 size = update.first + 1;
903 new_values.resize(size);
905 new_values[update.first] = update.second;
909 auto newtrans_lambda = [
this, kk, &new_values](std::size_t
begin,
910 std::size_t
end) ->
void {
911 for (std::size_t i = begin; i <
end; ++i) {
912 auto& elt = this->
_rows[i][kk].discr_val;
913 if (elt != std::numeric_limits< std::size_t >::max())
914 elt = new_values[elt];
918 auto undo_newtrans_lambda = [](std::size_t
begin, std::size_t
end) ->
void {
922 this->__threadProcessDatabase(newtrans_lambda, undo_newtrans_lambda);
927 template <
template <
typename >
class ALLOC >
929 const std::size_t nb_trans = __translators.size();
930 for (std::size_t i = std::size_t(0); i < nb_trans; ++i)
936 template <
template <
typename >
class ALLOC >
938 const std::vector< std::string, ALLOC< std::string > >& new_row) {
941 const std::size_t row_size = new_row.size();
942 if (row_size == std::size_t(0))
return;
944 if (__translators.highestInputColumn() >= row_size) {
948 <<
" columns whereas the database requires at least " 949 << (__translators.highestInputColumn() + 1) <<
" columns");
953 const std::size_t nb_trans = __translators.size();
954 Row< DBTranslatedValue > dbrow;
955 dbrow.reserve(nb_trans);
956 bool has_missing_val =
false;
957 for (std::size_t i = std::size_t(0); i < nb_trans; ++i) {
958 const DBTranslatedValue new_val(__translators.translate(new_row, i));
959 if (__translators.isMissingValue(new_val, i)) has_missing_val =
true;
960 dbrow.pushBack(std::move(new_val));
964 has_missing_val ? IsMissing::True : IsMissing::False);
970 template <
template <
typename >
class ALLOC >
971 bool DatabaseTable< ALLOC >::__isRowCompatible(
972 const typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&
975 const std::size_t row_size = row.size();
976 if (row_size != __translators.size())
return false;
978 const auto& translators = __translators.translators();
979 for (std::size_t i = std::size_t(0); i < row_size; ++i) {
980 switch (translators[i]->getValType()) {
982 if ((row[i].discr_val >= translators[i]->
domainSize())
983 && (row[i].discr_val != std::numeric_limits< std::size_t >::max()))
988 const IContinuousVariable& var =
989 static_cast< const IContinuousVariable&
>(
990 *(translators[i]->variable()));
991 if (((var.lowerBoundAsDouble() > (
double)row[i].cont_val)
992 || (var.upperBoundAsDouble() < (
double)row[i].cont_val))
993 && (row[i].cont_val != std::numeric_limits< float >::max()))
1000 "Translated value type not supported yet");
1009 template <
template <
typename >
class ALLOC >
1011 typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&&
1016 if (!__isRowCompatible(new_row)) {
1017 if (new_row.size() != __translators.size()) {
1021 <<
" elements whereas the database table has " 1022 << __translators.size() <<
" columns");
1025 "the new row is not compatible with the current translators");
1030 contains_missing_data);
1035 template <
template <
typename >
class ALLOC >
1037 const typename DatabaseTable< ALLOC >::template Row< DBTranslatedValue >&
1042 if (!__isRowCompatible(new_row)) {
1043 if (new_row.size() != __translators.size()) {
1047 <<
" elements whereas the database table has " 1048 << __translators.size() <<
" columns");
1051 "the new row is not compatible with the current translators");
1056 contains_missing_data);
1061 template <
template <
typename >
class ALLOC >
1063 const typename DatabaseTable< ALLOC >::template Row< DBCell >& new_row) {
1064 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1068 template <
template <
typename >
class ALLOC >
1070 typename DatabaseTable< ALLOC >::template Row< DBCell >&& new_row) {
1071 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1076 template <
template <
typename >
class ALLOC >
1081 rows_have_missing_vals) {
1084 for (
const auto& new_row : rows) {
1085 if (!__isRowCompatible(new_row)) {
1086 if (new_row.size() != __translators.size()) {
1090 <<
" elements whereas the database table has " 1091 << __translators.size() <<
" columns");
1095 "the new row is not compatible with the current translators");
1101 std::move(rows), rows_have_missing_vals);
1106 template <
template <
typename >
class ALLOC >
1111 rows_have_missing_vals) {
1114 for (
const auto& new_row : new_rows) {
1115 if (!__isRowCompatible(new_row)) {
1116 if (new_row.size() != __translators.size()) {
1120 <<
" elements whereas the database table has " 1121 << __translators.size() <<
" columns");
1125 "the new row is not compatible with the current translators");
1131 new_rows, rows_have_missing_vals);
1136 template <
template <
typename >
class ALLOC >
1139 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1144 template <
template <
typename >
class ALLOC >
1148 GUM_ERROR(NotImplementedYet,
"not implemented yet");
1153 template <
template <
typename >
class ALLOC >
1155 __translators.clear();
1156 __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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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