cross product done
This commit is contained in:
parent
c3d39eedbd
commit
96eb1a28c0
2 changed files with 7 additions and 14 deletions
21
DBEngine.cpp
21
DBEngine.cpp
|
@ -212,32 +212,25 @@ Relation DBEngine::crossProduct(Relation r1, Relation r2){
|
||||||
new_atts[i].clearAllValues();
|
new_atts[i].clearAllValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//currently all returned relations are called TEMP
|
||||||
|
Relation new_r("TEMP", new_atts);
|
||||||
|
|
||||||
vector<string> r1_tuple;
|
vector<string> r1_tuple;
|
||||||
vector<string> r2_tuple;
|
vector<string> r2_tuple;
|
||||||
|
vector<string> temp;
|
||||||
|
|
||||||
for (int i = 0; i < r1_attsize; ++i) {
|
for (int i = 0; i < r1_attsize; ++i) {
|
||||||
r1_tuple = r1.getTuple(i);
|
r1_tuple = r1.getTuple(i);
|
||||||
|
|
||||||
for (int a = 0; a < r1_tuple.size(); ++a) {
|
|
||||||
cout << r1_tuple[a] << " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < r2_attsize; ++j) {
|
for (int j = 0; j < r2_attsize; ++j) {
|
||||||
r2_tuple = r2.getTuple(j);
|
r2_tuple = r2.getTuple(j);
|
||||||
|
temp = r1_tuple;
|
||||||
|
temp.insert(temp.end(), r2_tuple.begin(), r2_tuple.end());
|
||||||
|
|
||||||
for (int b = 0; b < r2_tuple.size(); ++b){
|
new_r.insertTuple(temp);
|
||||||
cout << r2_tuple[b] << " ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//currently all returned relations are called TEMP
|
|
||||||
Relation new_r("TEMP", new_atts);
|
|
||||||
|
|
||||||
|
|
||||||
return new_r;
|
return new_r;
|
||||||
}
|
}
|
BIN
a.out
Executable file
BIN
a.out
Executable file
Binary file not shown.
Reference in a new issue