-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin_functions.cpp
28 lines (23 loc) · 1.58 KB
/
join_functions.cpp
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
#include "join_functions.h"
std::vector<std::unordered_map<std::string, std::string>> JoinFunctions::join(const std::vector<std::unordered_map<std::string, std::string>>& table1, const std::vector<std::unordered_map<std::string, std::string>>& table2, const std::string& key) {
std::vector<std::unordered_map<std::string, std::string>> result;
for (const auto& record1 : table1) {
for (const auto& record2 : table2) {
if (record1.at(key) == record2.at(key)) {
std::unordered_map<std::string, std::string> combined = record1;
combined.insert(record2.begin(), record2.end());
result.push_back(combined);
}
}
}
return result;
}
std::vector<std::unordered_map<std::string, std::string>> JoinFunctions::leftJoin(const std::vector<std::unordered_map<std::string, std::string>>& table1, const std::vector<std::unordered_map<std::string, std::string>>& table2, const std::string& key) {
// Implement left join logic here
}
std::vector<std::unordered_map<std::string, std::string>> JoinFunctions::rightJoin(const std::vector<std::unordered_map<std::string, std::string>>& table1, const std::vector<std::unordered_map<std::string, std::string>>& table2, const std::string& key) {
// Implement right join logic here
}
std::vector<std::unordered_map<std::string, std::string>> JoinFunctions::fullJoin(const std::vector<std::unordered_map<std::string, std::string>>& table1, const std::vector<std::unordered_map<std::string, std::string>>& table2, const std::string& key) {
// Implement full join logic here
}