41 std::mt19937 prng(
seed);
43 uint64_t written_bytes = 0;
47 unsigned num_words_key =
49 unsigned num_words_value =
55 size_t out_size = key_words.size() + 1 + value_words.size() + 1;
56 if (written_bytes + out_size >
totalbytes)
break;
59 os << key_words <<
'\t' << value_words <<
'\n';
61 os << key_words << value_words <<
'\n';
63 written_bytes += out_size;
78 [&](
size_t ,
auto emit) {
80 uint64_t written_bytes = 0;
81 while (written_bytes <
totalbytes / num_workers)
83 unsigned num_words_key =
85 unsigned num_words_value =
91 size_t out_size = key_words.size() + 1 + value_words.size() + 1;
92 if (written_bytes + out_size >
totalbytes)
break;
95 emit(key_words +
"\t" + value_words);
97 emit(key_words + value_words);
99 written_bytes += out_size;
105 int main(
int argc,
char* argv[]) {
110 "minimum words in a key");
112 "maximum words in a key");
115 "minimum words in a value");
117 "maximum words in a value");
120 "random seed (default: 123456)");
123 "add TAB as separator of key/value (for compatbility)");
126 "total number of bytes to generate (approximately)");
128 bool parallel =
false;
129 cp.
add_bool(1,
"parallel", parallel,
130 "run as Thrill parallel/distributed program");
133 cp.
add_string(
'o',
"output",
"<path>", output,
"output path");
147 std::ofstream of(output);
void add_unsigned(char key, const std::string &longkey, unsigned int &dest, const std::string &desc)
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.
size_t num_workers() const
Global number of workers in the system.
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
std::string RandomTextWriterGenerate(size_t num_words, RandomGenerator &rng)
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
void add_param_bytes(const std::string &name, uint32_t &dest, const std::string &desc)
void print_result(std::ostream &os)
print nicely formatted result of processing
static int Sequential(std::ostream &os)
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Command line parser which automatically fills variables and prints nice usage messages.
void add_string(char key, const std::string &longkey, std::string &dest, const std::string &desc)
add string option -key, –longkey and store to dest
size_t my_rank() const
Global rank of this worker among all other workers in the system.
unsigned range_words_value
void add_bool(char key, const std::string &longkey, bool &dest, const std::string &desc)
int main(int argc, char *argv[])
static void Parallel(api::Context &ctx, const std::string &output)
bool process(int argc, const char *const *argv, std::ostream &os)