-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.h
More file actions
45 lines (30 loc) · 1.69 KB
/
util.h
File metadata and controls
45 lines (30 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#ifndef MAP_REDUCE_UTIL_H
#define MAP_REDUCE_UTIL_H
#include <vector>
#include <boost/asio.hpp>
#include "types/KeyValueType.h"
#include "types/KeyValueTypeFactory.h"
namespace map_reduce {
std::pair<std::string, unsigned int> parse_ip_port(const std::string &address);
std::vector<std::pair<std::unique_ptr<KeyValueType>, std::unique_ptr<KeyValueType>>>
get_key_values_from_csv(const std::string &data, std::unique_ptr<KeyValueTypeFactory> &key_factory,
std::unique_ptr<KeyValueTypeFactory> &value_factory, char delimiter = ',',
char end_of_line = '\n');
std::string
to_csv(const std::vector<std::pair<std::unique_ptr<KeyValueType>, std::unique_ptr<KeyValueType>>> &key_values,
char delimeter = ',', char end_of_line = '\n');
std::string to_json(const std::pair<std::unique_ptr<KeyValueType>, std::unique_ptr<KeyValueType>> &key_value);
std::string data_end_message();
std::pair<std::unique_ptr<KeyValueType>, std::unique_ptr<KeyValueType>>
get_key_value_from_json(const std::string &data, std::unique_ptr<KeyValueTypeFactory> &key_factory,
std::unique_ptr<KeyValueTypeFactory> &value_factory);
const std::string data_end_flag = "data_has_ended";
class data_ended_error : public std::runtime_error {
public:
data_ended_error(const std::string &msg = "end of the data") : runtime_error(msg) {}
};
void send_end_message(const boost::asio::ip::tcp::endpoint &reduce_ep);
}
#endif //MAP_REDUCE_UTIL_H