Thrill  0.1
line_count.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * examples/word_count/line_count.cpp
3  *
4  * Runner program for LineCount example.
5  *
6  * Part of Project Thrill - http://project-thrill.org
7  *
8  * Copyright (C) 2015 Timo Bingmann <[email protected]>
9  *
10  * All rights reserved. Published under the BSD-2 license in the LICENSE file.
11  ******************************************************************************/
12 
14 #include <thrill/api/size.hpp>
15 #include <thrill/common/logger.hpp>
16 #include <tlx/cmdline_parser.hpp>
17 
18 #include <string>
19 
20 using namespace thrill; // NOLINT
21 
22 int main(int argc, char* argv[]) {
23 
25 
26  std::string input;
27  clp.add_param_string("input", input,
28  "input file pattern");
29 
30  if (!clp.process(argc, argv)) {
31  return -1;
32  }
33 
34  clp.print_result();
35 
36  auto start_func =
37  [input](api::Context& ctx) {
38  size_t line_count = api::ReadLines(ctx, input).Size();
39  sLOG1 << "counted" << line_count << "lines in total";
40  };
41 
42  return api::Run(start_func);
43 }
44 
45 /******************************************************************************/
int Run(const std::function< void(Context &)> &job_startpoint)
Runs the given job startpoint with a Context instance.
Definition: context.cpp:947
#define sLOG1
Definition: logger.hpp:38
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
Definition: context.hpp:221
DIA< std::string > ReadLines(Context &ctx, const std::string &filepath)
ReadLines is a DOp, which reads a file from the file system and creates an ordered DIA according to a...
Definition: read_lines.hpp:454
void print_result(std::ostream &os)
print nicely formatted result of processing
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220
Command line parser which automatically fills variables and prints nice usage messages.
void add_param_string(const std::string &name, std::string &dest, const std::string &desc)
add string parameter [name] with description and store to dest
int main(int argc, char *argv[])
Definition: line_count.cpp:22
bool process(int argc, const char *const *argv, std::ostream &os)