Skip to content

Instantly share code, notes, and snippets.

@drewxa
Last active November 10, 2017 14:23
Show Gist options
  • Save drewxa/ec63142765d4095a36687f2aadba7e45 to your computer and use it in GitHub Desktop.
Save drewxa/ec63142765d4095a36687f2aadba7e45 to your computer and use it in GitHub Desktop.

struct Table
{
  std::vector<std::string> get_column_names() const;
};

Сделать псевдонимы

using Raw = ... ;
using Table = ... ;

Необходимо сделать функцию загрузки .csv файлов в класс Table.

Table read_csv(std::string const& filename, char sep = ';', bool header = false);

Пример использования MapReduce:

auto table = read_csv("bigfile.csv");

auto mapper_op = [](Raw & raw, OutIt out) {
    for (auto& col in row)
    {
      if (col.find("iu8") != std::string::npos)
      {
        std::map<std::string, std::string> data = {
          {"name", col},
          {"university", "bmstu"}
        };
        *out = Raw(data);
        ++out;
      }
    }
};

auto reducer_op = [](std::vector<Raw> & raws, OutIt out) {
    // ...
};


Table new_table = run_map(mapper_op, table);
run_sort(newTable, {"name"});
Table result_table = run_reduce(reducer_op, {"name"}, new_table);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment