|
|
@ -9,6 +9,7 @@
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstdarg>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "io.h"
|
|
|
|
#include "io.h"
|
|
|
|
#include "hasher.h"
|
|
|
|
#include "hasher.h"
|
|
|
|
|
|
|
|
|
|
|
@ -139,8 +140,16 @@ public:
|
|
|
|
ColView<_Ty> operator [](const vector_type<uint32_t>& idxs) const {
|
|
|
|
ColView<_Ty> operator [](const vector_type<uint32_t>& idxs) const {
|
|
|
|
return ColView<_Ty>(*this, idxs);
|
|
|
|
return ColView<_Ty>(*this, idxs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vector_type<_Ty> operator [](const std::vector<bool>& idxs) const {
|
|
|
|
void out(uint32_t n = 4, const char* sep = " ") const {
|
|
|
|
vector_type<_Ty> ret (this->size);
|
|
|
|
|
|
|
|
uint32_t i = 0;
|
|
|
|
|
|
|
|
for(const auto& f : idxs){
|
|
|
|
|
|
|
|
if(f) ret.emplace_back(this->operator[](i));
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void out(uint32_t n = 1000, const char* sep = " ") const {
|
|
|
|
const char* more = "";
|
|
|
|
const char* more = "";
|
|
|
|
if (n < this->size)
|
|
|
|
if (n < this->size)
|
|
|
|
more = " ... ";
|
|
|
|
more = " ... ";
|
|
|
@ -243,7 +252,7 @@ public:
|
|
|
|
Iterator_t end() const {
|
|
|
|
Iterator_t end() const {
|
|
|
|
return Iterator_t(idxs.end(), orig);
|
|
|
|
return Iterator_t(idxs.end(), orig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void out(uint32_t n = 4, const char* sep = " ") const {
|
|
|
|
void out(uint32_t n = 1000, const char* sep = " ") const {
|
|
|
|
n = n > size ? size : n;
|
|
|
|
n = n > size ? size : n;
|
|
|
|
std::cout << '(';
|
|
|
|
std::cout << '(';
|
|
|
|
for (uint32_t i = 0; i < n; ++i)
|
|
|
|
for (uint32_t i = 0; i < n; ++i)
|
|
|
@ -438,19 +447,27 @@ struct TableInfo {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <int ...cols>
|
|
|
|
template <int ...cols>
|
|
|
|
void print2(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
void print2(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr) const {
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr,
|
|
|
|
|
|
|
|
FILE* __restrict fp = nullptr, uint32_t limit = std::numeric_limits<uint32_t>::max()
|
|
|
|
|
|
|
|
) const {
|
|
|
|
|
|
|
|
|
|
|
|
std::string printf_string =
|
|
|
|
std::string printf_string =
|
|
|
|
generate_printf_string<typename std::tuple_element<cols, tuple_type>::type ...>(sep, end);
|
|
|
|
generate_printf_string<typename std::tuple_element<cols, tuple_type>::type ...>(sep, end);
|
|
|
|
|
|
|
|
// puts(printf_string.c_str());
|
|
|
|
std::string header_string = std::string();
|
|
|
|
std::string header_string = std::string();
|
|
|
|
constexpr static int a_cols[] = { cols... };
|
|
|
|
constexpr static int a_cols[] = { cols... };
|
|
|
|
for (int i = 0; i < sizeof...(cols); ++i)
|
|
|
|
if (fp == nullptr){
|
|
|
|
header_string += std::string(this->colrefs[a_cols[i]].name) + sep;
|
|
|
|
header_string = get_header_string(sep, end);
|
|
|
|
const size_t l_sep = strlen(sep);
|
|
|
|
header_string.resize(header_string.size() - strlen(end));
|
|
|
|
if (header_string.size() - l_sep >= 0)
|
|
|
|
}
|
|
|
|
header_string.resize(header_string.size() - l_sep);
|
|
|
|
else {
|
|
|
|
|
|
|
|
for (int i = 0; i < sizeof...(cols); ++i)
|
|
|
|
const auto& prt_loop = [&fp, &view, &printf_string, *this](const auto& f) {
|
|
|
|
header_string += std::string(this->colrefs[a_cols[i]].name) + sep;
|
|
|
|
|
|
|
|
const size_t l_sep = strlen(sep);
|
|
|
|
|
|
|
|
if (header_string.size() - l_sep >= 0)
|
|
|
|
|
|
|
|
header_string.resize(header_string.size() - l_sep);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto& prt_loop = [&fp, &view, &printf_string, *this, &limit](const auto& f) {
|
|
|
|
#ifdef __AQ__HAS__INT128__
|
|
|
|
#ifdef __AQ__HAS__INT128__
|
|
|
|
constexpr auto num_hge = count_type<__int128_t, __uint128_t>((tuple_type*)(0));
|
|
|
|
constexpr auto num_hge = count_type<__int128_t, __uint128_t>((tuple_type*)(0));
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -466,16 +483,21 @@ struct TableInfo {
|
|
|
|
+ 1 // padding for msvc not allowing empty arrays
|
|
|
|
+ 1 // padding for msvc not allowing empty arrays
|
|
|
|
];
|
|
|
|
];
|
|
|
|
setgbuf(cbuf);
|
|
|
|
setgbuf(cbuf);
|
|
|
|
if (view)
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < view->size; ++i) {
|
|
|
|
if (view){
|
|
|
|
|
|
|
|
uint32_t outsz = limit > view->size ? view->size : limit;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < outsz; ++i) {
|
|
|
|
print2_impl<cols...>(f, (*view)[i], printf_string.c_str());
|
|
|
|
print2_impl<cols...>(f, (*view)[i], printf_string.c_str());
|
|
|
|
setgbuf();
|
|
|
|
setgbuf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < colrefs[0].size; ++i) {
|
|
|
|
else{
|
|
|
|
|
|
|
|
uint32_t outsz = limit > colrefs[0].size ? colrefs[0].size : limit;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < outsz; ++i) {
|
|
|
|
print2_impl<cols...>(f, i, printf_string.c_str());
|
|
|
|
print2_impl<cols...>(f, i, printf_string.c_str());
|
|
|
|
setgbuf();
|
|
|
|
setgbuf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (fp)
|
|
|
|
if (fp)
|
|
|
@ -490,15 +512,17 @@ struct TableInfo {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <int ...vals> struct applier {
|
|
|
|
template <int ...vals> struct applier {
|
|
|
|
inline constexpr static void apply(const TableInfo<Types...>& t, const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
inline constexpr static void apply(const TableInfo<Types...>& t, const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr)
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr, uint32_t limit = std::numeric_limits<uint32_t>::max()
|
|
|
|
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
t.template print2<vals ...>(sep, end, view, fp);
|
|
|
|
t.template print2<vals ...>(sep, end, view, fp, limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline void printall(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
inline void printall(const char* __restrict sep = ",", const char* __restrict end = "\n",
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr) {
|
|
|
|
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr,
|
|
|
|
applyIntegerSequence<sizeof...(Types), applier>::apply(*this, sep, end, view, fp);
|
|
|
|
uint32_t limit = std::numeric_limits<uint32_t>::max() ) const {
|
|
|
|
|
|
|
|
applyIntegerSequence<sizeof...(Types), applier>::apply(*this, sep, end, view, fp, limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TableInfo<Types...>* rename(const char* name) {
|
|
|
|
TableInfo<Types...>* rename(const char* name) {
|
|
|
@ -667,7 +691,9 @@ template <class ...Types>
|
|
|
|
template <size_t j>
|
|
|
|
template <size_t j>
|
|
|
|
inline typename std::enable_if<j == sizeof...(Types) - 1, void>::type
|
|
|
|
inline typename std::enable_if<j == sizeof...(Types) - 1, void>::type
|
|
|
|
TableInfo<Types ...>::print_impl(const uint32_t& i, const char* __restrict sep) const {
|
|
|
|
TableInfo<Types ...>::print_impl(const uint32_t& i, const char* __restrict sep) const {
|
|
|
|
std::cout << (get<j>(*this))[i];
|
|
|
|
decltype(auto) t = (get<j>(*this))[i];
|
|
|
|
|
|
|
|
// print(t);
|
|
|
|
|
|
|
|
std::cout << t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class ...Types>
|
|
|
|
template<class ...Types>
|
|
|
@ -682,6 +708,7 @@ inline typename std::enable_if < j < sizeof...(Types) - 1, void>::type
|
|
|
|
template<class ...Types>
|
|
|
|
template<class ...Types>
|
|
|
|
inline void TableInfo<Types...>::print(const char* __restrict sep, const char* __restrict end) const {
|
|
|
|
inline void TableInfo<Types...>::print(const char* __restrict sep, const char* __restrict end) const {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//printall(sep, end);
|
|
|
|
std::string header_string = get_header_string(sep, end);
|
|
|
|
std::string header_string = get_header_string(sep, end);
|
|
|
|
std::cout << header_string.c_str();
|
|
|
|
std::cout << header_string.c_str();
|
|
|
|
|
|
|
|
|
|
|
|