34 static constexpr
bool debug =
true;
38 template <
typename InputDIA>
41 uint64_t max_value = input_dia.Max();
42 sLOG <<
"max_value" << max_value;
45 uint64_t mask = (~uint64_t(0)) << level;
46 uint64_t maskbit = uint64_t(1) << level;
48 using PairBI = std::pair<uint8_t, uint64_t>;
50 auto wt = input_dia.template FlatMap<PairBI>(
51 [level](
const uint64_t&
x,
auto emit) {
52 for (
size_t i = 0; i <= level; ++i) {
53 emit(std::make_pair(i, x));
56 auto wt2 = wt.Sort([mask](
const PairBI& a,
const PairBI& b) {
57 if (a.first != b.first) {
58 return a.first < b.first;
61 return (a.second & (mask >> a.first)) < (b.second & (mask >> a.first));
66 wt2.Map([](
const PairBI& x) {
70 auto binary_wt = wt2.Window(
72 [maskbit](
size_t,
const std::vector<PairBI>& v) {
74 for (
size_t i = 0; i < v.size(); ++i) {
75 uint64_t b = (v[i].second & ((maskbit) >> v[i].first)) != 0;
82 binary_wt.Print(
"BINARY_WT");
84 binary_wt.WriteBinary(
"BINARY_WT");
87 int main(
int argc,
char* argv[]) {
96 "Path to input file.");
103 if (input_path.size()) {
104 auto input_dia = ReadBinary<uint64_t>(ctx, input_path);
108 std::default_random_engine rng(std::random_device { } ());
111 [&](
size_t) {
return uint64_t(rng() % 32); });
#define sLOG
Default logging method: output if the local debug variable is true.
auto Generate(Context &ctx, size_t size, const GenerateFunction &generate_function)
Generate is a Source-DOp, which creates a DIA of given size using a generator function.
int main(int argc, char *argv[])
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
void add_opt_param_string(const std::string &name, std::string &dest, const std::string &desc)
add optional string parameter [name] with description and store to dest
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
static by_string to_string(int val)
convert to string
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
static constexpr bool debug
Command line parser which automatically fills variables and prints nice usage messages.
static unsigned integer_log2_ceil(int i)
calculate the log2 floor of an integer type
tag structure for Window() and FlatWindow()
void set_author(const std::string &author)
Set author of program, will be wrapped.
bool process(int argc, const char *const *argv, std::ostream &os)
auto ConstructWaveletTree(const InputDIA &input_dia)